当前位置: 首页>>代码示例>>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;未经允许,请勿转载。