10例子32.txt
来自「这是一本java基础教程 对新手上路有很大帮助」· 文本 代码 · 共 28 行
TXT
28 行
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class Example10_32{
public static void main(String args[]){
new ColorWin("带颜色对话框的窗口");
}
}
class ColorWin extends JFrame implements ActionListener{
JButton buttonOpen,showColor;
ColorWin(String s){
setTitle(s);
buttonOpen=new JButton("打开颜色对话框");
showColor=new JButton();
buttonOpen.addActionListener(this);
add(buttonOpen,BorderLayout.NORTH);
add(showColor,BorderLayout.CENTER);
setBounds(60,60,300,300);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e){
Color newColor=JColorChooser.showDialog(this,"调色板",showColor.getBackground());
if(newColor!=null)
showColor.setBackground(newColor);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?