Java Code Examples for javax.swing.table.DefaultTableCellRenderer#setToolTipText()
The following examples show how to use
javax.swing.table.DefaultTableCellRenderer#setToolTipText() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResamplingUtils.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
public static void setUpDownsamplingColumn(JTable table, TableColumn downsamplingColumn, String defaultDownsampling) { //Set up the editor for the downsampling JComboBox comboBox = new JComboBox(); for ( String alias : (Set<String>) GPF.getDefaultInstance().getDownsamplerSpiRegistry().getAliases()) { comboBox.addItem(alias); } if(defaultDownsampling != null) { comboBox.setSelectedItem(defaultDownsampling); } downsamplingColumn.setCellEditor(new DefaultCellEditor(comboBox)); DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setToolTipText("Click for combo box"); downsamplingColumn.setCellRenderer(renderer); }
Example 2
Source File: ResamplingUtils.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
public static void setUpUpsamplingColumn(JTable table, TableColumn upsamplingColumn, String defaultUpsampling) { //Set up the editor for the upsampling JComboBox comboBox = new JComboBox(); //TODO use registry when agreement with other teams. By the moment, they are available only the options in the old resampling comboBox.addItem("Nearest"); comboBox.addItem("Bilinear"); comboBox.addItem("Bicubic"); if(defaultUpsampling != null) { comboBox.setSelectedItem(defaultUpsampling); } upsamplingColumn.setCellEditor(new DefaultCellEditor(comboBox)); DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setToolTipText("Click for combo box"); upsamplingColumn.setCellRenderer(renderer); }
Example 3
Source File: TableRenderDemo.java From marathonv5 with Apache License 2.0 | 6 votes |
public void setUpSportColumn(JTable table, TableColumn sportColumn) { // Set up the editor for the sport cells. JComboBox comboBox = new JComboBox(); comboBox.addItem("Snowboarding"); comboBox.addItem("Rowing"); comboBox.addItem("Knitting"); comboBox.addItem("Speed reading"); comboBox.addItem("Pool"); comboBox.addItem("None of the above"); sportColumn.setCellEditor(new DefaultCellEditor(comboBox)); // Set up tool tips for the sport cells. DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setToolTipText("Click for combo box"); sportColumn.setCellRenderer(renderer); }
Example 4
Source File: TableRenderDemo.java From mars-sim with GNU General Public License v3.0 | 6 votes |
public void setUpSportColumn(JTable table, TableColumn sportColumn) { //Set up the editor for the sport cells. JComboBox<String> comboBox = new JComboBox<String>(); comboBox.addItem("Snowboarding"); comboBox.addItem("Rowing"); comboBox.addItem("Knitting"); comboBox.addItem("Speed reading"); comboBox.addItem("Pool"); comboBox.addItem("None of the above"); sportColumn.setCellEditor(new DefaultCellEditor(comboBox)); //Set up tool tips for the sport cells. DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setToolTipText("Click for combo box"); sportColumn.setCellRenderer(renderer); }
Example 5
Source File: XTable.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * This method sets read write rows to be blue, and other rows to be their * default rendered colour. */ @Override public TableCellRenderer getCellRenderer(int row, int column) { DefaultTableCellRenderer tcr = (DefaultTableCellRenderer) super.getCellRenderer(row,column); tcr.setToolTipText(getToolTip(row,column)); if (defaultColor == null) { defaultColor = tcr.getForeground(); editableColor = Color.blue; errorColor = Color.red; // this sometimes happens for some reason if (defaultColor == null) { return tcr; } } if (column != VALUE_COLUMN) { tcr.setForeground(defaultColor); return tcr; } if (isCellError(row,column)) { tcr.setForeground(errorColor); } else if (isCellEditable(row, column)) { tcr.setForeground(editableColor); } else { tcr.setForeground(defaultColor); } return tcr; }
Example 6
Source File: XTable.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * This method sets read write rows to be blue, and other rows to be their * default rendered colour. */ @Override public TableCellRenderer getCellRenderer(int row, int column) { DefaultTableCellRenderer tcr = (DefaultTableCellRenderer) super.getCellRenderer(row,column); tcr.setToolTipText(getToolTip(row,column)); if (defaultColor == null) { defaultColor = tcr.getForeground(); editableColor = Color.blue; errorColor = Color.red; // this sometimes happens for some reason if (defaultColor == null) { return tcr; } } if (column != VALUE_COLUMN) { tcr.setForeground(defaultColor); return tcr; } if (isCellError(row,column)) { tcr.setForeground(errorColor); } else if (isCellEditable(row, column)) { tcr.setForeground(editableColor); } else { tcr.setForeground(defaultColor); } return tcr; }
Example 7
Source File: XTable.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * This method sets read write rows to be blue, and other rows to be their * default rendered colour. */ @Override public TableCellRenderer getCellRenderer(int row, int column) { DefaultTableCellRenderer tcr = (DefaultTableCellRenderer) super.getCellRenderer(row,column); tcr.setToolTipText(getToolTip(row,column)); if (defaultColor == null) { defaultColor = tcr.getForeground(); editableColor = Color.blue; errorColor = Color.red; // this sometimes happens for some reason if (defaultColor == null) { return tcr; } } if (column != VALUE_COLUMN) { tcr.setForeground(defaultColor); return tcr; } if (isCellError(row,column)) { tcr.setForeground(errorColor); } else if (isCellEditable(row, column)) { tcr.setForeground(editableColor); } else { tcr.setForeground(defaultColor); } return tcr; }
Example 8
Source File: XTable.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * This method sets read write rows to be blue, and other rows to be their * default rendered colour. */ @Override public TableCellRenderer getCellRenderer(int row, int column) { DefaultTableCellRenderer tcr = (DefaultTableCellRenderer) super.getCellRenderer(row,column); tcr.setToolTipText(getToolTip(row,column)); if (defaultColor == null) { defaultColor = tcr.getForeground(); editableColor = Color.blue; errorColor = Color.red; // this sometimes happens for some reason if (defaultColor == null) { return tcr; } } if (column != VALUE_COLUMN) { tcr.setForeground(defaultColor); return tcr; } if (isCellError(row,column)) { tcr.setForeground(errorColor); } else if (isCellEditable(row, column)) { tcr.setForeground(editableColor); } else { tcr.setForeground(defaultColor); } return tcr; }
Example 9
Source File: XTable.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * This method sets read write rows to be blue, and other rows to be their * default rendered colour. */ @Override public TableCellRenderer getCellRenderer(int row, int column) { DefaultTableCellRenderer tcr = (DefaultTableCellRenderer) super.getCellRenderer(row,column); tcr.setToolTipText(getToolTip(row,column)); if (defaultColor == null) { defaultColor = tcr.getForeground(); editableColor = Color.blue; errorColor = Color.red; // this sometimes happens for some reason if (defaultColor == null) { return tcr; } } if (column != VALUE_COLUMN) { tcr.setForeground(defaultColor); return tcr; } if (isCellError(row,column)) { tcr.setForeground(errorColor); } else if (isCellEditable(row, column)) { tcr.setForeground(editableColor); } else { tcr.setForeground(defaultColor); } return tcr; }
Example 10
Source File: XTable.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * This method sets read write rows to be blue, and other rows to be their * default rendered colour. */ @Override public TableCellRenderer getCellRenderer(int row, int column) { DefaultTableCellRenderer tcr = (DefaultTableCellRenderer) super.getCellRenderer(row,column); tcr.setToolTipText(getToolTip(row,column)); if (defaultColor == null) { defaultColor = tcr.getForeground(); editableColor = Color.blue; errorColor = Color.red; // this sometimes happens for some reason if (defaultColor == null) { return tcr; } } if (column != VALUE_COLUMN) { tcr.setForeground(defaultColor); return tcr; } if (isCellError(row,column)) { tcr.setForeground(errorColor); } else if (isCellEditable(row, column)) { tcr.setForeground(editableColor); } else { tcr.setForeground(defaultColor); } return tcr; }
Example 11
Source File: XTable.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * This method sets read write rows to be blue, and other rows to be their * default rendered colour. */ @Override public TableCellRenderer getCellRenderer(int row, int column) { DefaultTableCellRenderer tcr = (DefaultTableCellRenderer) super.getCellRenderer(row,column); tcr.setToolTipText(getToolTip(row,column)); if (defaultColor == null) { defaultColor = tcr.getForeground(); editableColor = Color.blue; errorColor = Color.red; // this sometimes happens for some reason if (defaultColor == null) { return tcr; } } if (column != VALUE_COLUMN) { tcr.setForeground(defaultColor); return tcr; } if (isCellError(row,column)) { tcr.setForeground(errorColor); } else if (isCellEditable(row, column)) { tcr.setForeground(editableColor); } else { tcr.setForeground(defaultColor); } return tcr; }
Example 12
Source File: XTable.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * This method sets read write rows to be blue, and other rows to be their * default rendered colour. */ @Override public TableCellRenderer getCellRenderer(int row, int column) { DefaultTableCellRenderer tcr = (DefaultTableCellRenderer) super.getCellRenderer(row,column); tcr.setToolTipText(getToolTip(row,column)); if (defaultColor == null) { defaultColor = tcr.getForeground(); editableColor = Color.blue; errorColor = Color.red; // this sometimes happens for some reason if (defaultColor == null) { return tcr; } } if (column != VALUE_COLUMN) { tcr.setForeground(defaultColor); return tcr; } if (isCellError(row,column)) { tcr.setForeground(errorColor); } else if (isCellEditable(row, column)) { tcr.setForeground(editableColor); } else { tcr.setForeground(defaultColor); } return tcr; }
Example 13
Source File: XTable.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * This method sets read write rows to be blue, and other rows to be their * default rendered colour. */ @Override public TableCellRenderer getCellRenderer(int row, int column) { DefaultTableCellRenderer tcr = (DefaultTableCellRenderer) super.getCellRenderer(row,column); tcr.setToolTipText(getToolTip(row,column)); if (defaultColor == null) { defaultColor = tcr.getForeground(); editableColor = Color.blue; errorColor = Color.red; // this sometimes happens for some reason if (defaultColor == null) { return tcr; } } if (column != VALUE_COLUMN) { tcr.setForeground(defaultColor); return tcr; } if (isCellError(row,column)) { tcr.setForeground(errorColor); } else if (isCellEditable(row, column)) { tcr.setForeground(editableColor); } else { tcr.setForeground(defaultColor); } return tcr; }
Example 14
Source File: XTable.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * This method sets read write rows to be blue, and other rows to be their * default rendered colour. */ @Override public TableCellRenderer getCellRenderer(int row, int column) { DefaultTableCellRenderer tcr = (DefaultTableCellRenderer) super.getCellRenderer(row,column); tcr.setToolTipText(getToolTip(row,column)); if (defaultColor == null) { defaultColor = tcr.getForeground(); editableColor = Color.blue; errorColor = Color.red; // this sometimes happens for some reason if (defaultColor == null) { return tcr; } } if (column != VALUE_COLUMN) { tcr.setForeground(defaultColor); return tcr; } if (isCellError(row,column)) { tcr.setForeground(errorColor); } else if (isCellEditable(row, column)) { tcr.setForeground(editableColor); } else { tcr.setForeground(defaultColor); } return tcr; }
Example 15
Source File: XTable.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * This method sets read write rows to be blue, and other rows to be their * default rendered colour. */ @Override public TableCellRenderer getCellRenderer(int row, int column) { DefaultTableCellRenderer tcr = (DefaultTableCellRenderer) super.getCellRenderer(row,column); tcr.setToolTipText(getToolTip(row,column)); if (defaultColor == null) { defaultColor = tcr.getForeground(); editableColor = Color.blue; errorColor = Color.red; // this sometimes happens for some reason if (defaultColor == null) { return tcr; } } if (column != VALUE_COLUMN) { tcr.setForeground(defaultColor); return tcr; } if (isCellError(row,column)) { tcr.setForeground(errorColor); } else if (isCellEditable(row, column)) { tcr.setForeground(editableColor); } else { tcr.setForeground(defaultColor); } return tcr; }
Example 16
Source File: XTable.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * This method sets read write rows to be blue, and other rows to be their * default rendered colour. */ @Override public TableCellRenderer getCellRenderer(int row, int column) { DefaultTableCellRenderer tcr = (DefaultTableCellRenderer) super.getCellRenderer(row,column); tcr.setToolTipText(getToolTip(row,column)); if (defaultColor == null) { defaultColor = tcr.getForeground(); editableColor = Color.blue; errorColor = Color.red; // this sometimes happens for some reason if (defaultColor == null) { return tcr; } } if (column != VALUE_COLUMN) { tcr.setForeground(defaultColor); return tcr; } if (isCellError(row,column)) { tcr.setForeground(errorColor); } else if (isCellEditable(row, column)) { tcr.setForeground(editableColor); } else { tcr.setForeground(defaultColor); } return tcr; }
Example 17
Source File: XTable.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * This method sets read write rows to be blue, and other rows to be their * default rendered colour. */ @Override public TableCellRenderer getCellRenderer(int row, int column) { DefaultTableCellRenderer tcr = (DefaultTableCellRenderer) super.getCellRenderer(row,column); tcr.setToolTipText(getToolTip(row,column)); if (defaultColor == null) { defaultColor = tcr.getForeground(); editableColor = Color.blue; errorColor = Color.red; // this sometimes happens for some reason if (defaultColor == null) { return tcr; } } if (column != VALUE_COLUMN) { tcr.setForeground(defaultColor); return tcr; } if (isCellError(row,column)) { tcr.setForeground(errorColor); } else if (isCellEditable(row, column)) { tcr.setForeground(editableColor); } else { tcr.setForeground(defaultColor); } return tcr; }
Example 18
Source File: XgappUpgradeSelector.java From gate-core with GNU Lesser General Public License v3.0 | 4 votes |
public XgappUpgradeSelector(URI gappUri, List<UpgradeXGAPP.UpgradePath> upgrades) { this.gappUri = gappUri; this.upgrades = upgrades; model = new UpgradePathTableModel(upgrades); strategyIcons = new EnumMap<UpgradeXGAPP.UpgradePath.UpgradeStrategy, Icon>(UpgradeXGAPP.UpgradePath.UpgradeStrategy.class); strategyIcons.put(UpgradeXGAPP.UpgradePath.UpgradeStrategy.UPGRADE, new GreenBallIcon(16, 16)); strategyIcons.put(UpgradeXGAPP.UpgradePath.UpgradeStrategy.PLUGIN_ONLY, new YellowBallIcon(16, 16)); strategyIcons.put(UpgradeXGAPP.UpgradePath.UpgradeStrategy.SKIP, new RedBallIcon(16, 16)); disabledStrategyIcon = new RedBallIcon(16, 16, true); XJTable pluginTable = new XJTable(model); pluginTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); JScrollPane scroller = new JScrollPane(pluginTable); statusLabel = new JLabel("Select plugin versions to upgrade to"); JPanel topPanel = new JPanel(new BorderLayout()); topPanel.add(statusLabel, BorderLayout.CENTER); Box buttonBox = Box.createHorizontalBox(); JButton loadButton = new JButton(); loadButton.setIcon(new OpenFileIcon(24, 24)); loadButton.setToolTipText("Load a saved upgrade script"); loadButton.setActionCommand("LOADSCRIPT"); loadButton.addActionListener(this); buttonBox.add(loadButton); buttonBox.add(Box.createHorizontalStrut(5)); JButton saveButton = new JButton(); saveButton.setIcon(new SaveIcon(24, 24)); saveButton.setToolTipText("Save selected upgrades as a script"); saveButton.setActionCommand("SAVESCRIPT"); saveButton.addActionListener(this); buttonBox.add(saveButton); topPanel.add(buttonBox, BorderLayout.SOUTH); mainPanel = new JPanel(new BorderLayout()); mainPanel.add(topPanel, BorderLayout.NORTH); mainPanel.add(scroller, BorderLayout.CENTER); DefaultTableCellRenderer newPluginRenderer = new DefaultTableCellRenderer(); newPluginRenderer.setToolTipText("Double-click or press the space key to change"); pluginTable.getColumnModel().getColumn(1).setCellRenderer(newPluginRenderer); pluginTable.getColumnModel().getColumn(2).setCellRenderer(new UpgradeStrategyRenderer()); pluginTable.getColumnModel().getColumn(3).setCellRenderer(new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); label.setEnabled(((UpgradeXGAPP.UpgradePath.UpgradeStrategy)table.getValueAt(row, 2)).upgradePlugin); return label; } }); pluginTable.getColumnModel().getColumn(1).setCellEditor(new PluginCoordinatesEditor()); // Alternate between two different cell editor components to avoid combo box rendering weirdness pluginTable.getColumnModel().getColumn(2).setCellEditor( new AlternatingTableCellEditor(new UpgradeStrategyEditor(), new UpgradeStrategyEditor())); pluginTable.getColumnModel().getColumn(3).setCellEditor( new AlternatingTableCellEditor(new UpgradeVersionEditor(), new UpgradeVersionEditor())); // initial sort model.fireTableDataChanged(); }
Example 19
Source File: SchemaPanel.java From netbeans with Apache License 2.0 | 4 votes |
private void initComp() { schemaTable.getModel().addTableModelListener(this); schemaTable.getTableHeader().setReorderingAllowed( false ); startString = getStartString(); //set key listener to delete rows when user presses del key schemaTable.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { tableKeyPressed(evt); } }); //add the initial row addRow(startString); //set width TableColumn column = null; for (int i = 0; i < 4; i++) { column = schemaTable.getColumnModel().getColumn(i); if (i == PRIMARY_COL) { column.setPreferredWidth(40); } else if(i ==SCHEMA_COL) { column.setPreferredWidth(250); } else { column.setPreferredWidth(80); } } //set renderer and editor for the first column schemaTable.getColumnModel().getColumn(PRIMARY_COL).setCellRenderer(new RadioColumnRenderer()); schemaTable.getColumnModel().getColumn(PRIMARY_COL).setCellEditor(new RadioColumnEditor()); //set up rendere/editor for the combo box column TableColumn rootColumn = schemaTable.getColumnModel().getColumn(ROOT_COL); rootColumn.setCellEditor(new ComboBoxColumnEditor()); DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setToolTipText(NbBundle.getMessage(SchemaPanel.class, "TIP_COMBO_COL")); rootColumn.setCellRenderer(renderer); int height = schemaTable.getRowHeight(); // Determine highest cell in the row for (int c=0; c<schemaTable.getColumnCount(); c++) { TableCellRenderer r = schemaTable.getCellRenderer(0, c); Component comp = schemaTable.prepareRenderer(r, 0, c); int h = comp.getPreferredSize().height; height = Math.max(height, h); } schemaTable.setRowHeight(height); }