Java Examples for javax.swing.JTable
The following java examples will help you to understand the usage of javax.swing.JTable. These source code samples are taken from different open source projects.
Example 1
Project: JadexPlayer-master File: SortHeaderRenderer.java View source code |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
int index = -1;
int direction = 0;
if (table != null) {
if (table.getModel() instanceof ISorterFilterTableModel) {
ISorterFilterTableModel model = (ISorterFilterTableModel) table.getModel();
index = table.convertColumnIndexToView(model.getSortColumn());
direction = model.getSortDirection();
}
JTableHeader header = table.getTableHeader();
if (header != null) {
setForeground(header.getForeground());
setBackground(header.getBackground());
setFont(header.getFont());
}
}
setIcon(col == index && direction != ISorterFilterTableModel.NONE ? new SortArrowIcon(direction) : null);
setText((value == null) ? "" : value.toString());
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
return this;
}
Example 2
Project: ocelot-master File: MatchScoreRenderer.java View source code |
/* * (non-Javadoc) * * @see * javax.swing.table.DefaultTableCellRenderer#getTableCellRendererComponent * (javax.swing.JTable, java.lang.Object, boolean, boolean, int, int) */ @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); JTextPane textPane = new JTextPane(); textPane.setBackground(comp.getBackground()); textPane.setForeground(Color.white); textPane.setFont(comp.getFont()); if (comp != null && value != null) { int score = (int) value; Color highlightColor = comp.getBackground(); if (score == 100) { highlightColor = new Color(16, 164, 87); } else if (score >= 95) { highlightColor = new Color(95, 164, 16); } else if (score >= 85) { highlightColor = new Color(232, 206, 11); } else if (score >= 75) { highlightColor = new Color(232, 143, 11); } else if (score >= 65) { highlightColor = new Color(232, 99, 11); } else { highlightColor = new Color(232, 51, 11); } DefaultHighlightPainter painter = new DefaultHighlightPainter(highlightColor); StyledDocument style = textPane.getStyledDocument(); SimpleAttributeSet rightAlign = new SimpleAttributeSet(); StyleConstants.setAlignment(rightAlign, StyleConstants.ALIGN_RIGHT); try { style.insertString(style.getLength(), " " + value + "% ", rightAlign); textPane.getHighlighter().addHighlight(0, textPane.getText().length(), painter); } catch (BadLocationException e) { LOG.warn("Error while highlighting the score " + value + "at column " + column + " and row " + row + ".", e); } } return textPane; }
Example 3
Project: assertj-swing-master File: AbstractContainerFixture_table_Test.java View source code |
@Test public void should_Find_Visible_JTable_By_Matcher() { robot.showWindow(window); JTableFixture table = fixture.table(new GenericTypeMatcher<JTable>(JTable.class) { @Override protected boolean isMatching(@Nonnull JTable t) { return t.getRowCount() == 8 && t.getColumnCount() == 6; } }); assertThat(table.target()).isSameAs(window.table); }
Example 4
Project: eMandoa-master File: CellRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JPanel panel = new JPanel(new BorderLayout());
//Funtzio honi JProgressBar denean bakarrik deituko dio
panel.add((JProgressBar) value, BorderLayout.CENTER);
if (isSelected) {
panel.setBackground(table.getSelectionBackground());
} else {
panel.setBackground(table.getSelectionForeground());
}
return panel;
}
Example 5
Project: iranAdempiere-master File: IconRenderer.java View source code |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
// needs no foreground
if (isSelected) {
super.setBackground(table.getSelectionBackground());
} else {
super.setBackground(table.getBackground());
}
if (value == null || !(value instanceof Icon)) {
setIcon(null);
} else {
setIcon((Icon) value);
}
return this;
}
Example 6
Project: jn-master File: PacketTableRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
Component c;
if (value instanceof Component) {
c = (Component) value;
if (isSelected) {
c.setForeground(table.getSelectionForeground());
c.setBackground(table.getSelectionBackground());
}
} else
c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
if (c instanceof JComponent) {
JComponent jc = (JComponent) c;
jc.setToolTipText(_table.getToolTip(row, col));
}
if (_table.getIsMarked(row) && !isSelected)
c.setBackground(Color.YELLOW);
else if (!isSelected)
c.setBackground(table.getBackground());
return c;
}
Example 7
Project: learning-bittorrent-master File: IconAndNameRenderer.java View source code |
/**
* Returns the <tt>Component</tt> that displays the icons & names
* based on the <tt>IconAndNameHolder</tt> object.
*/
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
IconAndNameHolder in = (IconAndNameHolder) value;
Icon icon = null;
String name = null;
if (in != null) {
icon = in.getIcon();
name = in.getName();
}
setIcon(icon);
return super.getTableCellRendererComponent(table, name, isSelected, hasFocus, row, column);
}
Example 8
Project: radar-netbeans-master File: LocationRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable jtable, Object o, boolean bln, boolean bln1, int i, int i1) {
Object value;
if (o instanceof IssueLocation) {
IssueLocation location = (IssueLocation) o;
if (location.getLineNumber() > 0) {
value = String.format("%4d:%s", location.getLineNumber(), location.getSimpleComponentName());
} else {
value = String.format(" %s", location.getSimpleComponentName());
}
} else {
value = o;
}
return super.getTableCellRendererComponent(jtable, value, bln, bln1, i, i1);
}
Example 9
Project: tizzit-master File: IconRenderer.java View source code |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
// needs no foreground
if (isSelected) {
super.setBackground(table.getSelectionBackground());
} else {
super.setBackground(table.getBackground());
}
if (value == null || !(value instanceof Icon)) {
setIcon(null);
} else {
setIcon((Icon) value);
}
return this;
}
Example 10
Project: Universal-G-Code-Sender-master File: ComboRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (isSelected) {
setForeground(table.getSelectionForeground());
setBackground(table.getSelectionBackground());
} else {
setForeground(table.getForeground());
setBackground(table.getBackground());
}
setSelectedItem(value);
return this;
}
Example 11
Project: OpenDolphin-master File: PatientSearchTransferHandler.java View source code |
@Override protected Transferable createTransferable(JComponent c) { JTable sourceTable = (JTable) c; ListTableModel<PatientModel> tableModel = (ListTableModel<PatientModel>) sourceTable.getModel(); int fromIndex = sourceTable.getSelectedRow(); PatientModel dragItem = (PatientModel) tableModel.getObject(fromIndex); return dragItem != null ? new PatientTransferable(dragItem) : null; }
Example 12
Project: MuVis-master File: ListViewTableUI.java View source code |
/** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents void initComponents() { tableViewPanel = new javax.swing.JScrollPane(); tracksTableView = new javax.swing.JTable(); setLayout(new java.awt.CardLayout()); tracksTableView.setAutoCreateRowSorter(true); tracksTableView.setModel(new TracksTableModel()); tracksTableView.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS); tracksTableView.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); tracksTableView.getTableHeader().setReorderingAllowed(false); tableViewPanel.setViewportView(tracksTableView); tracksTableView.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); tracksTableView.getColumnModel().getColumn(0).setPreferredWidth(2); add(tableViewPanel, "card3"); }
Example 13
Project: atlasframework-master File: FilterTableCellRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JLabel proto = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
ImageIcon icon = Icons.ICON_FILTER;
proto.setIcon(icon);
// i8n
proto.setToolTipText("Click to change filter!");
Filter filter = (Filter) value;
proto.setEnabled((filter != null && filter != Filter.INCLUDE && (Boolean) table.getModel().getValueAt(row, RulesListTable.COLIDX_ENABLED)));
return proto;
}
Example 14
Project: aXbo-research-master File: IconCellRenderer.java View source code |
/**
* {@inheritDoc}
*/
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (iconUrl != null && (val == null || value.equals(val))) {
ImageIcon icon = new ImageIcon(getClass().getClassLoader().getResource(iconUrl));
setIcon(icon);
} else {
setIcon(null);
}
return this;
}
Example 15
Project: Blossom-master File: PercentageCellRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int rowIndex, final int columnIndex) {
setNativeLookAndFeel(table, value, isSelected);
if (value != null) {
final double percentage = Double.valueOf(value.toString());
setText(decimalFormatter.format(percentage * Utilities.PERCENTAGE_FACTOR));
setToolTipText(String.valueOf(percentage));
}
return this;
}
Example 16
Project: BlossomsPokemonGoManager-master File: PercentageCellRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int rowIndex, final int columnIndex) {
setNativeLookAndFeel(table, value, isSelected);
if (value != null) {
final double percentage = Double.valueOf(value.toString());
setText(decimalFormatter.format(percentage * Utilities.PERCENTAGE_FACTOR));
setToolTipText(String.valueOf(percentage));
}
return this;
}
Example 17
Project: Desktop-master File: IconStringRenderer.java View source code |
/* * @see TableCellRenderer#getTableCellRendererComponent(JTable, Object, boolean, boolean, int, int) */ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel retval = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (value instanceof JLabel) { retval.setText(((JLabel) value).getText()); retval.setIcon(((JLabel) value).getIcon()); retval.setToolTipText(toolTip); } return retval; }
Example 18
Project: Docear-master File: IconStringRenderer.java View source code |
/* * @see TableCellRenderer#getTableCellRendererComponent(JTable, Object, boolean, boolean, int, int) */ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel retval = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (value instanceof JLabel) { retval.setText(((JLabel) value).getText()); retval.setIcon(((JLabel) value).getIcon()); retval.setToolTipText(toolTip); } return retval; }
Example 19
Project: EnrichmentMapApp-master File: ColorAndValueRenderer.java View source code |
@Override
public JLabel getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
JLabel label = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
if (value instanceof Double && Double.isFinite((Double) value)) {
String text = format.format((Double) value);
label.setText(text);
label.setFont(new Font((UIManager.getFont("TableHeader.font")).getName(), Font.PLAIN, (UIManager.getFont("TableHeader.font")).getSize() - 2));
label.setHorizontalAlignment(SwingConstants.RIGHT);
}
return label;
}
Example 20
Project: Feuille-master File: xfxintParamsTableRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (value instanceof Params) {
Params p = (Params) value;
setText(" " + p.toString());
if (p.isInactive()) {
setForeground(Color.red.darker());
} else {
setForeground(Color.green.darker());
}
}
if (isSelected) {
setBackground(new Color(219, 231, 255));
} else {
setBackground(Color.white);
}
return this;
}
Example 21
Project: filebot-master File: FileRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value != null) {
File file = (File) value;
setText(file.getName());
setToolTipText(file.getPath());
if (SUBTITLE_FILES.accept(file)) {
setIcon(ResourceManager.getIcon("file.subtitle"));
} else if (VIDEO_FILES.accept(file)) {
setIcon(ResourceManager.getIcon("file.video"));
}
setForeground(table.getForeground());
} else {
setText("<Click to select video file>");
setToolTipText(null);
setIcon(null);
setForeground(Color.LIGHT_GRAY);
}
return this;
}
Example 22
Project: flowspring-master File: ReadtableRenderer.java View source code |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (component instanceof JLabel) {
JLabel label = (JLabel) component;
String string = (String) value;
string = string.replace(this.readwindow.getPath(), "");
label.setText("." + string);
return label;
}
return component;
}
Example 23
Project: freehep-ncolor-pdf-master File: TableHeaderCellRenderer.java View source code |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
// Inherit the colors and font from the header component
if (table != null) {
JTableHeader header = table.getTableHeader();
if (header != null) {
setForeground(header.getForeground());
setBackground(header.getBackground());
setFont(header.getFont());
}
}
setText(value.toString());
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
setHorizontalAlignment(JLabel.CENTER);
return this;
}
Example 24
Project: gitj-master File: DefaultRenderer.java View source code |
@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);
if (isSelected) {
label.setBackground(TABLE_SELECTED);
} else if (row % 2 == 0) {
label.setBackground(TABLE_GRAY);
} else {
label.setBackground(Color.white);
}
return label;
}
Example 25
Project: gtitool-master File: HistoryPathTableCellRenderer.java View source code |
/** * {@inheritDoc} * * @see TableCellRenderer#getTableCellRendererComponent(JTable, Object, * boolean, boolean, int, int) */ @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, @SuppressWarnings("unused") boolean hasFocus, int row, @SuppressWarnings("unused") int column) { HistoryPath historyPath = null; if (value instanceof HistoryPath) { historyPath = ((HistoryPath) value); } else { //$NON-NLS-1$ throw new IllegalArgumentException("the value is not a history path"); } HistoryPathComponent component = new HistoryPathComponent(historyPath, table, row); if (isSelected) { component.setBackground(table.getSelectionBackground()); component.setForeground(table.getSelectionForeground()); } else { component.setBackground(table.getBackground()); component.setForeground(table.getForeground()); } component.setEnabled(table.isEnabled()); component.setFont(table.getFont()); return component; }
Example 26
Project: hbase-gui-admin-master File: EditTableCellRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
Component comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
EditTableDataModel model = (EditTableDataModel) table.getModel();
if (model.isChanged(row)) {
comp.setBackground(Color.gray);
} else {
if (!isSelected) {
comp.setBackground(null);
}
}
return (comp);
}
Example 27
Project: JCOOL-master File: PropertyCellEditor.java View source code |
public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, final int row, int column) {
property.setValue(value);
Component editorComponent = property.getEditorComponent();
editorComponent.validate();
panel.removeAll();
panel.add(editorComponent, BorderLayout.CENTER);
if (panel.getComponentListeners().length == 0) {
panel.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
table.setRowHeight(row, e.getComponent().getPreferredSize().height);
}
});
}
panel.setBackground(table.getBackground());
for (int i = 0, size = panel.getComponentCount(); i < size; i++) {
panel.getComponent(i).setBackground(table.getBackground());
}
return panel;
}
Example 28
Project: jmeter-plugins-master File: HeaderClickCheckAllListenerTest.java View source code |
/** * Test of mouseClicked method, of class HeaderClickCheckAllListener. */ @Test public void testMouseClicked_work() { System.out.println("mouseClicked"); JTable table = new JTable(); table.addColumn(new TableColumn()); MouseEvent evt = new MouseEvent(table.getTableHeader(), 1, 1, 1, 10, 10, 1, true); HeaderClickCheckAllListener instance = new HeaderClickCheckAllListener(); instance.mouseClicked(evt); }
Example 29
Project: jmodeltest2-master File: FrameResults.java View source code |
public void initComponents() throws Exception { tableModels = tempTableModels; tableAIC = tempTableAIC; tableAICc = tempTableAICc; tableBIC = tempTableBIC; tableDT = tempTableDT; // set format for all columns for (int i = 0; i < 8; i++) { TableColumn AICtableColumn = tableAIC.getColumnModel().getColumn(i); AICtableColumn.setCellRenderer((javax.swing.table.TableCellRenderer) AICRenderer); TableColumn AICctableColumn = tableAICc.getColumnModel().getColumn(i); AICctableColumn.setCellRenderer((javax.swing.table.TableCellRenderer) AICcRenderer); TableColumn BICtableColumn = tableBIC.getColumnModel().getColumn(i); BICtableColumn.setCellRenderer((javax.swing.table.TableCellRenderer) BICRenderer); TableColumn DTtableColumn = tableDT.getColumnModel().getColumn(i); DTtableColumn.setCellRenderer((javax.swing.table.TableCellRenderer) DTRenderer); } panelInfo.setSize(PANEL_INFO_DIM); panelInfo.setLocation(new java.awt.Point(0, 390)); panelInfo.setVisible(true); panelInfo.setLayout(null); labelInfo.setSize(LABEL_INFO_DIM); labelInfo.setLocation(new java.awt.Point(40, 0)); labelInfo.setVisible(true); labelInfo.setText("Decimal numbers are rounded. Click on column headers to sort data in ascending or descending order (+Shift)"); labelInfo.setForeground(java.awt.Color.gray); labelInfo.setHorizontalTextPosition(javax.swing.JLabel.CENTER); labelInfo.setFont(XManager.FONT_LABEL_BIG); labelDate.setSize(LABEL_DATE_DIM); labelDate.setLocation(new java.awt.Point(40, 10)); labelDate.setVisible(true); labelDate.setText("Date"); labelDate.setForeground(java.awt.Color.gray); labelDate.setFont(XManager.FONT_LABEL_BIG); tabbedPane.setSize(TABBED_PANE_DIM); tabbedPane.setLocation(new java.awt.Point(0, 0)); tabbedPane.setVisible(true); tabbedPane.setAutoscrolls(true); panelModels.setVisible(true); panelModels.setLayout(null); panelModels.setFont(XManager.FONT_CONSOLE); scrollPaneModels.setSize(SCROLL_PANE_DIM); scrollPaneModels.setLocation(new java.awt.Point(12, 14)); scrollPaneModels.setVisible(true); scrollPaneModels.setAutoscrolls(true); scrollPaneModels.setForeground(java.awt.Color.blue); scrollPaneModels.setBackground(null); scrollPaneModels.setFont(XManager.FONT_TABULAR); tableModels.setColumnSelectionAllowed(true); tableModels.setToolTipText("Click and Shift+Click on headers to order up and down"); tableModels.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); tableModels.setCellSelectionEnabled(true); tableModels.setVisible(true); tableModels.setPreferredScrollableViewportSize(new java.awt.Dimension(600, 300)); tableModels.setGridColor(java.awt.Color.gray); tableModels.setFont(XManager.FONT_TABULAR); panelAIC.setVisible(true); panelAIC.setLayout(null); scrollPaneAIC.setSize(SCROLL_PANE_DIM); scrollPaneAIC.setLocation(new java.awt.Point(12, 14)); scrollPaneAIC.setVisible(true); scrollPaneAIC.setAutoscrolls(true); scrollPaneAIC.setForeground(java.awt.Color.blue); scrollPaneAIC.setBackground(null); scrollPaneAIC.setFont(XManager.FONT_TABULAR); tableAIC.setColumnSelectionAllowed(true); tableAIC.setToolTipText("Click and Shift+Click on headers to order up and down"); tableAIC.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS); tableAIC.setCellSelectionEnabled(true); tableAIC.setVisible(true); tableAIC.setPreferredScrollableViewportSize(new java.awt.Dimension(675, 350)); tableAIC.setGridColor(java.awt.Color.gray); tableAIC.setFont(XManager.FONT_TABULAR); panelAICc.setVisible(true); panelAICc.setLayout(null); scrollPaneAICc.setSize(SCROLL_PANE_DIM); scrollPaneAICc.setLocation(new java.awt.Point(12, 14)); scrollPaneAICc.setVisible(true); scrollPaneAICc.setAutoscrolls(true); scrollPaneAICc.setForeground(java.awt.Color.blue); scrollPaneAICc.setBackground(null); scrollPaneAICc.setFont(XManager.FONT_TABULAR); tableAICc.setColumnSelectionAllowed(true); tableAICc.setToolTipText("Click and Shift+Click on headers to order up and down"); tableAICc.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); tableAICc.setCellSelectionEnabled(true); tableAICc.setVisible(true); tableAICc.setPreferredScrollableViewportSize(new java.awt.Dimension(675, 350)); tableAICc.setGridColor(java.awt.Color.gray); tableAICc.setFont(XManager.FONT_TABULAR); panelBIC.setVisible(true); panelBIC.setLayout(null); scrollPaneBIC.setSize(SCROLL_PANE_DIM); scrollPaneBIC.setLocation(new java.awt.Point(12, 14)); scrollPaneBIC.setVisible(true); scrollPaneBIC.setAutoscrolls(true); scrollPaneBIC.setForeground(java.awt.Color.blue); scrollPaneBIC.setBackground(null); scrollPaneBIC.setFont(XManager.FONT_TABULAR); tableBIC.setColumnSelectionAllowed(true); tableBIC.setToolTipText("Click and Shift+Click on headers to order up and down"); tableBIC.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); tableBIC.setCellSelectionEnabled(true); tableBIC.setVisible(true); tableBIC.setPreferredScrollableViewportSize(new java.awt.Dimension(675, 350)); tableBIC.setGridColor(java.awt.Color.gray); tableBIC.setFont(XManager.FONT_TABULAR); panelDT.setVisible(true); panelDT.setLayout(null); scrollPaneDT.setSize(SCROLL_PANE_DIM); scrollPaneDT.setLocation(new java.awt.Point(12, 14)); scrollPaneDT.setVisible(true); scrollPaneDT.setAutoscrolls(true); scrollPaneDT.setForeground(java.awt.Color.blue); scrollPaneDT.setBackground(null); scrollPaneDT.setFont(XManager.FONT_TABULAR); tableDT.setColumnSelectionAllowed(true); tableDT.setToolTipText("Click and Shift+Click on headers to order up and down"); tableDT.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); tableDT.setCellSelectionEnabled(true); tableDT.setVisible(true); tableDT.setPreferredScrollableViewportSize(new java.awt.Dimension(675, 350)); tableDT.setGridColor(java.awt.Color.gray); tableDT.setFont(XManager.FONT_TABULAR); setLocation(new java.awt.Point(281, 80)); setResizable(true); setFont(XManager.FONT_TABULAR); setLayout(null); setTitle("Results"); setResizable(false); panelInfo.add(labelInfo); panelInfo.add(labelDate); tabbedPane.add(panelModels); tabbedPane.setTitleAt(tabbedPane.getTabCount() - 1, "Models"); tabbedPane.add(panelAIC); tabbedPane.setTitleAt(tabbedPane.getTabCount() - 1, "AIC"); tabbedPane.setEnabledAt(tabbedPane.getTabCount() - 1, false); tabbedPane.setForegroundAt(tabbedPane.getTabCount() - 1, Color.gray); tabbedPane.add(panelAICc); tabbedPane.setTitleAt(tabbedPane.getTabCount() - 1, "AICc"); tabbedPane.setEnabledAt(tabbedPane.getTabCount() - 1, false); tabbedPane.setForegroundAt(tabbedPane.getTabCount() - 1, Color.gray); tabbedPane.add(panelBIC); tabbedPane.setTitleAt(tabbedPane.getTabCount() - 1, "BIC"); tabbedPane.setEnabledAt(tabbedPane.getTabCount() - 1, false); tabbedPane.setForegroundAt(tabbedPane.getTabCount() - 1, Color.gray); tabbedPane.add(panelDT); tabbedPane.setTitleAt(tabbedPane.getTabCount() - 1, "DT"); tabbedPane.setEnabledAt(tabbedPane.getTabCount() - 1, false); tabbedPane.setForegroundAt(tabbedPane.getTabCount() - 1, Color.gray); panelModels.add(scrollPaneModels); scrollPaneModels.getViewport().add(tableModels); panelAIC.add(scrollPaneAIC); scrollPaneAIC.getViewport().add(tableAIC); panelAICc.add(scrollPaneAICc); scrollPaneAICc.getViewport().add(tableAICc); panelBIC.add(scrollPaneBIC); scrollPaneBIC.getViewport().add(tableBIC); panelDT.add(scrollPaneDT); scrollPaneDT.getViewport().add(tableDT); add(panelInfo); add(tabbedPane); tabbedPane.setSelectedIndex(0); setSize(FRAME_DIM); // event handling addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { thisWindowClosing(e); } }); sorterModels.addMouseListenerToHeaderInTable(tableModels); sorterAIC.addMouseListenerToHeaderInTable(tableAIC); sorterAICc.addMouseListenerToHeaderInTable(tableAICc); sorterBIC.addMouseListenerToHeaderInTable(tableBIC); sorterDT.addMouseListenerToHeaderInTable(tableDT); // set date Date today = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("dd MMMMM yyyy"); String datenewformat = formatter.format(today); labelDate.setText(datenewformat); }
Example 30
Project: JMultiMC-master File: DateCellRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value instanceof Long) {
Long millis = (Long) value;
Date installDate = new Date(millis);
if (component instanceof JLabel) {
((JLabel) component).setText(installDate.toString());
}
}
return component;
}
Example 31
Project: josm-plugins-master File: NameIconCellRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int colIndex) {
if (isSelected) {
setBackground(BG_COLOR_SELECTED);
} else {
setBackground(Color.WHITE);
}
TaggingPreset provider = (TaggingPreset) value;
if (provider != null) {
setText(provider.getName());
setIcon(provider.getIcon());
}
return this;
}
Example 32
Project: LimeWire-Pirate-Edition-master File: IsPlayingRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
setText("");
setBorder(emptyBorder);
if (value instanceof LocalFileItem) {
if (playerMediator.get().isPlaying(((LocalFileItem) value).getFile()) || playerMediator.get().isPaused(((LocalFileItem) value).getFile()))
setIcon(playingIcon);
else
setIcon(null);
} else {
setIcon(null);
}
return this;
}
Example 33
Project: MPS-master File: ParameterTypeCellEditor.java View source code |
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
MethodParameter p = ListSequence.fromList(this.myModel.getParameters()).getElement(row);
final JComboBox comboBox = new JComboBox(ListSequence.fromList(p.getAvailableTypes()).toGenericArray(String.class));
comboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent p0) {
ParameterTypeCellEditor.this.mySelected = ((String) comboBox.getSelectedItem());
}
});
comboBox.setSelectedItem(value);
return comboBox;
}
Example 34
Project: netbeans-mantis-integration-master File: PriorityCellRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
String id = null;
if (value instanceof ObjectRef) {
ObjectRef or = (ObjectRef) value;
value = or.getName();
id = or.getId().toString();
}
JLabel renderer = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (id != null) {
renderer.setIcon(new ImageIcon(mpp.getImageById(id)));
} else {
renderer.setIcon(null);
}
return renderer;
}
Example 35
Project: platypus-master File: TreedSortingTest.java View source code |
@Test public void treedSorterTest() throws Exception { System.out.println("treedSorterTest"); initTree(); JFrame frame = new JFrame(); frame.getContentPane().setLayout(new BorderLayout()); TreedModel model = new TestTreedModel(); TableFront2TreedModel<TreeItem> tModel = new TableFront2TreedModel<>(model); tModel.expand(tree.get(37), false); tModel.expand(tree.get(7), false); tModel.expand(tree.get(56), false); tModel.expand(tree.get(138), false); JTable tbl = new JTable(tModel); tbl.setRowSorter(new TreedRowsSorter<>(tModel, null)); frame.getContentPane().add(new JScrollPane(tbl), BorderLayout.CENTER); frame.setSize(800, 700); //frame.setVisible(true); Thread.sleep(100); //frame.setVisible(false); }
Example 36
Project: project-bacon-master File: TrendEnumCellRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JLabel c = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
c.setText("");
//Icon.
int index = Arrays.asList(TRENDS).indexOf((Trend) value);
c.setToolTipText(TREND_ICON_TIPS[index]);
c.setIcon(scaledIcons.get(index));
return c;
}
Example 37
Project: SlingBeans-master File: PropertyTableCellEditor.java View source code |
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
PropertyTableModel tableModel = (PropertyTableModel) table.getModel();
valueEditorContainer = new ValueEditorContainer();
valueEditorContainer.hideBorders();
FileObjectAttribute foa = tableModel.getAttribute(row);
valueEditorContainer.setTypeAndValue(foa.getType(), foa.getValue());
return valueEditorContainer;
}
Example 38
Project: SmartTools-master File: FileTableRender.java View source code |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
setOpaque(isSelected);
if (isSelected) {
setBackground(Color.WHITE);
setForeground(Color.BLACK);
} else {
setForeground(Color.WHITE);
}
if (column == 0) {
setText(null);
setIcon((Icon) value);
} else {
setText(value == null ? "" : value.toString());
setIcon(null);
}
return this;
}
Example 39
Project: speechalyzer-master File: CustomTableCellRenderer.java View source code |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value instanceof String) {
String amount = (String) value;
if (column == 5 || column == 6) {
if (amount.trim().startsWith("A")) {
cell.setBackground(Color.pink);
// you can also customize the Font and Foreground this way
// cell.setForeground();
// cell.setFont();
} else {
cell.setBackground(Color.white);
}
} else {
cell.setBackground(Color.white);
}
}
return cell;
}
Example 40
Project: sqlpower-library-master File: CheckBoxRenderer.java View source code |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (isSelected) {
setForeground(table.getSelectionForeground());
setBackground(table.getSelectionBackground());
} else {
setForeground(table.getForeground());
setBackground(table.getBackground());
}
setSelected((value != null && ((Boolean) value).booleanValue()));
return this;
}
Example 41
Project: WhiteRabbit-master File: TableCellLongTextRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
final JTextArea jtext = new JTextArea();
jtext.setText((String) value);
jtext.setWrapStyleWord(true);
jtext.setLineWrap(true);
jtext.setFont(table.getFont());
jtext.setSize(table.getColumn(table.getColumnName(column)).getWidth(), (int) jtext.getPreferredSize().getHeight());
jtext.setMargin(new Insets(10, 5, 10, 5));
return jtext;
}
Example 42
Project: WorldPainter-master File: JButtonTableCellRenderer.java View source code |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component renderer;
if (value != null) {
setText(((JButton) value).getText());
renderer = this;
} else {
renderer = emptyCellRenderer;
}
if (isSelected) {
renderer.setBackground(table.getSelectionBackground());
} else {
renderer.setBackground(table.getBackground());
}
return renderer;
}
Example 43
Project: ZazilDWH-master File: CellRender.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
//throw new UnsupportedOperationException("Not supported yet.");
if (isSelected) {
setForeground(table.getSelectionForeground());
setBackground(table.getSelectionBackground());
} else {
setForeground(table.getSelectionForeground());
setBackground(UIManager.getColor("Button.background"));
}
setText((value == null) ? "" : value.toString());
return this;
}
Example 44
Project: BW4T-master File: EntityTableCellRenderer.java View source code |
/** (non-Javadoc) * @see javax.swing.table.DefaultTableCellRenderer#getTableCellRendererComponent * (javax.swing.JTable, java.lang.Object, boolean, boolean, int, int) */ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (table.getName().equals(EntityPanel.getBotTableName())) { setAppropriateColorBotTableName(value, column, component); } else if (table.getName().equals(EntityPanel.getePartnerTableName())) { setAppropriateColorEPartner(value, column, component); } return component; }
Example 45
Project: HermesJMS-master File: HermesCellEditor.java View source code |
/* * (non-Javadoc) * * @see javax.swing.table.TableCellEditor#getTableCellEditorComponent(javax.swing.JTable, * java.lang.Object, boolean, int, int) */ public Component getTableCellEditorComponent(JTable arg0, Object arg1, boolean arg2, int arg3, int arg4) { try { final Vector<String> options = new Vector<String>(); final Context ctx = HermesBrowser.getBrowser().getContext(); for (NamingEnumeration names = ctx.listBindings(""); names.hasMore(); ) { final Binding b = (Binding) names.next(); if (b.getObject() instanceof Hermes) { options.add(b.getName()); } } final JComboBox combo = new JComboBox(options); combo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { selection = (String) combo.getSelectedItem(); } }); return combo; } catch (NamingException ex) { throw new HermesRuntimeException(ex); } }
Example 46
Project: mmfplanner-master File: RoiTableCellRenderer.java View source code |
/** * Returns a JLabel with bold text for the leftmost and rightmost columns as * well as "X". * * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, * java.lang.Object, boolean, boolean, int, int) */ @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { // use the default values from the parent super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); // change the bold value if not set correctly boolean bold = (((0 == column) && (row > table.getRowCount() - 8)) || (table.getColumnCount() - 1 == column) || (row == table.getRowCount() - 2) || (row == table.getRowCount() - 7) || "X".equals(value)); if (bold != ((getFont().getStyle() & Font.BOLD) == Font.BOLD)) { setFont(table.getFont().deriveFont((bold ? Font.BOLD : Font.PLAIN))); } // only the left column is left-aligned, all others are right-aligned if (0 == column) { setHorizontalAlignment(SwingConstants.LEFT); } else if ("X".equals(value)) { setHorizontalAlignment(SwingConstants.CENTER); } else { setHorizontalAlignment(SwingConstants.RIGHT); } // calculated data is gray if (!isSelected) { boolean gray = (row >= table.getRowCount() - 7); setBackground((gray ? TangoColor.ALUMINIUM_1 : Color.WHITE)); } return this; }
Example 47
Project: OsmUi-master File: BooleanParamRenderer.java View source code |
/* (non-Javadoc) * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int) */ @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { BooleanParameter param = (BooleanParameter) value; Component c = delegate.getTableCellRendererComponent(table, param.getValueBoolean(), isSelected, hasFocus, row, column); if (c instanceof JCheckBox) { JCheckBox cb = (JCheckBox) c; cb.setHorizontalAlignment(SwingConstants.CENTER); } return c; }
Example 48
Project: Scute-master File: ResultsTableCellRenderer.java View source code |
/* * (non-Javadoc) * * @see * javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax * .swing.JTable, java.lang.Object, boolean, boolean, int, int) */ @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { // String text = String.valueOf(value); setText(text); // table.getRowMargin() // int thisHeight = getPreferredSize().height; // if (thisHeight > table.getRowHeight(row)) { // table.setRowHeight(row, getPreferredSize().height); // } // this.setWrapStyleWord(true); // this.setLineWrap(true); int fontHeight = getFontMetrics(getFont()).getHeight(); // int textLength = text.length(); int lines = text.split("<br/>").length + 1; // // (table.getRowMargin())+ int height = fontHeight * lines; // int height = getPreferredSize().height; table.setRowHeight(row, height); return this; }
Example 49
Project: slumdroid-master File: ComboBoxRenderer.java View source code |
/* (non-Javadoc) * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int) */ @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (isSelected) { setForeground(table.getSelectionForeground()); super.setBackground(table.getSelectionBackground()); } else { setForeground(table.getForeground()); setBackground(table.getBackground()); } setSelectedItem(value); return this; }
Example 50
Project: svarog-master File: ChooseExperimentTable.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
ChooseExperimentTableModel tableModel = (ChooseExperimentTableModel) table.getModel();
label.setBackground(tableModel.getRowColor(row, isSelected));
if (isSelected) {
label.setForeground(Color.white);
} else {
label.setForeground(Color.black);
}
return label;
}
Example 51
Project: windowtester-master File: JTableRecorder.java View source code |
/** Normally, a click in a table results in selection of a given cell. */ protected Step createClick(Component target, int x, int y, int mods, int count) { JTable table = (JTable) target; Point where = new Point(x, y); int row = table.rowAtPoint(where); int col = table.columnAtPoint(where); ComponentReference cr = getResolver().addComponent(target); String methodName = "actionSelectCell"; ArrayList args = new ArrayList(); args.add(cr.getID()); args.add(getLocationArgument(table, x, y)); if (row == -1 || col == -1) { methodName = "actionClick"; } if ((mods != 0 && mods != MouseEvent.BUTTON1_MASK) || count > 1) { methodName = "actionClick"; args.add(abbot.util.AWT.getMouseModifiers(mods)); if (count > 1) { args.add(String.valueOf(count)); } } return new Action(getResolver(), null, methodName, (String[]) args.toArray(new String[args.size()]), javax.swing.JTable.class); }
Example 52
Project: ptii-master File: JTableComponentBuilder.java View source code |
public java.awt.Component getInstance(java.util.Map<String, Object> beanProperties) throws Exception { JTable table = new JTable(); table.setModel(new AbstractTableModel() { public int getRowCount() { return 10; } public int getColumnCount() { return 10; } public Object getValueAt(int row, int col) { return "" + row + ":" + col; } }); JScrollPane scrollPane = new JScrollPane(table); return scrollPane; }
Example 53
Project: MediathekView-master File: PanelInfoStarts.java View source code |
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jButtonAuffrischen = new javax.swing.JButton();
javax.swing.JScrollPane jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
setBorder(javax.swing.BorderFactory.createEtchedBorder());
jButtonAuffrischen.setText("Auffrischen");
jTable1.setAutoCreateRowSorter(true);
jTable1.setModel(new TModel());
jScrollPane1.setViewportView(jTable1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 461, Short.MAX_VALUE).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE).addComponent(jButtonAuffrischen))).addContainerGap()));
layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 276, Short.MAX_VALUE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jButtonAuffrischen).addContainerGap()));
}
Example 54
Project: android-sdkfido-master File: TableUtils.java View source code |
public static void setMinimumHeight(int height, JTable table, JScrollPane scroller) {
Dimension dim = table.getPreferredScrollableViewportSize();
dim.height = height;
table.setPreferredScrollableViewportSize(dim);
table.setMinimumSize(dim);
// table.setFillsViewportHeight(true);
Dimension dimHeader = table.getTableHeader().getPreferredSize();
dim.height += dimHeader.height;
scroller.setMinimumSize(dim);
}
Example 55
Project: ASH-Viewer-master File: LinkEntryAction.java View source code |
protected void actionPerformed(JTable table, DrawingState drawing, Point location, ActionEvent event) {
DrawingState current = drawing.getValueAt(location, 2, 2) == null ? null : drawing;
if (current != null && last != null && current != last) {
helper.createLinkEntry(current, last);
table.repaint();
last = null;
return;
} else {
last = current;
return;
}
}
Example 56
Project: aspectj-in-action-code-master File: Main.java View source code |
public static void main(String[] args) { JFrame appFrame = new JFrame(); appFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); DefaultTableModel tableModel = new DefaultTableModel(4, 2); JTable table = new JTable(tableModel); appFrame.getContentPane().add(table); appFrame.pack(); appFrame.setVisible(true); System.err.println("Frame is now visible"); tableModel.setValueAt("[0,0]", 0, 0); tableModel.removeRow(2); }
Example 57
Project: Astrosoft-master File: SortableHeaderRenderer.java View source code |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component c = tableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
SortableTableModel model = (SortableTableModel) table.getModel();
AstrosoftTableColumn modelColumn = model.getColumn(table.convertColumnIndexToModel(column));
SortInfo sortInfo = model.getSortInfo();
if (sortInfo != null && sortInfo.getSortBy() == modelColumn) {
if (c instanceof JLabel) {
JLabel l = (JLabel) c;
l.setHorizontalTextPosition(JLabel.LEFT);
l.setIcon(((SortableTable) table).getSortImageIcon());
return l;
}
} else {
((JLabel) c).setIcon(null);
}
return c;
}
Example 58
Project: bitten-master File: AddressListRenderer.java View source code |
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) { Collection<AddressListable> list = (Collection<AddressListable>) value; Object[][] data = new Object[list.size()][]; Object[] columns = { "Address", "Value" }; int i = 0; for (AddressListable l : list) { String add = "COINBASE"; GraphAddress a = l.address(); BigInteger v = l.value(); if (a != null) { add = a.toString(); } data[i] = new Object[] { add, Utils.bitcoinValueToFriendlyString(v) }; i++; } JTable t = new JTable(new DefaultTableModel(data, columns)); table.setRowHeight(64); return t; }
Example 59
Project: codjo-data-process-master File: ResultTableCellRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
TreatmentResult treatmentResult = (TreatmentResult) value;
JLabel jLabel = new JLabel();
jLabel.setOpaque(true);
jLabel.setBorder(noFocusBorder);
if (!isSelected) {
jLabel.setBackground(table.getBackground());
} else {
jLabel.setBackground(table.getSelectionBackground());
jLabel.setForeground(table.getSelectionForeground());
}
switch(column) {
case 0:
jLabel.setText(treatmentResult.getTitle());
break;
case 1:
jLabel.setHorizontalTextPosition(JLabel.CENTER);
jLabel.setText(treatmentResult.getStateLabel());
jLabel.setBackground(new Color(treatmentResult.getStateColor()));
break;
case 2:
jLabel.setText(treatmentResult.getMessage());
break;
default:
jLabel.setText("???");
break;
}
return jLabel;
}
Example 60
Project: com.opendoorlogistics-master File: JTableUtils.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
// prepare by calling the original render's method
booleanRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
// set enabled/disabled
boolean enabled = table.getModel().isCellEditable(row, column);
if (enabled != box.isEnabled()) {
box.setEnabled(enabled);
}
return box;
}
Example 61
Project: com.revolsys.open-master File: NumberTableCellRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(final JTable table, Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
if (value instanceof Number) {
final Number number = (Number) value;
value = getFormat().format(number);
}
final Component label = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
setHorizontalAlignment(SwingConstants.RIGHT);
return label;
}
Example 62
Project: dedupeer-master File: IconLabelRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
ImageIcon icon = null;
JLabel iconLabel = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (((StoredFileDataModel) table.getModel()).getStoredFileByRow(row) instanceof DFolder) {
if (//icon must appear only in the first column
column == 0) {
icon = (String) value != null ? FileUtils.getFolderIcon() : null;
}
} else {
icon = FileUtils.getIconByFileType((String) value);
}
iconLabel.setIcon(icon);
if (isSelected) {
iconLabel.setBackground(table.getSelectionBackground());
iconLabel.setForeground(table.getSelectionForeground());
} else {
iconLabel.setBackground(table.getBackground());
iconLabel.setForeground(table.getForeground());
}
return iconLabel;
}
Example 63
Project: DL-Learner-Protege-Plugin-master File: ProgressBarTableCellRenderer.java View source code |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
int n = 0;
if (!(value instanceof Number)) {
String str;
if (value instanceof String) {
str = (String) value;
} else {
str = value.toString();
}
try {
n = Integer.valueOf(str).intValue();
} catch (NumberFormatException ex) {
}
} else {
n = ((Number) value).intValue();
}
setValue(n);
return this;
}
Example 64
Project: dyevc-master File: StringRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
MonitoredRepository repository = (MonitoredRepository) table.getValueAt(row, 0);
String tooltip = TooltipRenderer.renderTooltipFor(repository);
String stringValue = (String) value;
switch(column) {
case 1:
if (stringValue.equals("") || stringValue.equals("no name")) {
setValue("Not specified");
setForeground(Color.RED);
} else {
setForeground(UIManager.getColor("Label.foreground"));
}
break;
default:
setForeground(UIManager.getColor("Label.foreground"));
}
setToolTipText(tooltip);
ToolTipManager.sharedInstance().setDismissDelay(15000);
return this;
}
Example 65
Project: geogebra-master File: CASTableCellRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Font casFont = view.getCASViewComponent().getFont();
if (value instanceof GeoCasCell) {
GeoCasCell cell = (GeoCasCell) value;
// set CASTableCell value
setValue(cell);
// update font and row height
if (cell.isUseAsText()) {
setFont(casFont.deriveFont(cell.getFontStyle(), (float) (casFont.getSize() * (cell.getFontSizeMultiplier()))));
setForeground(GColorD.getAwtColor(cell.getFontColor()));
dummyField.setForeground(GColorD.getAwtColor(cell.getFontColor()));
this.getInputArea().setForeground(GColorD.getAwtColor(cell.getFontColor()));
} else {
setFont(casFont);
}
updateTableRowHeight(table, row);
// set inputPanel width to match table column width
// -1 = set to table column width (even if larger than viewport)
setInputPanelWidth(-1);
}
return this;
}
Example 66
Project: geonetworking-master File: PingStatusRenderer.java View source code |
public Component getTableCellRendererComponent(JTable table, Object pingStatus, boolean isSelected, boolean hasFocus, int row, int column) {
final Color newColor;
if (pingStatus == null || !(pingStatus instanceof PingStatus))
newColor = Color.ORANGE;
else
switch((PingStatus) pingStatus) {
case UNKNOWN:
newColor = Color.ORANGE;
break;
case READY:
newColor = Color.GREEN;
break;
case NOT_READY:
newColor = Color.RED;
break;
default:
newColor = Color.ORANGE;
break;
}
setBackground(newColor);
if (this.isBordered) {
if (isSelected) {
if (this.selectedBorder == null) {
this.selectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5, table.getSelectionBackground());
}
setBorder(this.selectedBorder);
} else {
if (this.unselectedBorder == null) {
this.unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5, table.getBackground());
}
setBorder(this.unselectedBorder);
}
}
return this;
}
Example 67
Project: HUSACCT-master File: ColorRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object color, boolean isSelected, boolean hasFocus, int row, int column) {
Color newColor = (Color) color;
setBackground(newColor);
if (isBordered) {
if (isSelected) {
if (selectedBorder == null) {
selectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5, table.getSelectionBackground());
}
setBorder(selectedBorder);
} else {
if (unselectedBorder == null) {
unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5, table.getBackground());
}
setBorder(unselectedBorder);
}
}
setToolTipText("RGB value: " + newColor.getRed() + ", " + newColor.getGreen() + ", " + newColor.getBlue());
return this;
}
Example 68
Project: ieo-beast-master File: ColumnResizer.java View source code |
public static void adjustColumnPreferredWidths(JTable table) {
TableColumnModel columnModel = table.getColumnModel();
for (int col = 0; col < table.getColumnCount(); col++) {
int maxwidth = 0;
for (int row = 0; row < table.getRowCount(); row++) {
TableCellRenderer rend = table.getCellRenderer(row, col);
Object value = table.getValueAt(row, col);
Component comp = rend.getTableCellRendererComponent(table, value, false, false, row, col);
maxwidth = Math.max(comp.getPreferredSize().width, maxwidth);
}
// END: row loop
TableColumn column = columnModel.getColumn(col);
TableCellRenderer headerRenderer = column.getHeaderRenderer();
if (headerRenderer == null) {
headerRenderer = table.getTableHeader().getDefaultRenderer();
}
Object headerValue = column.getHeaderValue();
Component headerComp = headerRenderer.getTableCellRendererComponent(table, headerValue, false, false, 0, col);
maxwidth = Math.max(maxwidth, headerComp.getPreferredSize().width);
column.setPreferredWidth(maxwidth);
}
// END: col loop
}
Example 69
Project: ismp_manager-master File: TableUtil.java View source code |
public static final JTable getTable() { return new JTable() { public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component prepareRenderer = super.prepareRenderer(renderer, row, column); if (this.getSelectedRow() == row) { prepareRenderer.setBackground(new Color(200, 220, 180)); } else { if (row % 2 == 0) { prepareRenderer.setBackground(Color.WHITE); } else { prepareRenderer.setBackground(new Color(120, 180, 230, 128)); } } return prepareRenderer; } public boolean isCellEditable(int row, int col) { return false; } }; }
Example 70
Project: jabref-master File: MainTableHeaderRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
// delegate to previously used TableCellRenderer which styles the component
Component resultFromDelegate = delegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
// Changing style is only possible if both value and resultFromDelegate are JLabels
if ((value instanceof JLabel) && (resultFromDelegate instanceof JLabel)) {
String text = ((JLabel) value).getText();
Icon icon = ((JLabel) value).getIcon();
if (icon == null) {
((JLabel) resultFromDelegate).setText(text);
resultFromDelegate.setFont(GUIGlobals.currentFont);
} else {
((JLabel) resultFromDelegate).setIcon(icon);
((JLabel) resultFromDelegate).setText(null);
}
}
return resultFromDelegate;
}
Example 71
Project: jade_agents-master File: StorageAgentGUI.java View source code |
/** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents void initComponents() { jScrollPane2 = new javax.swing.JScrollPane(); jTableStorage = new javax.swing.JTable(); jScrollPane1 = new javax.swing.JScrollPane(); jTableQueue = new javax.swing.JTable(); jScrollPane3 = new javax.swing.JScrollPane(); jListLog = new javax.swing.JList(); setTitle("Storeage Overview"); jTableStorage.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {}, new String[] { "Item", "In Storage" }) { Class[] types = new Class[] { java.lang.String.class, java.lang.Integer.class }; boolean[] canEdit = new boolean[] { false, false }; public Class getColumnClass(int columnIndex) { return types[columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; } }); jScrollPane2.setViewportView(jTableStorage); jTableQueue.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {}, new String[] { "Item", "Requested" }) { Class[] types = new Class[] { java.lang.String.class, java.lang.Integer.class }; boolean[] canEdit = new boolean[] { false, false }; public Class getColumnClass(int columnIndex) { return types[columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; } }); jScrollPane1.setViewportView(jTableQueue); jListLog.setModel(log); jListLog.setDoubleBuffered(true); jScrollPane3.setViewportView(jListLog); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 630, Short.MAX_VALUE).addGroup(layout.createSequentialGroup().addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 321, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 303, Short.MAX_VALUE))).addContainerGap())); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap().addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 226, Short.MAX_VALUE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)).addContainerGap())); pack(); }
Example 72
Project: jdal-master File: BooleanRenderer.java View source code |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (isSelected) {
setForeground(table.getSelectionForeground());
super.setBackground(table.getSelectionBackground());
} else {
setForeground(table.getForeground());
setBackground(table.getBackground());
}
setSelected((value != null && ((Boolean) value).booleanValue()));
if (hasFocus) {
setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
} else {
setBorder(noFocusBorder);
}
return this;
}
Example 73
Project: josm-master File: SelectionTableCellRendererTest.java View source code |
/**
* Unit test of {@link SelectionTableCellRenderer#SelectionTableCellRenderer}.
*/
@Test
public void testSelectionTableCellRenderer() {
MemberTableModel model = new MemberTableModel(null, null, null);
SelectionTableCellRenderer r = new SelectionTableCellRenderer(model);
assertEquals(r, r.getTableCellRendererComponent(null, null, false, false, 0, 0));
assertEquals(r, r.getTableCellRendererComponent(new JTable(model), new Node(), false, false, 0, 0));
}
Example 74
Project: josm-older-master File: TagMergeTableCellRenderer.java View source code |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
reset();
TagMergeItem item = (TagMergeItem) value;
switch(col) {
case 0:
renderKey(item, isSelected);
break;
case 1:
renderValue(item, isSelected);
break;
default:
// should not happen, but just in case
throw new IllegalArgumentException(MessageFormat.format("Parameter 'col' must be 0 or 1. Got {0}.", col));
}
return this;
}
Example 75
Project: jsystem-master File: AnotherBeanCellEditorModel.java View source code |
@Override
public String[] getOptions(JTable table, int row, int column) {
String columnName = table.getColumnName(column);
if (columnName.equals("SelectedItem")) {
String val = "" + table.getValueAt(row, 0);
if (val.equals("val1")) {
return new String[] { "xxx", "yyy", "zzz", "ggg" };
} else {
return new String[] { "1111", "2222", "3333", "4444" };
}
} else {
return super.getOptions(table, row, column);
}
}
Example 76
Project: kevoree-master File: ITunesTableUI.java View source code |
@Override
public void installUI(JComponent c) {
super.installUI(c);
table.remove(rendererPane);
rendererPane = createCustomCellRendererPane();
table.add(rendererPane);
// TODO save defaults.
table.setOpaque(false);
table.setFont(MacFontUtils.ITUNES_FONT);
table.setGridColor(TABLE_GRID_COLOR);
table.setIntercellSpacing(new Dimension(0, 0));
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.getTableHeader().setDefaultRenderer(new ITunesTableHeaderRenderer(table));
table.setShowHorizontalLines(false);
TableHeaderUtils.makeHeaderFillEmptySpace(table);
TableUtils.makeStriped(table, EVEN_ROW_COLOR);
table.setDefaultRenderer(Rating.class, new ITunesRatingTableCellRenderer());
table.setDefaultEditor(Object.class, createDefaultTableCellEditor());
makeTableActive();
WindowUtils.installWeakWindowFocusListener(table, createWindowFocusListener());
}
Example 77
Project: korsakow-editor-master File: ResourceTreeTableCellEditor.java View source code |
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int r, int c) {
editingNode = treeTable.getNodeAt(r);
if (editingNode != null)
value = editingNode.getName();
if (value == null)
value = "";
// TreeTableCellEditor tries to compensate if root isn't visible. however its trick seems to simply not work
int TreeTableCellEditorFixedRow = getTreeTable().getTree().isRootVisible() ? r : r + 1;
final JTextField textField = (JTextField) super.getTableCellEditorComponent(table, value, isSelected, TreeTableCellEditorFixedRow, c);
textField.setBorder(null);
UIUtil.runUITaskLater(new Runnable() {
public void run() {
textField.setSelectionStart(0);
textField.setSelectionEnd(textField.getText().length());
textField.requestFocus();
}
});
return textField;
}
Example 78
Project: l2fprod-common-master File: NumberRenderer.java View source code |
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JTable.DropLocation dl = table.getDropLocation(); if (dl != null && !dl.isInsertRow() && !dl.isInsertColumn() && dl.getRow() == row && dl.getColumn() == column) { isSelected = true; } setFont(UIManager.getFont("Table.font")); setBorder(EMPTY_BORDER); setValue(value); if (isSelected) { setBackground(table.getSelectionBackground()); setForeground(table.getSelectionForeground()); } else { setBackground(table.getBackground()); setForeground(table.getForeground()); } return this; }
Example 79
Project: limewire5-ruby-master File: IsPlayingRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
setText("");
setBorder(emptyBorder);
if (value instanceof LocalFileItem) {
if (playerMediator.get().isPlaying(((LocalFileItem) value).getFile()) || playerMediator.get().isPaused(((LocalFileItem) value).getFile()))
setIcon(playingIcon);
else
setIcon(null);
} else {
setIcon(null);
}
return this;
}
Example 80
Project: magarena-master File: StartTimeCellRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int col) {
final LocalDateTime gameStart = getLocalTimeFromEpoch(Long.parseLong((String) value));
final JLabel lbl = new JLabel(gameStart.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM)));
lbl.setOpaque(true);
if (isSelected) {
lbl.setForeground(table.getSelectionForeground());
lbl.setBackground(table.getSelectionBackground());
} else {
lbl.setForeground(table.getForeground());
lbl.setBackground(table.getBackground());
}
// lbl.setBorder(noFocusBorder);
return lbl;
}
Example 81
Project: navtableforms-master File: VectorialUpdateJTableContextualMenu.java View source code |
@Override
public void mouseClicked(MouseEvent e) {
table = (JTable) e.getComponent();
if ((e.getClickCount() == 2) && (table.getSelectedRow() > -1)) {
openDialog();
} else if (e.getButton() == BUTTON_RIGHT) {
if (!JTableUtils.hasRows(table) || (table.getSelectedRow() == NO_ROW_SELECTED)) {
updateMenuItem.setEnabled(false);
} else {
updateMenuItem.setEnabled(true);
}
popupMenu.show(e.getComponent(), e.getX(), e.getY());
}
}
Example 82
Project: NearInfinity-master File: ToolTipTableCellRenderer.java View source code |
// --------------------- Begin Interface TableCellRenderer ---------------------
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (table.getColumnModel().getColumn(column).getWidth() < getFontMetrics(getFont()).stringWidth(getText())) {
StringBuffer sb = new StringBuffer("<html>");
String string = getText();
int index = 0;
while (index < string.length()) {
if (index > 0)
sb.append("<br>");
int delta = string.indexOf((int) ' ', index + 100);
if (delta == -1)
delta = string.length();
sb.append(string.substring(index, Math.min(delta, string.length())));
index = delta;
}
sb.append("</html>");
setToolTipText(sb.toString());
} else
setToolTipText(null);
return this;
}
Example 83
Project: opg-master File: CustomColorChooser.java View source code |
@Override
public void stateChanged(ChangeEvent arg0) {
sel.setColor(chooser.getColor());
JTable cTable = null;
if (gui.getColorTabbedPane().getSelectedIndex() == 1)
cTable = gui.getDescColorTable();
if (gui.getColorTabbedPane().getSelectedIndex() == 0)
cTable = gui.getAncesColorTable();
int r = cTable.getSelectedRow();
int[] rows = (r < 0 ? new int[] { 0 } : cTable.getSelectedRows());
for (int row : rows) {
cTable.setValueAt(gui.customSwatchArray.getSelected().getColor(), row, 1);
}
sel.repaint();
}
Example 84
Project: OWASP-WebScarab-master File: EnabledBooleanTableCellRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (value == null)
return table.getDefaultRenderer(Object.class).getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
setEnabled(table.isCellEditable(row, column));
if (isSelected) {
setForeground(table.getSelectionForeground());
super.setBackground(table.getSelectionBackground());
} else {
setForeground(table.getForeground());
setBackground(table.getBackground());
}
setSelected((value != null && ((Boolean) value).booleanValue()));
if (hasFocus) {
setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
} else {
setBorder(noFocusBorder);
}
return this;
}
Example 85
Project: PembayaranSpp-master File: TableAutoColumnWidth.java View source code |
private void autoColumn(JTable t) {
//cara untuk menyesuaikan kolom dari tabel adalah mengambil
// lebar kolom yang ada kemudian sesuaikan
TableColumnModel tableColumnModel = t.getColumnModel();
for (int column = 0; column < tableColumnModel.getColumnCount(); column++) {
int columnWidthMax = 0;
for (int row = 0; row < t.getRowCount(); row++) {
TableCellRenderer tableCellRenderer = t.getCellRenderer(row, column);
Object tableValue = t.getValueAt(row, column);
Component component = tableCellRenderer.getTableCellRendererComponent(t, tableValue, false, false, row, column);
columnWidthMax = Math.max(component.getPreferredSize().width + 5, columnWidthMax);
}
//akhir for baris
TableColumn tableColumn = tableColumnModel.getColumn(column);
tableColumn.setPreferredWidth(columnWidthMax + 5);
}
//akhir for kolom
}
Example 86
Project: Phenex-master File: PlaceholderRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if ((value == null) || (value.equals(""))) {
final Component component = super.getTableCellRendererComponent(table, this.placeholder, isSelected, hasFocus, row, column);
component.setForeground(Color.GRAY);
return component;
} else {
final Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (isSelected) {
component.setForeground(UIManager.getColor("Table.selectionForeground"));
} else {
component.setForeground(UIManager.getColor("Table.foreground"));
}
return component;
}
}
Example 87
Project: RipplePower-master File: RowColorTableCellRenderer.java View source code |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
boolean flag = false;
if (table instanceof RowColorModel) {
RowColorModel model = (RowColorModel) table;
setBackground(model.getBackground(row, isSelected, table));
setForeground(model.getForeground(row, isSelected, table));
if (value instanceof String) {
String address = (String) value;
if (AccountFind.isRippleAddress(address)) {
setFont(font);
} else {
setFont(defFont);
}
flag = true;
}
}
if (!flag) {
if (value instanceof Icon) {
setIcon((Icon) value);
} else {
setIcon(null);
}
}
setText(value == null ? "" : value.toString());
return this;
}
Example 88
Project: Scarab-master File: EnabledBooleanTableCellRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (value == null)
return table.getDefaultRenderer(Object.class).getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
setEnabled(table.isCellEditable(row, column));
if (isSelected) {
setForeground(table.getSelectionForeground());
super.setBackground(table.getSelectionBackground());
} else {
setForeground(table.getForeground());
setBackground(table.getBackground());
}
setSelected((value != null && ((Boolean) value).booleanValue()));
if (hasFocus) {
setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
} else {
setBorder(noFocusBorder);
}
return this;
}
Example 89
Project: schach-master File: MyCellRenderer.java View source code |
/**
* Methode, die die Eigenschaften der Tabellenzellen setzt.
*/
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JLabel c = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
// Tabelleneigenschaften
c.setFont(new Font("Arial", Font.BOLD, 15));
c.setForeground(new Color(43, 23, 2));
c.setVerticalAlignment(JLabel.CENTER);
// anders ausgerichtet, als wenn es sich um die linke Tabelle handelt
if (this.bottom) {
c.setHorizontalAlignment(JLabel.CENTER);
} else {
c.setHorizontalAlignment(JLabel.RIGHT);
}
return c;
}
Example 90
Project: statalign-master File: ColorRenderer.java View source code |
public Component getTableCellRendererComponent(JTable table, Object color, boolean isSelected, boolean hasFocus, int row, int column) {
Color newColor = (Color) color;
setBackground(newColor);
if (isBordered) {
if (isSelected) {
if (selectedBorder == null) {
selectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5, table.getSelectionBackground());
}
setBorder(selectedBorder);
} else {
if (unselectedBorder == null) {
unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5, table.getBackground());
}
setBorder(unselectedBorder);
}
}
setToolTipText("RGB value: " + newColor.getRed() + ", " + newColor.getGreen() + ", " + newColor.getBlue());
return this;
}
Example 91
Project: Towel-master File: TableFilterTest.java View source code |
public static void main(String[] args) { ObjectTableModel<Person> model = new ObjectTableModel<Person>(new AnnotationResolver(Person.class), "name,age,live"); model.setEditableDefault(true); JTable table = new JTable(model); new TableFilter(table); model.addAll(PreData.getSampleList()); // JTableView view = new JTableView(model); // view.getFooterModel().setFunction(0, new FuncConcat("-")); // view.getFooterModel().setFunction(1, new FuncSum()); JScrollPane pane = new JScrollPane(); pane.setViewportView(table); JFrame frame = new JFrame(); frame.getContentPane().add(pane); frame.pack(); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
Example 92
Project: vcd-nclient-master File: NotificationsTableCellRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
NotificationsTableModel model = (NotificationsTableModel) table.getModel();
row = table.convertRowIndexToModel(row);
if (model.isBlockingTask(row)) {
comp.setBackground(Color.lightGray);
} else {
if (isSelected) {
comp.setBackground(table.getSelectionBackground());
} else {
comp.setBackground(table.getBackground());
}
}
return comp;
}
Example 93
Project: VUE-master File: IconRenderer.java View source code |
public java.awt.Component getTableCellRendererComponent(javax.swing.JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value instanceof javax.swing.ImageIcon) {
setOpaque(true);
setIcon((javax.swing.ImageIcon) value);
setText("");
} else {
setIcon(null);
}
return this;
}
Example 94
Project: webos-theme-builder-master File: LeftEllipsisRenderer.java View source code |
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
//Determine the width available to render the text
int availableWidth = table.getColumnModel().getColumn(column).getWidth() - 10;
availableWidth -= table.getIntercellSpacing().getWidth();
Insets borderInsets = getBorder().getBorderInsets((Component) this);
availableWidth -= (borderInsets.left + borderInsets.right);
String cellText = getText();
FontMetrics fm = getFontMetrics(getFont());
if (fm.stringWidth(cellText) > availableWidth) {
String dots = "...";
int textWidth = fm.stringWidth(dots);
int i = cellText.length() - 1;
for (; i > 0; i--) {
textWidth += fm.charWidth(cellText.charAt(i));
if (textWidth > availableWidth) {
break;
}
}
setText(dots + cellText.substring(i + 1));
}
return this;
}
Example 95
Project: aidGer-master File: DateTableRenderer.java View source code |
/* * (non-Javadoc) * * @see * javax.swing.table.DefaultTableCellRenderer#getTableCellRendererComponent * (javax.swing.JTable, java.lang.Object, boolean, boolean, int, int) */ @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { String text = ""; if (value != null && Date.class.isInstance(value)) { Calendar cal = Calendar.getInstance(); cal.clear(); // it could be that no date shall be shown if (!value.equals(cal.getTime())) { text = format.format((Date) value); } } return super.getTableCellRendererComponent(table, text, isSelected, hasFocus, row, column); }
Example 96
Project: ChromisPOS-master File: AboutDialog.java View source code |
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
void initComponents() {
jScrollPane2 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jLabel3 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jTable1.setModel(new javax.swing.table.DefaultTableModel(new Object[][] { { null, null, null, null }, { null, null, null, null }, { null, null, null, null }, { null, null, null, null } }, new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
jScrollPane2.setViewportView(jTable1);
// NOI18N
jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/chromis/images/chromis_main.png")));
// NOI18N
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12));
jLabel2.setText("www.chromis.co.uk");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jLabel3)).addGroup(layout.createSequentialGroup().addGap(30, 30, 30).addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE))).addContainerGap(33, Short.MAX_VALUE)));
layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(1, 1, 1).addComponent(jLabel2).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
}
Example 97
Project: felix-master File: ResultCellRenderer.java View source code |
/** * Renderer method. * @param table the table * @param value the value * @param isSelected is the cell selected * @param hasFocus has the cell the focus * @param row the cell row * @param column the cell column * @return the resulting component * @see javax.swing.table.DefaultTableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int) */ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); ResultTableModel results = (ResultTableModel) table.getModel(); String status = (String) results.getValueAt(row, column); if (status.equals(ResultTableModel.SUCCESS)) { c.setForeground(Color.GREEN); setToolTipText(results.getMessage(row, column)); } if (status.equals(ResultTableModel.FAILURE)) { c.setForeground(Color.ORANGE); setToolTipText(results.getMessage(row, column)); } if (status.equals(ResultTableModel.ERROR)) { c.setForeground(Color.RED); setToolTipText(results.getMessage(row, column)); } return c; }
Example 98
Project: GhostGrader-master File: GradebooksWindow.java View source code |
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
classTable = new javax.swing.JTable();
// NOI18N
jScrollPane1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Courses", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Georgia", 0, 14)));
classTable.setModel(new javax.swing.table.DefaultTableModel(new Object[][] { { null, null, null, null, null, null, null, null, null } }, new String[] { "Row", "Class Name", "Course Prefix", "Course Number", "Class Section", "Class Building", "Class Room Number", "Meeting Time", "Semester" }) {
boolean[] canEdit = new boolean[] { false, false, false, false, false, true, true, true, true };
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit[columnIndex];
}
});
jScrollPane1.setViewportView(classTable);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 787, Short.MAX_VALUE));
layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 521, Short.MAX_VALUE));
}
Example 99
Project: jdk7u-jdk-master File: NonPublicInterface.java View source code |
public static void main(String[] args) throws Exception { Class nonPublic = null; String[] nonPublicInterfaces = new String[] { "java.awt.Conditional", "java.util.zip.ZipConstants", "javax.swing.GraphicsWrapper", "javax.swing.JPopupMenu$Popup", "javax.swing.JTable$Resizable2", "javax.swing.JTable$Resizable3", "javax.swing.ToolTipManager$Popup", "sun.audio.Format", "sun.audio.HaePlayable", "sun.tools.agent.StepConstants" }; for (int i = 0; i < nonPublicInterfaces.length; i++) { try { nonPublic = Class.forName(nonPublicInterfaces[i]); break; } catch (ClassNotFoundException ex) { } } if (nonPublic == null) { throw new Error("couldn't find system non-public interface"); } ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream oout = new ObjectOutputStream(bout); oout.writeObject(Proxy.newProxyInstance(nonPublic.getClassLoader(), new Class[] { nonPublic }, new Handler())); oout.close(); ObjectInputStream oin = new ObjectInputStream(new ByteArrayInputStream(bout.toByteArray())); oin.readObject(); }
Example 100
Project: ManagedRuntimeInitiative-master File: NonPublicInterface.java View source code |
public static void main(String[] args) throws Exception { Class nonPublic = null; String[] nonPublicInterfaces = new String[] { "java.awt.Conditional", "java.util.zip.ZipConstants", "javax.swing.GraphicsWrapper", "javax.swing.JPopupMenu$Popup", "javax.swing.JTable$Resizable2", "javax.swing.JTable$Resizable3", "javax.swing.ToolTipManager$Popup", "sun.audio.Format", "sun.audio.HaePlayable", "sun.tools.agent.StepConstants" }; for (int i = 0; i < nonPublicInterfaces.length; i++) { try { nonPublic = Class.forName(nonPublicInterfaces[i]); break; } catch (ClassNotFoundException ex) { } } if (nonPublic == null) { throw new Error("couldn't find system non-public interface"); } ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream oout = new ObjectOutputStream(bout); oout.writeObject(Proxy.newProxyInstance(nonPublic.getClassLoader(), new Class[] { nonPublic }, new Handler())); oout.close(); ObjectInputStream oin = new ObjectInputStream(new ByteArrayInputStream(bout.toByteArray())); oin.readObject(); }
Example 101
Project: openjdk-master File: JTableInGlassPaneOverlapping.java View source code |
@Override protected JComponent getSwingComponent() { // Create columns names String columnNames[] = { "Column 1", "Column 2", "Column 3" }; // Create some data String dataValues[][] = { { "12", "234", "67" }, { "-123", "43", "853" }, { "93", "89.2", "109" }, { "279", "9033", "3092" }, { "12", "234", "67" }, { "-123", "43", "853" }, { "93", "89.2", "109" }, { "279", "9033", "3092" }, { "12", "234", "67" }, { "-123", "43", "853" }, { "93", "89.2", "109" }, { "279", "9033", "3092" }, { "12", "234", "67" }, { "-123", "43", "853" }, { "93", "89.2", "109" }, { "279", "9033", "3092" } }; // Create a new table instance JTable jt = new JTable(dataValues, columnNames); jt.getModel().addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent e) { System.err.println("table changed"); } }); return jt; }