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);
}
}
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");
}
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");
}
}
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;
}
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();
}
}
Aggregations