14. 8. 2. JToggleButton is a button that has two states. Pressed and not pressed.
来源:互联网 发布:app自制软件 编辑:程序博客网 时间:2024/05/17 01:07
import java.awt.Color;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JDialog;import javax.swing.JPanel;import javax.swing.JToggleButton;public class ToggleButton extends JDialog implements ActionListener { private JToggleButton red = new JToggleButton("red"); private JToggleButton green = new JToggleButton("green"); private JToggleButton blue = new JToggleButton("blue"); private JPanel display = new JPanel(); public ToggleButton() { JPanel bottom = new JPanel(); JPanel leftPanel = new JPanel(); red.addActionListener(this); green.addActionListener(this); blue.addActionListener(this); leftPanel.add(red); leftPanel.add(green); leftPanel.add(blue); bottom.add(leftPanel); display.setBackground(Color.black); bottom.add(display); add(bottom); pack(); setResizable(false); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); setVisible(true); } public static void main(String[] args) { new ToggleButton(); } public void actionPerformed(ActionEvent e) { Color color = display.getBackground(); int red = color.getRed(); int green = color.getGreen(); int blue = color.getBlue(); if (e.getActionCommand() == "red") { if (red == 0) { red = 255; } else { red = 0; } } if (e.getActionCommand() == "green") { if (green == 0) { green = 255; } else { green = 0; } } if (e.getActionCommand() == "blue") { if (blue == 0) { blue = 255; } else { blue = 0; } } Color setCol = new Color(red, green, blue); display.setBackground(setCol); }}
- 14. 8. 2. JToggleButton is a button that has two states. Pressed and not pressed.
- android: what is the difference between focused, enabled, pressed, and selected states?
- Numbers that can be pressed when the Mobile Phone is locked
- EXTjs4 动态设置 button pressed 状态切换
- shutdown as soon as the power button is pressed, without any prompt
- Android根据Button状态(normal,focused,pressed)显示不同背景图片
- Android根据Button状态(normal,focused,pressed)显示不同背景图片
- Android根据Button状态(normal,focused,pressed)显示不同背景图片
- Android根据Button状态(normal,focused,pressed)显示不同背景图片
- Android根据Button状态(normal,focused,pressed)显示不同背景图片
- Android根据Button状态(normal,focused,pressed)显示不同背景图片
- Android根据Button状态(normal,focused,pressed)显示不同背景图片
- Android根据Button状态(normal,focused,pressed)显示不同背景图片
- Android根据Button状态(normal,focused,pressed)显示不同背景图片
- Form is submitted twice when Enter key is pressed twice
- When ESC is pressed, change the color of the character.
- iOS: Detecting which UIButton was pressed in a UITableView
- pressed, focused, selected区别
- DIR-110路由器 邮件设置
- 学习Ultimate Toolbox笔记二(BackgroundPainter)
- 有错误的。任意进制转换类模版。求指教。
- CSDN社区英雄图谱
- CSDN网友挑选的2007年最有价值文章
- 14. 8. 2. JToggleButton is a button that has two states. Pressed and not pressed.
- CSDN技术英雄会,会了哪些英雄?
- Android四种Activity的加载模式
- 近10年最强的50本计算机图书,您读过几本?
- UVa 401 - Palindromes
- opecv--cvFindContours
- Pascal程序练习-狼找兔子
- Data truncation: Data too long for column '***' at row 1 的解决
- 用struts2搭建一个登录的例子