本文整理了Java中javax.swing.JTable.setBackground()
方法的一些代码示例,展示了JTable.setBackground()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTable.setBackground()
方法的具体详情如下:
包路径:javax.swing.JTable
类名称:JTable
方法名:setBackground
暂无
代码示例来源:origin: libgdx/libgdx
private void uiStyle () {
contentPane.setBackground(new Color(36, 36, 36));
topPanel.setBackground(new Color(36, 36, 36));
topPanel.setForeground(new Color(255, 255, 255));
table.setBackground(new Color(46, 46, 46));
table.setForeground(new Color(255, 255, 255));
bottomPanel.setBackground(new Color(36, 36, 36));
bottomPanel.setForeground(new Color(255, 255, 255));
buttonPanel.setBackground(new Color(36, 36, 36));
buttonPanel.setForeground(new Color(255, 255, 255));
scrollPane.setBorder(BorderFactory.createEmptyBorder());
scrollPane.setBackground(new Color(36, 36, 36));
scrollPane.getViewport().setBackground(new Color(36, 36, 36));
warningNotice.setForeground(new Color(255, 20, 20));
warningNotice2.setForeground(new Color(255, 20, 20));
}
代码示例来源:origin: pentaho/mondrian
relationTable.setBackground(new java.awt.Color(255, 204, 204));
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame();
frame.setSize(300,300);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTable table = new JTable(5, 5);
table.setBackground(Color.GRAY);
frame.setLayout(new FlowLayout());
frame.add(table);
代码示例来源:origin: stackoverflow.com
// Add Table
JTable table=new JTable(data,columns);
c.gridx=0;
c.gridy=1;
c.weightx=1;
c.weighty=1;
c.gridwidth=c.REMAINDER;
c.fill=GridBagConstraints.HORIZONTAL; // this line solves the problem
table.setBackground(Color.RED);
table.setMinimumSize(new Dimension(400,400));
cp.add(table, c);
代码示例来源:origin: stackoverflow.com
JFrame jframe = new JFrame();
jframe.setExtendedState(JFrame.MAXIMIZED_BOTH);
GridLayout layout = new GridLayout(); //chose your favorite
JTable jtable = new JTable();
jtable.setBackground(Color.yellow);
Container contentPane = jframe.getContentPane();
contentPane.setLayout(layout);
contentPane.add(jtable);
jframe.setVisible(true);
代码示例来源:origin: tulskiy/musique
public void setBackground(Color color) {
super.setBackground(color);
if (color != null) {
bgColor1 = color;
bgColor2 = darker(color);
}
}
代码示例来源:origin: stackoverflow.com
JFrame jframe = new JFrame();
jframe.setExtendedState(JFrame.MAXIMIZED_BOTH);
JTable jtable = new JTable();
jtable.setBackground(Color.yellow);
jframe.getContentPane().add(jtable);
jframe.setVisible(true);
代码示例来源:origin: stackoverflow.com
String[] colNames = {"Item", "Count"};
DefaultTableModel dtm = new DefaultTableModel(colNames, 0);
JPanel j = new JPanel(new BorderLayout());
JTable t = new JTable(dtm);
t.setBackground(Color.GREEN);
t.getTableHeader().setReorderingAllowed(false);
t.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
t.getColumnModel().getColumn(0).setPreferredWidth(113);
j.add(new JScrollPane(t), BorderLayout.CENTER);
代码示例来源:origin: org.apache.jmeter/ApacheJMeter_http
private void enableTable(boolean custEnabled, boolean sysEnabled, JTable table, PowerTableModel model,
JButton addButton, JButton deleteButton) {
table.setEnabled(custEnabled);
Color greyColor = new Color(240, 240, 240);
Color blueColor = new Color(184, 207, 229);
table.setBackground(sysEnabled ? greyColor : Color.WHITE);
table.setSelectionBackground(sysEnabled ? greyColor : blueColor);
addButton.setEnabled(custEnabled);
deleteButton.setEnabled(custEnabled);
if (custEnabled && (model.getRowCount() > 0)) {
deleteButton.setEnabled(true);
addButton.setEnabled(true);
}
}
代码示例来源:origin: stackoverflow.com
JTable table = new JTable(data, columns);
table.setModel(model);
table.setBackground(Color.LIGHT_GRAY);
table.setForeground(Color.black);
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
table.setFillsViewportHeight(true);
代码示例来源:origin: RPTools/maptool
public void initTransferTable() {
getTransferTable().setBackground(Color.white);
updateTransferTable();
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
/** Allows to subclasses initialize table
* @param t
*/
private void initializeTable() {
table.setModel(tableModel);
TableSheetCell tableCell = new TableSheetCell(tableModel);
table.setDefaultRenderer(Node.Property.class, tableCell);
table.setDefaultEditor(Node.Property.class, tableCell);
table.getTableHeader().setDefaultRenderer(tableCell);
table.setShowGrid(false);
table.setIntercellSpacing(new Dimension(0, 0));
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.getTableHeader().setReorderingAllowed(false);
if (UIManager.getColor("Panel.background") != null) { // NOI18N
table.setBackground(UIManager.getColor("Panel.background")); // NOI18N
table.setSelectionBackground(UIManager.getColor("Panel.background")); // NOI18N
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
/** Allows to subclasses initialize table
* @param t
*/
private void initializeTable() {
table.setModel(tableModel);
TableSheetCell tableCell = new TableSheetCell(tableModel);
table.setDefaultRenderer(Node.Property.class, tableCell);
table.setDefaultEditor(Node.Property.class, tableCell);
table.getTableHeader().setDefaultRenderer(tableCell);
table.setShowGrid(false);
table.setIntercellSpacing(new Dimension(0, 0));
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.getTableHeader().setReorderingAllowed(false);
if (UIManager.getColor("Panel.background") != null) { // NOI18N
table.setBackground(UIManager.getColor("Panel.background")); // NOI18N
table.setSelectionBackground(UIManager.getColor("Panel.background")); // NOI18N
}
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
/** Allows to subclasses initialize table
* @param t
*/
private void initializeTable() {
table.setModel(tableModel);
tableCell = new TableSheetCell(tableModel);
table.setDefaultRenderer(Node.Property.class, tableCell);
table.setDefaultEditor(Node.Property.class, tableCell);
table.getTableHeader().setDefaultRenderer(tableCell);
table.setShowGrid(false);
table.setIntercellSpacing(new Dimension(0, 0));
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.getTableHeader().setReorderingAllowed(false);
if (UIManager.getColor("Panel.background") != null) { // NOI18N
table.setBackground(UIManager.getColor("Panel.background")); // NOI18N
table.setSelectionBackground(UIManager.getColor("Panel.background")); // NOI18N
}
}
代码示例来源:origin: nl.cloudfarming.client/geometry-import
public ImportShapeSummaryPanel(){
this.setLayout(new MigLayout("wrap 1"));
JLabel summaryText = new JLabel(Bundle.ImportShapeSummaryPanel_summary_text());
this.add(summaryText);
tableModel = new DefaultTableModel();
importedtable = new JTable(tableModel);
importedtable.setBorder(new EmptyBorder(0,0,0,0));
importedtable.setBackground(Color.white);
JScrollPane importedTableScrolPane = new JScrollPane(importedtable);
importedTableScrolPane.setBackground(Color.white);
importedTableScrolPane.setBorder(new EmptyBorder(0, 0, 0, 0));
importedTableScrolPane.getViewport().setBackground(Color.white);
this.add(importedTableScrolPane);
}
代码示例来源:origin: org.apache.jmeter/ApacheJMeter_core
/**
* Create the main GUI panel which contains the argument table.
*
* @return the main GUI panel
*/
private Component makeMainPanel() {
initializeTableModel();
table = new JTable(tableModel);
table.getTableHeader().setDefaultRenderer(new HeaderAsPropertyRenderer());
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
if (this.background != null) {
table.setBackground(this.background);
}
JMeterUtils.applyHiDPI(table);
return makeScrollPane(table);
}
代码示例来源:origin: atarw/material-ui-swing
@Override
public void installUI (JComponent c) {
super.installUI (c);
JTable table = (JTable) c;
table.setOpaque (false);
table.setSelectionForeground (UIManager.getColor ("Table.selectionForeground"));
table.setBackground (UIManager.getColor ("Table.background"));
table.setFont (UIManager.getFont ("Table.font"));
table.setBorder (UIManager.getBorder ("Table.border"));
table.setGridColor (UIManager.getColor ("Table.gridColor"));
table.setSelectionBackground (UIManager.getColor ("Table.selectionBackground"));
table.getTableHeader ().setResizingAllowed (true);
int rowHeight = UIManager.getInt ("Table.rowHeight");
if (rowHeight > 0) {
table.setRowHeight (rowHeight);
}
else {
table.setRowHeight (table.getRowHeight () + 25);
}
table.setDefaultRenderer (Object.class, new MaterialTableCellRenderer ());
table.setDefaultEditor (Object.class, new MaterialTableCellEditor ());
}
代码示例来源:origin: SeeSharpSoft/intellij-csv-validator
private static JTable createRowHeadersTable(final JTable userTable, int startingNumber) {
final JTable rowHeadersTable = new JBTable(new RowHeadersTableModel(userTable.getModel().getRowCount(), startingNumber));
// this is where you set the width of the row headers
rowHeadersTable.createDefaultColumnsFromModel();
// make the rows look and behave like headers
rowHeadersTable.setBackground(rowHeadersTable.getTableHeader().getBackground());
rowHeadersTable.setForeground(rowHeadersTable.getTableHeader().getForeground());
rowHeadersTable.setFont(rowHeadersTable.getTableHeader().getFont());
rowHeadersTable.setRowHeight(userTable.getRowHeight());
rowHeadersTable.getTableHeader().setReorderingAllowed(false);
rowHeadersTable.setRowSelectionAllowed(true);
rowHeadersTable.setCellSelectionEnabled(true);
rowHeadersTable.setFocusable(true);
rowHeadersTable.setDragEnabled(true);
rowHeadersTable.setSelectionMode(userTable.getSelectionModel().getSelectionMode());
return rowHeadersTable;
}
代码示例来源:origin: xyz.cofe/gui.swing
public JTable getTable(){
if( table!=null )return table;
synchronized(this){
if( table!=null )return table;
table = new JTable();
table.setAutoCreateRowSorter(false);
table.setAutoCreateColumnsFromModel(false);
table.setModel(getSortRowTM());
table.setDefaultEditor(PropertyValue.class, getPropertyEditor());
table.setDefaultRenderer(PropertyValue.class, getPropertyRender());
table.setBackground(Color.white);
table.setFillsViewportHeight(true);
//table.setOpaque(false);
table.setShowVerticalLines(true);
return table;
}
}
//</editor-fold>
代码示例来源:origin: net.sf.sfac/sfac-core
@Override
protected void synchronizeEditableState() {
if (table != null) {
boolean tableEnabled = isEnabled();
table.setEnabled(tableEnabled);
table.setBackground(tableEnabled ? Color.WHITE : Color.LIGHT_GRAY);
table.setForeground(tableEnabled ? Color.BLACK : Color.DARK_GRAY);
table.repaint();
getTableModel().setEditable(isEditable());
}
checkActionStates();
}
内容来源于网络,如有侵权,请联系作者删除!