use of javax.swing.table.JTableHeader 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.JTableHeader 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.JTableHeader in project specify by rhebecaabreu.
the class PhDCheckHeader method mouseClicked.
public void mouseClicked(MouseEvent e) {
if (mousePressed) {
mousePressed = false;
JTableHeader header = (JTableHeader) (e.getSource());
JTable tableView = header.getTable();
TableColumnModel columnModel = tableView.getColumnModel();
int viewColumn = columnModel.getColumnIndexAtX(e.getX());
int coluna = tableView.convertColumnIndexToModel(viewColumn);
MeusProjetos a = new MeusProjetos();
a.limpalista();
if (viewColumn == getColumn() && e.getClickCount() == 1 && coluna != -1) {
doClick();
a.limpalista();
}
}
((JTableHeader) e.getSource()).repaint();
}
use of javax.swing.table.JTableHeader in project CCDD by nasa.
the class CcddJTableHandler method createDefaultTableHeader.
/**
********************************************************************************************
* Get the default table header object
********************************************************************************************
*/
@Override
protected JTableHeader createDefaultTableHeader() {
return new JTableHeader(columnModel) {
/**
************************************************************************************
* Provide the tool tip text for the column headers
************************************************************************************
*/
@Override
public String getToolTipText(MouseEvent me) {
String text = null;
// Get the index of the column underneath the mouse pointer
int column = columnModel.getColumn(columnModel.getColumnIndexAtX(me.getPoint().x)).getModelIndex();
// Check if tool tip exists
if (toolTips != null && column < toolTips.length && toolTips[column] != null && !toolTips[column].isEmpty()) {
// Get the tool tip for the column header
text = toolTips[column];
}
return text;
}
/**
************************************************************************************
* Override the header preferred size to add the vertical padding
************************************************************************************
*/
@Override
public Dimension getPreferredSize() {
// Get the header's preferred size and add the vertical padding
Dimension headerSize = super.getPreferredSize();
headerSize.height += ModifiableSpacingInfo.HEADER_VERTICAL_PADDING.getSpacing();
return headerSize;
}
@Override
public /**
************************************************************************************
* Override the column drag to end the edit sequence
************************************************************************************
*/
void setDraggedColumn(TableColumn column) {
// Set the flag indicating if the column move sequence is complete
boolean finished = getDraggedColumn() != null && column == null;
// Perform the column drag operation
super.setDraggedColumn(column);
// Check if the column drag operation is complete
if (finished) {
// End the edit sequence and flag that a change occurred
undoManager.endEditSequence();
undoManager.ownerHasChanged();
}
}
};
}
use of javax.swing.table.JTableHeader in project mafscaling by vimsh.
the class ClosedLoop method createAfrDataTable.
private JTable createAfrDataTable(JPanel panel, String tableName, int gridy) {
final JTable afrTable = new JTable() {
private static final long serialVersionUID = 6526901361175099297L;
public boolean isCellEditable(int row, int column) {
return false;
}
};
DefaultTableColumnModel afrModel = new DefaultTableColumnModel();
final TableColumn afrColumn = new TableColumn(0, 250);
afrColumn.setHeaderValue(tableName);
afrModel.addColumn(afrColumn);
JTableHeader lblAfrTableName = afrTable.getTableHeader();
lblAfrTableName.setColumnModel(afrModel);
lblAfrTableName.setReorderingAllowed(false);
DefaultTableCellRenderer headerRenderer = (DefaultTableCellRenderer) lblAfrTableName.getDefaultRenderer();
headerRenderer.setHorizontalAlignment(SwingConstants.LEFT);
GridBagConstraints gbc_lblAfrTableName = new GridBagConstraints();
gbc_lblAfrTableName.insets = new Insets((gridy == 0 ? 0 : 5), 0, 0, 0);
gbc_lblAfrTableName.anchor = GridBagConstraints.PAGE_START;
gbc_lblAfrTableName.fill = GridBagConstraints.HORIZONTAL;
gbc_lblAfrTableName.gridx = 0;
gbc_lblAfrTableName.gridy = gridy;
panel.add(lblAfrTableName, gbc_lblAfrTableName);
afrTable.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
afrColumn.setWidth(afrTable.getWidth());
}
});
afrTable.getTableHeader().setReorderingAllowed(false);
afrTable.setColumnSelectionAllowed(true);
afrTable.setCellSelectionEnabled(true);
afrTable.setBorder(new LineBorder(new Color(0, 0, 0)));
afrTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
afrTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
afrTable.setModel(new DefaultTableModel(AfrTableRowCount, AfrTableColumnCount));
Utils.initializeTable(afrTable, ColumnWidth);
if (tableName.equals(Afr1TableName)) {
Format[][] formatMatrix = { { new DecimalFormat("#"), new DecimalFormat("0.00") } };
NumberFormatRenderer renderer = (NumberFormatRenderer) afrTable.getDefaultRenderer(Object.class);
renderer.setFormats(formatMatrix);
} else if (tableName.equals(Afr2TableName)) {
Format[][] formatMatrix = { { new DecimalFormat("#"), new DecimalFormat("0.00") }, { new DecimalFormat("#"), new DecimalFormat("#") } };
NumberFormatRenderer renderer = (NumberFormatRenderer) afrTable.getDefaultRenderer(Object.class);
renderer.setFormats(formatMatrix);
}
GridBagConstraints gbc_afrTable = new GridBagConstraints();
gbc_afrTable.insets = new Insets(0, 0, 0, 0);
gbc_afrTable.anchor = GridBagConstraints.PAGE_START;
gbc_afrTable.gridx = 0;
gbc_afrTable.gridy = gridy + 1;
panel.add(afrTable, gbc_afrTable);
excelAdapter.addTable(afrTable, true, false);
return afrTable;
}
Aggregations