⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 example16_5.java

📁 不错的教程 适合中高级人员的使用
💻 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 + -