📄 example16_5.java
字号:
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 Example16_5
{ public static void main(String args[])
{
new Dwindow("带颜色对话框的窗口");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -