example8_6.java
来自「不错的教程 适合中高级人员的使用」· Java 代码 · 共 38 行
JAVA
38 行
import java.awt.event.*;
import java.awt.*;
import javax.swing.JColorChooser;
class Dwindow extends Frame implements ActionListener
{ Button button;
Dwindow(String s)
{ super(s);
button=new Button("打开颜色对话框");
button.addActionListener(this);
setLayout(new FlowLayout());
add(button);
setBounds(60,60,300,300);
setVisible(true);
validate();
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
);
}
public void actionPerformed(ActionEvent e)
{
Color newColor=JColorChooser.showDialog(this,"调色板",button.getBackground());
button.setBackground(newColor);
}
}
public class Example8_6
{ public static void main(String args[])
{
new Dwindow("带颜色对话框的窗口");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?