zoukankan      html  css  js  c++  java
  • 分享一个调色小程序

    package Task15;
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    
    import javax.swing.*;
    
    public class One {
    		public static void main(String[] args)
    		{
    			new MyFrame();
    		}
    }
    class MyFrame extends JFrame
    {
    	
    	//private JRadioButton red,yellow;
    	private JRadioButton rb1;
    	private JPanel palette;
    	private JPanel normal;
    	private ButtonGroup rgroup;
    	
    	MyFrame()
    	{
    		this.setTitle("背景转换");
    		this.setBounds(200,300,200,300);
    		//this.setLayout(new FlowLayout(FlowLayout.CENTER));
    		this.setDefaultCloseOperation(MyFrame.EXIT_ON_CLOSE);
    		palette=new JPanel();
    		normal=new JPanel();
    		rgroup=new ButtonGroup();
    		addJRadioButton("红");
    		addJRadioButton("黑");
    		addJRadioButton("黄");
    		this.add(palette,BorderLayout.CENTER);
    		this.add(normal,BorderLayout.SOUTH);
    		
    		this.setVisible(true);
    	}
    	private void addJRadioButton(final String text)
    	{
    		
    		rb1=new JRadioButton(text);
    		normal.add(rb1);
    		rgroup.add(rb1);
    		rb1.addActionListener(new ActionListener()
    				{
    					public void actionPerformed(ActionEvent e)
    					{
    						Color col=null;
    						if("红".equals(text))
    							col=Color.RED;
    						
    						else if("黑".equals(text))
    							col=Color.BLACK;
    						else if("黄".equals(text))
    								col=Color.YELLOW;
    						else{
    							col=Color.WHITE;
    						}
    						
    						
    						palette.setBackground(col);
    					}
    				}
    				);
    		
    	}
    }
    
    
  • 相关阅读:
    web页面前图标
    leetcode收获
    Shell统计函数耗时(实现数字运算)
    Shell判断数值是否存在于列表
    设置Ubuntu虚拟机硬件时间与系统同步
    Python捕获键盘中断^C方法(Ctrl-C)
    Shell创建zip文件不包含完整路径方法
    jquery判断复选框checkbox是否被选中
    php Base64编码/解码
    php二维数组排序
  • 原文地址:https://www.cnblogs.com/tfxz/p/12621725.html
Copyright © 2011-2022 走看看