?? colortest.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 + -