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


Java JButton.setBackground方法代碼示例

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


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

示例1: stylizeButton

import javax.swing.JButton; //導入方法依賴的package包/類
/**
 * JComponent styling wrappers
 */
public void stylizeButton(JButton b){
	b.setFocusPainted(false);
	b.setFont(font_14_bold);
	b.setForeground(Color.WHITE);
	b.setBackground(new Color(102, 0, 153)); // Purple
}
 
開發者ID:kevingilboy,項目名稱:COE1186,代碼行數:10,代碼來源:TrainModelGUI.java

示例2: prepareControls

import javax.swing.JButton; //導入方法依賴的package包/類
protected void prepareControls() {
    JFrame frame = new JFrame("SplitPane Mixing");
    JPanel p = new JPanel(new GridLayout());
    p.setPreferredSize(new Dimension(500, 500));
    propagateAWTControls(p);
    sp1 = new JScrollPane(p);

    JButton button = new JButton("JButton");
    button.setBackground(Color.RED);
    button.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            clicked = true;
        }
    });
    sp2 = new JScrollPane(button);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sp1, sp2);
    splitPane.setOneTouchExpandable(false);
    splitPane.setDividerLocation(150);

    splitPane.setPreferredSize(new Dimension(400, 200));

    frame.getContentPane().add(splitPane);
    frame.pack();
    frame.setVisible(true);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:28,代碼來源:JSplitPaneOverlapping.java

示例3: stylizeButton

import javax.swing.JButton; //導入方法依賴的package包/類
/**
 * Created by Kevin Le to stylize buttons to all look the same
 * @param b
 */
public void stylizeButton(JButton b){
	Border thickBorder = new LineBorder(Color.WHITE, 3);
   	b.setBorder(thickBorder);
	b.setContentAreaFilled(false);
	b.setOpaque(true);
	b.setBackground(Color.BLACK);
	b.setForeground(Color.WHITE);
}
 
開發者ID:kevingilboy,項目名稱:COE1186,代碼行數:13,代碼來源:TrainModelNewGUI.java

示例4: stylizeButton

import javax.swing.JButton; //導入方法依賴的package包/類
public void stylizeButton(JButton b){
	Border thickBorder = new LineBorder(Color.WHITE, 3);
   		b.setBorder(thickBorder);
	b.setContentAreaFilled(false);
	b.setOpaque(true);
	b.setBackground(Color.BLACK);
	b.setForeground(Color.WHITE);
}
 
開發者ID:kevingilboy,項目名稱:COE1186,代碼行數:9,代碼來源:TrainC.java

示例5: stylizeButton

import javax.swing.JButton; //導入方法依賴的package包/類
public void stylizeButton(JButton b){
	Border thickBorder = new LineBorder(Color.WHITE, 3);
   	b.setBorder(thickBorder);
	b.setContentAreaFilled(false);
	b.setOpaque(true);
	b.setBackground(Color.BLACK);
	b.setForeground(Color.WHITE);
}
 
開發者ID:kevingilboy,項目名稱:COE1186,代碼行數:9,代碼來源:TrackModelGUI.java

示例6: stylizeButton

import javax.swing.JButton; //導入方法依賴的package包/類
public void stylizeButton(JButton b){
	Border thickBorder = new LineBorder(Color.WHITE, 3);
	b.setFont(new Font("Arial", Font.BOLD, 18));
   	b.setBorder(thickBorder);
	b.setContentAreaFilled(false);
	b.setOpaque(true);
	b.setBackground(Color.BLACK);
	b.setForeground(Color.WHITE);
}
 
開發者ID:kevingilboy,項目名稱:COE1186,代碼行數:10,代碼來源:SplashPage.java

示例7: SecurePasswordInputPanel

import javax.swing.JButton; //導入方法依賴的package包/類
private SecurePasswordInputPanel() {
    super(new GridLayout(0, 1));

    this.passwordField = new JPasswordField(10);
    passwordField.setEditable(false);

    add(passwordField);

    Set<Integer> rows = new HashSet<Integer>(KEYS_MAP.keySet());
    final int n = rows.size();

    SecureRandom random = new SecureRandom();
    while (!rows.isEmpty()) {
        int row = random.nextInt() % n;
        if (!rows.contains(row)) {
            continue;
        }

        String[] keys = KEYS_MAP.get(row);
        rows.remove(row);

        JPanel panel = new JPanel();
        for (int column = 0; column < keys.length; column++) {
            String text = keys[column];
            JButton button = new JButton(text);
            button.setFont(button.getFont().deriveFont(Font.TRUETYPE_FONT));
            if (CLEAR.equalsIgnoreCase(text)) {
                button.setBackground(Color.red);
            } else if (CAPS.equalsIgnoreCase(text) || BACKSPACE.equalsIgnoreCase(text)) {
                button.setBackground(Color.lightGray);
            } else {
                buttons.add(button);
            }

            button.putClientProperty("key", text);
            button.addActionListener(new MyActionListener());
            panel.add(button);
        } // end for
        add(panel);
    } // end while(!rows.isEmpty())

    //setVisible(true);
}
 
開發者ID:xipki,項目名稱:xitk,代碼行數:44,代碼來源:SecurePasswordInputPanel.java

示例8: stylizeButton_Disabled

import javax.swing.JButton; //導入方法依賴的package包/類
public void stylizeButton_Disabled(JButton b){
	b.setFocusPainted(false);
	b.setFont(font_14_bold);
	b.setForeground(Color.GRAY);
	b.setBackground(new Color(50, 0, 70));
}
 
開發者ID:kevingilboy,項目名稱:COE1186,代碼行數:7,代碼來源:TrnControllerGUI.java

示例9: createButton

import javax.swing.JButton; //導入方法依賴的package包/類
public JButton createButton(String string, Color color, Color textColor) {

		JButton button = createButton(string);

		button.setBackground(color);
		button.setForeground(textColor);

		return button;
	}
 
開發者ID:Gallery-of-Kaeon,項目名稱:Kaeon-FUSION,代碼行數:10,代碼來源:IDE.java

示例10: Components

import javax.swing.JButton; //導入方法依賴的package包/類
/**
 * Initializing the components.
 */
private void Components() {
	
	letsPlay = new JLabel("Let's Play");
	letsPlay.setHorizontalAlignment(SwingConstants.CENTER);
	letsPlay.setBounds(6, 6, 644, 16);
	contentPane.add(letsPlay);
	
	vLabel = new JLabel("Vehicle:");
	vLabel.setBounds(6, 47, 61, 16);
	contentPane.add(vLabel);
	
	vehicle = new JComboBox<>();
	vehicle.setBounds(79, 43, 83, 27);
	contentPane.add(vehicle);
	
	rLabel = new JLabel("Row:");
	rLabel.setBounds(174, 47, 44, 16);
	contentPane.add(rLabel);
	
	row = new JComboBox<>();
	row.setBounds(230, 43, 83, 27);
	contentPane.add(row);
	
	colsLabel = new JLabel("Column:");
	colsLabel.setBounds(335, 47, 61, 16);
	contentPane.add(colsLabel);
	
	column = new JComboBox<>();
	column.setBounds(408, 43, 83, 27);
	contentPane.add(column);
	
	execute = new JButton("Execute");
	execute.setForeground(Color.BLACK);
	execute.setBackground(Color.WHITE);
	execute.setBounds(503, 42, 117, 29);
	contentPane.add(execute);
	
	lblThisRowAnd = new JLabel("This row and column represents the head of vehicle");
	lblThisRowAnd.setFont(new Font("Lucida Grande", Font.PLAIN, 9));
	lblThisRowAnd.setBounds(200, 26, 252, 16);
	contentPane.add(lblThisRowAnd);
	
	int x = 174, y = 97;
	for(int i = 0; i < cells.length; i++){
	
		for(int j = 0; j < cells[i].length; j++){
			
			cells[i][j] = new JLabel("");
			cells[i][j].setOpaque(true);
			cells[i][j].setForeground(Color.white);
			cells[i][j].setHorizontalAlignment(SwingConstants.CENTER);
			cells[i][j].setBackground(new Color(204, 204, 204));
			cells[i][j].setBounds(x+(j*50), y, 50, 50);
			x += 1;
			contentPane.add(cells[i][j]);
		}
		x = 174;
		y += 51;
	}
	
	cells[2][5].setText("Exit");
	cells[2][5].setBackground(Color.red);
	
	for(int i = 1; i <= 6; i++){
		vehicle.addItem(String.valueOf(i));
		row.addItem(String.valueOf(i));
		column.addItem(String.valueOf(i));
	}
	
}
 
開發者ID:rehanjavedofficial,項目名稱:Rush-Hour,代碼行數:74,代碼來源:MainFrame.java

示例11: customizeButton

import javax.swing.JButton; //導入方法依賴的package包/類
private static void customizeButton(JButton button, Border border, Dimension dim, Color color) {
  button.setBackground(color);
  button.setOpaque(true);
  button.setPreferredSize(dim);
  button.setBorder(border);
}
 
開發者ID:vaclav,項目名稱:voicemenu,代碼行數:7,代碼來源:Style.java


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