當前位置: 首頁>>代碼示例>>Java>>正文


Java JTable.setBackground方法代碼示例

本文整理匯總了Java中javax.swing.JTable.setBackground方法的典型用法代碼示例。如果您正苦於以下問題:Java JTable.setBackground方法的具體用法?Java JTable.setBackground怎麽用?Java JTable.setBackground使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JTable的用法示例。


在下文中一共展示了JTable.setBackground方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createConstraintsTable

import javax.swing.JTable; //導入方法依賴的package包/類
public JTable createConstraintsTable(boolean rebuild) {		
    JTable table = new JTable(new VRPTableModel(rebuild));	      
    
    table.setPreferredScrollableViewportSize(new Dimension(60, 60));
    table.setAutoscrolls(true);
    table.setAutoCreateColumnsFromModel(true);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    table.setMaximumSize(new Dimension(60, 60));
    table.setBackground(Color.LIGHT_GRAY);
    table.setBorder(BorderFactory.createCompoundBorder());
    table.setForeground(Color.BLACK);
    table.setShowGrid(true);
    
      return table;
}
 
開發者ID:guilhebl,項目名稱:routerapp,代碼行數:16,代碼來源:VRPSettings.java

示例2: JFormularioAVencer

import javax.swing.JTable; //導入方法依賴的package包/類
public JFormularioAVencer(AdministradorPagos modelo){
	super(modelo);
	this.setTitle("Cheques Próximos a Vencer (prox. 10 días)");
	this.setSize(345, 200);
	this.setLocation(720, 220);
	this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	this.getContentPane().setBackground(new Color(255, 103, 17));
	this.getContentPane().setLayout(new BoxLayout(this.getContentPane(), BoxLayout.PAGE_AXIS));
	tabla = new JTable(new TablaChequesAVencer(modelo.obtenerChequesAVencer()));
	this.getContentPane().add(tabla);
	tabla.setBackground(new Color(255, 103, 17));
	btnDepositar = new JButton("Depositar");
	this.getContentPane().add(btnDepositar);
	btnCancelar = new JButton("Cancelar");
	this.getContentPane().add(btnCancelar);
	
	btnDepositar.addActionListener(
		new DepositoChequesController(this.getModelo(), this)
	);
	
	btnCancelar.addActionListener(new ActionListener(){
		public void actionPerformed(ActionEvent e){
			dispose();
		}
	});
}
 
開發者ID:edelgado-uade,項目名稱:ioo.tp,代碼行數:27,代碼來源:JFormularioAVencer.java

示例3: checkTableGridLines

import javax.swing.JTable; //導入方法依賴的package包/類
private static void checkTableGridLines() {

        TableModel dataModel = new AbstractTableModel() {
            public int getColumnCount() {
                return 10;
            }

            public int getRowCount() {
                return 10;
            }

            public Object getValueAt(int row, int col) {
                return " ";
            }
        };

        DefaultTableCellRenderer r = new DefaultTableCellRenderer();
        r.setOpaque(true);
        r.setBackground(CELL_RENDERER_BACKGROUND_COLOR);

        JTable table = new JTable(dataModel);
        table.setSize(WIDTH, HEIGHT);
        table.setDefaultRenderer(Object.class, r);
        table.setGridColor(GRID_COLOR);
        table.setShowGrid(true);
        table.setShowHorizontalLines(true);
        table.setShowVerticalLines(true);
        table.setBackground(TABLE_BACKGROUND_COLOR);

        checkTableGridLines(table);
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:32,代碼來源:DrawGridLinesTest.java

示例4: AttrTable

import javax.swing.JTable; //導入方法依賴的package包/類
public AttrTable(Window parent) {
	super(new BorderLayout());
	this.parent = parent;

	titleEnabled = true;
	title = new TitleLabel();
	title.setHorizontalAlignment(SwingConstants.CENTER);
	title.setVerticalAlignment(SwingConstants.CENTER);
	tableModel = new TableModelAdapter(parent, NULL_ATTR_MODEL);
	table = new JTable(tableModel);
	table.setDefaultEditor(Object.class, editor);
	table.setTableHeader(null);
	table.setRowHeight(20);

	Font baseFont = title.getFont();
	int titleSize = Math.round(baseFont.getSize() * 1.2f);
	Font titleFont = baseFont.deriveFont((float) titleSize).deriveFont(Font.BOLD);
	title.setFont(titleFont);
	Color bgColor = new Color(240, 240, 240);
	setBackground(bgColor);
	table.setBackground(bgColor);
	Object renderer = table.getDefaultRenderer(String.class);
	if (renderer instanceof JComponent) {
		((JComponent) renderer).setBackground(Color.WHITE);
	}

	JScrollPane tableScroll = new JScrollPane(table);

	this.add(title, BorderLayout.PAGE_START);
	this.add(tableScroll, BorderLayout.CENTER);
	LocaleManager.addLocaleListener(this);
	localeChanged();
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:34,代碼來源:AttrTable.java

示例5: JFormularioChequesLog

import javax.swing.JTable; //導入方法依賴的package包/類
public JFormularioChequesLog(AdministradorPagos modelo) {
	super(modelo);
	this.setTitle("Log de cheques");
	this.setSize(345, 200);
	this.setLocation(10, 430);
	this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	tabla = new JTable(new TablaChequesLog(modelo.obtenerListaCheques()));
	this.getContentPane().add(tabla);
	tabla.setBackground(new Color(212, 208, 169));
	
}
 
開發者ID:edelgado-uade,項目名稱:ioo.tp,代碼行數:12,代碼來源:JFormularioChequesLog.java

示例6: JFormularioChequesPagos

import javax.swing.JTable; //導入方法依賴的package包/類
public JFormularioChequesPagos(AdministradorPagos modelo) {
	super(modelo);
	this.setTitle("Listado de cheques usados para pagar");
	this.setSize(345, 200);
	this.setLocation(1075, 430);
	this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	tabla = new JTable(new TablaChequesDepositados(modelo.obtenerChequesPagos()));
	this.getContentPane().add(tabla);
	tabla.setBackground(new Color(212, 208, 169));
}
 
開發者ID:edelgado-uade,項目名稱:ioo.tp,代碼行數:11,代碼來源:JFormularioChequesPagos.java

示例7: JFormularioChequesDisponibles

import javax.swing.JTable; //導入方法依賴的package包/類
public JFormularioChequesDisponibles(AdministradorPagos modelo) {
	super(modelo);
	this.setTitle("Listado de cheques disponibles");
	this.setSize(345, 200);
	this.setLocation(365, 430);
	this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	tabla = new JTable(new TablaChequesDisponibles(modelo.obtenerChequesDisponibles()));
	this.getContentPane().add(tabla);
	tabla.setBackground(new Color(212, 208, 169));
}
 
開發者ID:edelgado-uade,項目名稱:ioo.tp,代碼行數:11,代碼來源:JFormularioChequesDisponibles.java

示例8: JFormularioChequesDepositados

import javax.swing.JTable; //導入方法依賴的package包/類
public JFormularioChequesDepositados(AdministradorPagos modelo) {
	super(modelo);
	this.setTitle("Listado de cheques despositados");
	this.setSize(345, 200);
	this.setLocation(720, 430);
	this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	tabla = new JTable(new TablaChequesDepositados(modelo.obtenerChequesDepositados()));
	this.getContentPane().add(tabla);
	tabla.setBackground(new Color(212, 208, 169));
}
 
開發者ID:edelgado-uade,項目名稱:ioo.tp,代碼行數:11,代碼來源:JFormularioChequesDepositados.java

示例9: initialize

import javax.swing.JTable; //導入方法依賴的package包/類
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    frame = new JFrame("Library Book Loan System - Notifications");
    frame.setResizable(false);
    frame.setBounds(100, 100, 438, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
    JPanel panel = new JPanel();
    frame.getContentPane().add(panel, BorderLayout.CENTER);
    panel.setLayout(null);
    
    JLabel lblNotifications = new JLabel("Notifications");
    lblNotifications.setHorizontalAlignment(SwingConstants.CENTER);
    lblNotifications.setFont(new Font("Segoe UI Light", Font.PLAIN, 14));
    lblNotifications.setBounds(10, 40, 414, 22);
    panel.add(lblNotifications);
    
    JLabel label_1 = new JLabel("Library Book Loan System");
    label_1.setHorizontalAlignment(SwingConstants.CENTER);
    label_1.setFont(new Font("Segoe UI Light", Font.PLAIN, 18));
    label_1.setBounds(10, 11, 414, 25);
    panel.add(label_1);
    
    JPanel panel_1 = new JPanel();
    panel_1.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Available Books", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
    panel_1.setBounds(10, 73, 414, 177);
    panel.add(panel_1);
    panel_1.setLayout(null);
    
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(10, 22, 394, 144);
    panel_1.add(scrollPane);
    
    Object columnNames[] = { "No", "Message" };
    Object rowData[][] = getNotifications();
    
    table = new JTable(rowData, columnNames)
    {
        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    
    table.setBackground(Color.white);
    table.setOpaque(true);
    
    
    table.getTableHeader().setReorderingAllowed(false);
    TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(table.getModel());
    table.setRowSorter(sorter);

    List<RowSorter.SortKey> sortKeys = new ArrayList<>(25);
    sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
    sorter.setSortKeys(sortKeys);
    
    table.getColumnModel().getColumn(0).setMaxWidth(40);
    scrollPane.setViewportView(table);
    
}
 
開發者ID:hisener,項目名稱:bbm487s2017g1,代碼行數:63,代碼來源:CustomerNotifications.java


注:本文中的javax.swing.JTable.setBackground方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。