⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 colortest.java

📁 记事本的基本功能
💻 JAVA
字号:
package Tools;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.awt.*;
public class ColorTest extends JFrame {

    private JPanel panel_1;
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private JButton button;
    private JPanel panel;
    /**
     * Launch the application
     * @param args
     */
    public static void main(String args[]) {
	try {
	    ColorTest frame = new ColorTest();
	    frame.setVisible(true);
	} catch (Exception e) {
	    e.printStackTrace();
	}
    }

    /**
     * Create the frame
     */
    public ColorTest() {
	super();
	getContentPane().setLayout(null);
	setBounds(100, 100, 500, 375);
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    	{
    		panel = new JPanel();
    		panel.setLayout(null);
    		panel.setBounds(0, 0, 492, 340);
    		getContentPane().add(panel);
    		{
    			button = new JButton();
    			button.addActionListener(new ActionListener() {
    				public void actionPerformed(final ActionEvent e) {
    				test();
    				}
    			});
    			button.setText("New JButton");
    			button.setBounds(108, 134, 99, 23);
    			panel.add(button);
    		}
    		{
    			panel_1 = new JPanel();
    			panel_1.setBounds(85, 25, 193, 70);
    			panel.add(panel_1);
    		}
    	}
	//
    }
    public void test(){
		Color color = JColorChooser.showDialog(this,"Color", Color.BLACK);
		panel_1.setBackground(color);
		System.out.println(color);
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -