use of javax.swing.table.DefaultTableCellRenderer in project specify by rhebecaabreu.
the class MeusProjetos method criaTableShowD.
public void criaTableShowD(JPanel panel) {
table = new JTable();
table.setCellSelectionEnabled(true);
table.setGridColor(SystemColor.controlHighlight);
// table_3.setBounds(3, 24, 540, 0);
table.setFont(new Font("Lucida Sans Unicode", Font.PLAIN, 13));
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
// table_3.setTableHeader(null);
table.getTableHeader().setResizingAllowed(true);
table.getTableHeader().setReorderingAllowed(false);
JTableHeader header = table.getTableHeader();
DefaultTableCellRenderer centralizado = (DefaultTableCellRenderer) header.getDefaultRenderer();
centralizado.setHorizontalAlignment(SwingConstants.CENTER);
table.setModel(showr);
table.getColumnModel().getColumn(0).setPreferredWidth(536);
TableColumn col = table.getColumnModel().getColumn(0);
col.setCellRenderer(new TextAreaCellRenderer());
JTableHeader cabecalho = table.getTableHeader();
cabecalho.setFont(new Font("Leelawadee UI", Font.PLAIN, 12));
panel.add(table);
scrollPane3 = new JScrollPane(table);
scrollPane3.setBounds(4, 10, 559, 440);
// só mostra a barra vertical se necessário
scrollPane3.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
// só mostra a barra horizontal se necessário
scrollPane3.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
panel.add(scrollPane3);
}
use of javax.swing.table.DefaultTableCellRenderer in project specify by rhebecaabreu.
the class MeusProjetos method criaJTable.
public void criaJTable() {
table_1 = new JTable();
table_1.setShowVerticalLines(true);
table_1.setShowHorizontalLines(true);
table_1.setGridColor(SystemColor.scrollbar);
table_1.setSelectionBackground(SystemColor.textHighlight);
table_1.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
table_1.setBounds(3, 24, 540, 0);
table_1.setFont(new Font("Leelawadee UI", Font.PLAIN, 12));
table_1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table_1.getTableHeader().setResizingAllowed(true);
table_1.getTableHeader().setReorderingAllowed(false);
table_1.setBorder(new MatteBorder(1, 1, 1, 1, (Color) UIManager.getColor("Menu[Disabled].textForeground")));
table_1.setModel(tableModel);
table_1.getColumnModel().getColumn(0).setPreferredWidth(18);
table_1.getColumnModel().getColumn(1).setPreferredWidth(50);
table_1.getColumnModel().getColumn(2).setPreferredWidth(169);
table_1.getColumnModel().getColumn(3).setPreferredWidth(110);
table_1.getColumnModel().getColumn(4).setPreferredWidth(140);
table_1.getColumnModel().getColumn(5).setPreferredWidth(185);
JTableHeader cabecalho = table_1.getTableHeader();
cabecalho.setFont(new Font("Leelawadee UI", Font.PLAIN, 12));
DefaultTableCellRenderer esquerda = new DefaultTableCellRenderer();
DefaultTableCellRenderer centro = new DefaultTableCellRenderer();
DefaultTableCellRenderer direita = new DefaultTableCellRenderer();
esquerda.setHorizontalAlignment(SwingConstants.LEFT);
centro.setHorizontalAlignment(SwingConstants.CENTER);
direita.setHorizontalAlignment(SwingConstants.RIGHT);
table_1.getColumnModel().getColumn(3).setCellRenderer(centro);
table_1.getColumnModel().getColumn(4).setCellRenderer(centro);
table_1.getColumnModel().getColumn(0).setCellRenderer(centro);
table_1.getColumnModel().getColumn(1).setCellRenderer(centro);
AbtToolTipHeader tooltipHeader = new AbtToolTipHeader(table_1.getColumnModel());
// Seta a table header de tooltips
table_1.setTableHeader(tooltipHeader);
tooltipHeader.addToolTipToColumn(// Coluna 0
1, "Código do requisito");
tooltipHeader.addToolTipToColumn(// Coluna 0
2, "Identificador do requisito");
tooltipHeader.addToolTipToColumn(// Coluna 0
3, "Tipo de requisito");
tooltipHeader.addToolTipToColumn(// Coluna 0
4, "Data da criação/inclusão do requisito no sistema");
tooltipHeader.addToolTipToColumn(// Coluna 0
5, "Última modificação/alteração realizada no requisito");
TableColumn tc = table_1.getColumnModel().getColumn(0);
tc.setCellEditor(table_1.getDefaultEditor(Boolean.class));
tc.setCellRenderer(table_1.getDefaultRenderer(Boolean.class));
table_1.setRowHeight(20);
tc.setHeaderRenderer(new PhDCheckHeader(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
// ações quando clicar no check
Object source = e.getSource();
if (source instanceof AbstractButton == false) {
return;
}
boolean check = e.getStateChange() == ItemEvent.SELECTED;
int coluna = 0;
if (check == true) {
for (int i = 0; i < table_1.getRowCount(); i++) {
table_1.setValueAt(new Boolean(check), i, coluna);
table_1.addRowSelectionInterval(i, i);
}
} else {
for (int i = 0; i < table_1.getRowCount(); i++) {
table_1.setValueAt(new Boolean(check), i, coluna);
table_1.removeRowSelectionInterval(i, i);
}
}
}
}));
((DefaultTableCellRenderer) table_1.getTableHeader().getDefaultRenderer()).setHorizontalAlignment(SwingConstants.CENTER);
panelRequisitos.setLayout(null);
panelRequisitos.add(table_1);
scrollPane2 = new JScrollPane(table_1);
scrollPane2.setBounds(4, 29, 570, 498);
// só mostra a barra vertical se necessário
scrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
// só mostra a barra horizontal se necessário
scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
panelRequisitos.add(scrollPane2);
}
use of javax.swing.table.DefaultTableCellRenderer in project 2XB3 by SurayaAtouraya.
the class MainMenu method initialize.
// Initialize the contents of the main frame.
private void initialize() throws IOException {
frame.addWindowListener(CloseWindow);
frame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
newFrame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
JButton find = new JButton("Find Contractor");
JButton end = new JButton("Exit Program");
end.addActionListener(CloseFrame);
find.addActionListener(FindButton);
pane.add(find);
pane.add(end);
model.addColumn("Contractor Name");
model.addColumn("License Number");
model.addColumn("State");
model.addColumn("City");
model.addColumn("Address");
model.addColumn("Phone Number");
model.addColumn("Speciality");
model.addColumn("Rating");
DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
centerRenderer.setHorizontalAlignment(JLabel.CENTER);
for (int i = 0; i <= 7; i++) {
contractorTable.getColumnModel().getColumn(i).setCellRenderer(centerRenderer);
}
contractorTable.getColumnModel().getColumn(0).setPreferredWidth(150);
contractorTable.getColumnModel().getColumn(1).setPreferredWidth(75);
contractorTable.getColumnModel().getColumn(2).setPreferredWidth(0);
contractorTable.getColumnModel().getColumn(3).setPreferredWidth(100);
contractorTable.getColumnModel().getColumn(4).setPreferredWidth(150);
contractorTable.getColumnModel().getColumn(5).setPreferredWidth(100);
contractorTable.getColumnModel().getColumn(6).setPreferredWidth(200);
contractorTable.getColumnModel().getColumn(7).setPreferredWidth(0);
contractorTable.getTableHeader().setReorderingAllowed(false);
contractorTable.getTableHeader().setResizingAllowed(false);
contractorTable.isCellEditable(0, 0);
JScrollPane scrollPane = new JScrollPane(contractorTable);
scrollPane.setPreferredSize(new Dimension(1300, 650));
pane.add(scrollPane);
frame.add(pane);
frame.setVisible(true);
}
use of javax.swing.table.DefaultTableCellRenderer in project WorldPainter by Captain-Chaos.
the class SimpleThemeEditor method setTheme.
public void setTheme(SimpleTheme theme) {
this.theme = theme;
if (theme != null) {
terrainTableModel = new TerrainRangesTableModel(theme.getTerrainRanges());
terrainTableModel.setChangeListener(this);
tableTerrain.setModel(terrainTableModel);
tableTerrain.setDefaultRenderer(Integer.class, new DefaultTableCellRenderer());
tableTerrain.setDefaultRenderer(Terrain.class, new TerrainTableCellRenderer(colourScheme));
tableTerrain.setDefaultRenderer(JButton.class, new JButtonTableCellRenderer());
tableTerrain.setDefaultEditor(Integer.class, new JSpinnerTableCellEditor(new SpinnerNumberModel(1, 1, theme.getMaxHeight() - 1, 1)));
JComboBox terrainEditor = new JComboBox(Terrain.getConfiguredValues());
terrainEditor.setRenderer(new TerrainListCellRenderer(colourScheme));
tableTerrain.setDefaultEditor(Terrain.class, new DefaultCellEditor(terrainEditor));
tableTerrain.setDefaultEditor(JButton.class, new JButtonTableCellEditor(this));
checkBoxBeaches.setSelected(theme.isBeaches());
spinnerWaterLevel.setModel(new SpinnerNumberModel(theme.getWaterHeight(), 0, theme.getMaxHeight() - 1, 1));
spinnerWaterLevel.setEnabled(checkBoxBeaches.isSelected());
checkBoxRandomise.setSelected(theme.isRandomise());
layerTableModel = new LayerRangesTableModel(theme.getMaxHeight(), theme.getLayerMap());
tableLayers.setModel(layerTableModel);
tableLayers.setDefaultRenderer(Layer.class, new LayerTableCellRenderer());
tableLayers.setDefaultRenderer(JButton.class, new JButtonTableCellRenderer());
tableLayers.setDefaultEditor(Integer.class, new JSpinnerTableCellEditor(new SpinnerNumberModel(1, 1, theme.getMaxHeight() - 1, 1)));
tableLayers.setDefaultEditor(JButton.class, new JButtonTableCellEditor(this));
}
}
use of javax.swing.table.DefaultTableCellRenderer in project com.revolsys.open by revolsys.
the class BaseColumnFactory method calcHeaderWidth.
@Override
protected int calcHeaderWidth(final JXTable table, final TableColumnExt tableColumn) {
int width = super.calcHeaderWidth(table, tableColumn);
width += this.sortWidth;
final TableCellRenderer renderer = getHeaderRenderer(table, tableColumn);
if (renderer instanceof DefaultTableCellRenderer) {
final DefaultTableCellRenderer defaultTableCellRenderer = (DefaultTableCellRenderer) renderer;
final int position = defaultTableCellRenderer.getHorizontalTextPosition();
if (position > 0) {
width += position;
}
}
return width;
}
Aggregations