📄 colorchooser.java.bak
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
public class colorChooser extends JFrame {
private JPanel contentPane;
private XYLayout xYLayout1 = new XYLayout();
private JColorChooser jColorChooser1 = new JColorChooser();
private JButton jButton1 = new JButton();
private JTextPane jTextPane1 = new JTextPane();
public colorChooser() {
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(xYLayout1);
this.setSize(new Dimension(250, 250));
this.setTitle("使用 ColorChooser");
this.getContentPane().setLayout(xYLayout1);
jButton1.setText("设置颜色");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton1_actionPerformed(e);
}
});
this.getContentPane().add(jButton1, new XYConstraints(78, 17, 95, 25));
this.getContentPane().add(jTextPane1, new XYConstraints(23, 47, 204, 151));
}
public static void main(String[] args){
colorChooser f=new colorChooser();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
f.show();
}
void jButton1_actionPerformed(ActionEvent e) {
Color c=Color.white;
JFrame frame=new JFrame();
c=jColorChooser1.showDialog(frame,"选择你要的颜色",c);
jTextPane1.setBackground(c);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -