Search in sources :

Example 6 with JTableHeader

use of javax.swing.table.JTableHeader in project EnrichmentMapApp by BaderLab.

the class HeatMapMainPanel method createTableHeader.

private void createTableHeader(int expressionColumnWidth) {
    JTableHeader header = table.getTableHeader();
    header.setReorderingAllowed(false);
    HeatMapTableModel tableModel = (HeatMapTableModel) table.getModel();
    TableColumnModel columnModel = table.getColumnModel();
    TableCellRenderer vertRenderer = new ColumnHeaderVerticalRenderer();
    TableCellRenderer vertRendererPheno1 = new ColumnHeaderVerticalRenderer(EMStyleBuilder.Colors.LIGHTEST_PHENOTYPE_1);
    TableCellRenderer vertRendererPheno2 = new ColumnHeaderVerticalRenderer(EMStyleBuilder.Colors.LIGHTEST_PHENOTYPE_2);
    TableColumn rankColumn = columnModel.getColumn(HeatMapTableModel.RANK_COL);
    rankColumn.setHeaderRenderer(columnHeaderRankOptionRendererFactory.create(this, HeatMapTableModel.RANK_COL));
    rankColumn.setPreferredWidth(100);
    ((TableRowSorter<?>) table.getRowSorter()).setSortable(HeatMapTableModel.RANK_COL, false);
    int colCount = tableModel.getColumnCount();
    for (int col = HeatMapTableModel.DESC_COL_COUNT; col < colCount; col++) {
        EMDataSet dataset = tableModel.getDataSet(col);
        String pheno1 = dataset.getEnrichments().getPhenotype1();
        String pheno2 = dataset.getEnrichments().getPhenotype2();
        Optional<String> pheno = tableModel.getPhenotype(col);
        TableCellRenderer renderer;
        if (pheno.filter(p -> p.equals(pheno1)).isPresent())
            renderer = vertRendererPheno1;
        else if (pheno.filter(p -> p.equals(pheno2)).isPresent())
            renderer = vertRendererPheno2;
        else
            renderer = vertRenderer;
        TableColumn column = columnModel.getColumn(col);
        column.setHeaderRenderer(renderer);
        column.setPreferredWidth(expressionColumnWidth);
    }
}
Also used : Arrays(java.util.Arrays) Inject(com.google.inject.Inject) AfterInjection(org.baderlab.csplugins.enrichmentmap.AfterInjection) HeatMapTableModel(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.HeatMapTableModel) Operator(org.baderlab.csplugins.enrichmentmap.view.heatmap.HeatMapParams.Operator) JTableHeader(javax.swing.table.JTableHeader) TableCellRenderer(javax.swing.table.TableCellRenderer) IconManager(org.cytoscape.util.swing.IconManager) Assisted(com.google.inject.assistedinject.Assisted) ComboItem(org.baderlab.csplugins.enrichmentmap.view.util.ComboItem) Map(java.util.Map) BorderLayout(java.awt.BorderLayout) JComboBox(javax.swing.JComboBox) DEFAULT_SIZE(javax.swing.GroupLayout.DEFAULT_SIZE) Set(java.util.Set) ColorAndValueRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.ColorAndValueRenderer) Distance(org.baderlab.csplugins.enrichmentmap.view.heatmap.HeatMapParams.Distance) Component(java.awt.Component) Collectors(java.util.stream.Collectors) TableRowSorter(javax.swing.table.TableRowSorter) Sets(com.google.common.collect.Sets) PREFERRED_SIZE(javax.swing.GroupLayout.PREFERRED_SIZE) List(java.util.List) Alignment(javax.swing.GroupLayout.Alignment) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) LookAndFeelUtil(org.cytoscape.util.swing.LookAndFeelUtil) SwingUtil(org.baderlab.csplugins.enrichmentmap.view.util.SwingUtil) ColumnHeaderRankOptionRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.ColumnHeaderRankOptionRenderer) JCheckBox(javax.swing.JCheckBox) Optional(java.util.Optional) JTable(javax.swing.JTable) ColumnHeaderVerticalRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.ColumnHeaderVerticalRenderer) RankValue(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankValue) JPanel(javax.swing.JPanel) ListSelectionModel(javax.swing.ListSelectionModel) ActionListener(java.awt.event.ActionListener) TableColumnModel(javax.swing.table.TableColumnModel) SortKey(javax.swing.RowSorter.SortKey) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) CompletableFuture(java.util.concurrent.CompletableFuture) GradientLegendPanel(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.GradientLegendPanel) ArrayList(java.util.ArrayList) SwingUtilities(javax.swing.SwingUtilities) EMStyleBuilder(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder) JButton(javax.swing.JButton) Transform(org.baderlab.csplugins.enrichmentmap.view.heatmap.HeatMapParams.Transform) TableColumn(javax.swing.table.TableColumn) JPopupMenu(javax.swing.JPopupMenu) ActionEvent(java.awt.event.ActionEvent) RankOptionErrorHeader(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankOptionErrorHeader) RankValueRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankValueRenderer) JScrollPane(javax.swing.JScrollPane) JLabel(javax.swing.JLabel) GroupLayout(javax.swing.GroupLayout) ColorRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.ColorRenderer) Comparator(java.util.Comparator) TableCellRenderer(javax.swing.table.TableCellRenderer) HeatMapTableModel(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.HeatMapTableModel) JTableHeader(javax.swing.table.JTableHeader) TableColumnModel(javax.swing.table.TableColumnModel) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) ColumnHeaderVerticalRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.ColumnHeaderVerticalRenderer) TableColumn(javax.swing.table.TableColumn) TableRowSorter(javax.swing.table.TableRowSorter)

Example 7 with JTableHeader

use of javax.swing.table.JTableHeader in project jdk8u_jdk by JetBrains.

the class bug6889007 method main.

public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    Robot robot = new Robot();
    robot.setAutoDelay(20);
    final JFrame frame = new JFrame();
    frame.setUndecorated(true);
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JTableHeader th = new JTableHeader();
            th.setColumnModel(new JTable(20, 5).getColumnModel());
            th.setUI(new MyTableHeaderUI());
            frame.add(th);
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    });
    toolkit.realSync();
    Point point = frame.getLocationOnScreen();
    int shift = 10;
    int x = point.x;
    int y = point.y + frame.getHeight() / 2;
    for (int i = -shift; i < frame.getWidth() + 2 * shift; i++) {
        robot.mouseMove(x++, y);
    }
    toolkit.realSync();
    // 9 is a magic test number
    if (MyTableHeaderUI.getTestValue() != 9) {
        throw new RuntimeException("Unexpected test number " + MyTableHeaderUI.getTestValue());
    }
    System.out.println("ok");
}
Also used : SunToolkit(sun.awt.SunToolkit) JTableHeader(javax.swing.table.JTableHeader)

Example 8 with JTableHeader

use of javax.swing.table.JTableHeader in project jdk8u_jdk by JetBrains.

the class DimensionEncapsulation method run.

@Override
public void run() {
    runTest(new Panel());
    runTest(new Button());
    runTest(new Checkbox());
    runTest(new Canvas());
    runTest(new Choice());
    runTest(new Label());
    runTest(new Scrollbar());
    runTest(new TextArea());
    runTest(new TextField());
    runTest(new Dialog(new JFrame()));
    runTest(new Frame());
    runTest(new Window(new JFrame()));
    runTest(new FileDialog(new JFrame()));
    runTest(new List());
    runTest(new ScrollPane());
    runTest(new JFrame());
    runTest(new JDialog(new JFrame()));
    runTest(new JWindow(new JFrame()));
    runTest(new JLabel("hi"));
    runTest(new JMenu());
    runTest(new JTree());
    runTest(new JTable());
    runTest(new JMenuItem());
    runTest(new JCheckBoxMenuItem());
    runTest(new JToggleButton());
    runTest(new JSpinner());
    runTest(new JSlider());
    runTest(Box.createVerticalBox());
    runTest(Box.createHorizontalBox());
    runTest(new JTextField());
    runTest(new JTextArea());
    runTest(new JTextPane());
    runTest(new JPasswordField());
    runTest(new JFormattedTextField());
    runTest(new JEditorPane());
    runTest(new JButton());
    runTest(new JColorChooser());
    runTest(new JFileChooser());
    runTest(new JCheckBox());
    runTest(new JInternalFrame());
    runTest(new JDesktopPane());
    runTest(new JTableHeader());
    runTest(new JLayeredPane());
    runTest(new JRootPane());
    runTest(new JMenuBar());
    runTest(new JOptionPane());
    runTest(new JRadioButton());
    runTest(new JRadioButtonMenuItem());
    runTest(new JPopupMenu());
    //runTest(new JScrollBar()); --> don't test defines max and min in
    // terms of preferred
    runTest(new JScrollPane());
    runTest(new JViewport());
    runTest(new JSplitPane());
    runTest(new JTabbedPane());
    runTest(new JToolBar());
    runTest(new JSeparator());
    runTest(new JProgressBar());
    if (!failures.isEmpty()) {
        System.out.println("These classes failed");
        for (final Component failure : failures) {
            System.out.println(failure.getClass());
        }
        throw new RuntimeException("Test failed");
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) Choice(java.awt.Choice) JTextArea(javax.swing.JTextArea) TextArea(java.awt.TextArea) JTextArea(javax.swing.JTextArea) Label(java.awt.Label) JLabel(javax.swing.JLabel) JTableHeader(javax.swing.table.JTableHeader) JToggleButton(javax.swing.JToggleButton) JToggleButton(javax.swing.JToggleButton) Button(java.awt.Button) JRadioButton(javax.swing.JRadioButton) JButton(javax.swing.JButton) JFrame(javax.swing.JFrame) Checkbox(java.awt.Checkbox) JDialog(javax.swing.JDialog) FileDialog(java.awt.FileDialog) Dialog(java.awt.Dialog) JTextField(javax.swing.JTextField) TextField(java.awt.TextField) JFormattedTextField(javax.swing.JFormattedTextField) JSlider(javax.swing.JSlider) ArrayList(java.util.ArrayList) List(java.awt.List) Canvas(java.awt.Canvas) JWindow(javax.swing.JWindow) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) ScrollPane(java.awt.ScrollPane) JScrollPane(javax.swing.JScrollPane) JTable(javax.swing.JTable) JSpinner(javax.swing.JSpinner) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JDialog(javax.swing.JDialog) JFrame(javax.swing.JFrame) Frame(java.awt.Frame) JInternalFrame(javax.swing.JInternalFrame) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JTextPane(javax.swing.JTextPane) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) Scrollbar(java.awt.Scrollbar) Window(java.awt.Window) JWindow(javax.swing.JWindow) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JToolBar(javax.swing.JToolBar) JPopupMenu(javax.swing.JPopupMenu) Panel(java.awt.Panel) JEditorPane(javax.swing.JEditorPane) JRootPane(javax.swing.JRootPane) FileDialog(java.awt.FileDialog) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Example 9 with JTableHeader

use of javax.swing.table.JTableHeader in project intellij-plugins by JetBrains.

the class DartProblemsViewPanel method createTable.

@NotNull
private TableView<DartProblem> createTable() {
    final TableView<DartProblem> table = new TableView<>(new DartProblemsTableModel(myProject, myPresentationHelper));
    table.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                // as in NewErrorTreeViewPanel
                navigate(false);
            }
        }
    });
    EditSourceOnDoubleClickHandler.install(table);
    table.addMouseListener(new PopupHandler() {

        @Override
        public void invokePopup(Component comp, int x, int y) {
            popupInvoked(comp, x, y);
        }
    });
    //noinspection unchecked
    ((DefaultRowSorter) table.getRowSorter()).setRowFilter(myPresentationHelper.getRowFilter());
    table.getRowSorter().addRowSorterListener(e -> {
        final List<? extends RowSorter.SortKey> sortKeys = myTable.getRowSorter().getSortKeys();
        assert sortKeys.size() == 1 : sortKeys;
        ((DartProblemsTableModel) myTable.getModel()).setSortKey(sortKeys.get(0));
    });
    new TableSpeedSearch(table, object -> object instanceof DartProblem ? ((DartProblem) object).getErrorMessage() + " " + ((DartProblem) object).getPresentableLocation() : "");
    table.setShowVerticalLines(false);
    table.setShowHorizontalLines(false);
    table.setStriped(true);
    table.setRowHeight(table.getRowHeight() + JBUI.scale(4));
    JTableHeader tableHeader = table.getTableHeader();
    tableHeader.setPreferredSize(new Dimension(0, table.getRowHeight()));
    return table;
}
Also used : KeyAdapter(java.awt.event.KeyAdapter) JTableHeader(javax.swing.table.JTableHeader) RelativePoint(com.intellij.ui.awt.RelativePoint) KeyEvent(java.awt.event.KeyEvent) TableView(com.intellij.ui.table.TableView) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with JTableHeader

use of javax.swing.table.JTableHeader in project adempiere by adempiere.

the class VHeaderRenderer method handleClickEvent.

//	getTableCellRendererComponent
protected void handleClickEvent(MouseEvent e) {
    JTableHeader header = (JTableHeader) (e.getSource());
    JTable tableView = header.getTable();
    TableColumnModel columnModel = tableView.getColumnModel();
    int viewColumn = columnModel.getColumnIndexAtX(e.getX());
    int column = tableView.convertColumnIndexToModel(viewColumn);
    if (viewColumn == m_column && e.getClickCount() == 1 && column != -1) {
        m_check.doClick();
    }
}
Also used : JTable(javax.swing.JTable) JTableHeader(javax.swing.table.JTableHeader) TableColumnModel(javax.swing.table.TableColumnModel)

Aggregations

JTableHeader (javax.swing.table.JTableHeader)123 JTable (javax.swing.JTable)31 TableColumn (javax.swing.table.TableColumn)27 TableCellRenderer (javax.swing.table.TableCellRenderer)25 TableColumnModel (javax.swing.table.TableColumnModel)24 Component (java.awt.Component)21 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)19 JScrollPane (javax.swing.JScrollPane)17 MouseEvent (java.awt.event.MouseEvent)15 JLabel (javax.swing.JLabel)15 Color (java.awt.Color)11 MouseAdapter (java.awt.event.MouseAdapter)11 JPanel (javax.swing.JPanel)11 DefaultTableModel (javax.swing.table.DefaultTableModel)10 BorderLayout (java.awt.BorderLayout)9 Dimension (java.awt.Dimension)9 Point (java.awt.Point)9 JButton (javax.swing.JButton)8 JComponent (javax.swing.JComponent)8 JPopupMenu (javax.swing.JPopupMenu)7