ex07
来源:互联网 发布:炒沥青怎么看金十数据 编辑:程序博客网 时间:2024/06/06 03:03
import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JCheckBoxMenuItem;import javax.swing.JFormattedTextField;import javax.swing.JFrame;import javax.swing.JMenu;import javax.swing.JMenuItem;import javax.swing.JPasswordField;import javax.swing.JRadioButton;import javax.swing.JRadioButtonMenuItem;import javax.swing.JTextArea;import javax.swing.JTextField;import javax.swing.JToggleButton;import static net.mindview.util.SwingConsole.*;public class ex07 extends JFrame { JTextArea text = new JTextArea(20, 40); JButton button = new JButton("button"); JCheckBox checkBox = new JCheckBox("checkBox"); JCheckBoxMenuItem checkBoxMenuItem = new JCheckBoxMenuItem( "checkBoxMenuItem"); JMenu menu = new JMenu("menu"); JMenuItem menuItem = new JMenuItem("menuitem"); JPasswordField password = new JPasswordField(20); JRadioButton radioButton = new JRadioButton("radiobutton"); JRadioButtonMenuItem radionbuttonmenuitem = new JRadioButtonMenuItem( "radiobuttonmenuitem"); JTextField textfield = new JTextField(20); JFormattedTextField formattedTextField = new JFormattedTextField(); JToggleButton toggle = new JToggleButton("toggle"); public ex07() { textfield.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { text.append(((JTextField) e.getSource()).getText() + "\n"); } }); formattedTextField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { text.append(((JFormattedTextField) e.getSource()).getText() + "\n"); } }); toggle.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { text.append(((JToggleButton) e.getSource()).getText() + "\n"); } }); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { text.append(((JButton) e.getSource()).getText() + "\n"); } }); checkBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { text.append(((JCheckBox) e.getSource()).getText() + "\n"); } }); checkBoxMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { text.append(((JCheckBoxMenuItem) e.getSource()).getText() + "\n"); } }); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { text.append(((JButton) e.getSource()).getText() + "\n"); } }); menu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { text.append(((JMenu) e.getSource()).getText() + "\n"); } }); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { text.append(((JMenuItem) e.getSource()).getText() + "\n"); } }); password.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { text.append(((JPasswordField) e.getSource()).getText() + "\n"); } }); radioButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { text.append(((JRadioButton) e.getSource()).getText() + "\n"); } }); radionbuttonmenuitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { text.append(((JRadioButtonMenuItem) e.getSource()).getText() + "\n"); } }); radioButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { text.append(((JRadioButton) e.getSource()).getText() + "\n"); } }); setLayout(new FlowLayout()); add(text); add(button); add(checkBox); add(checkBoxMenuItem); add(menu); add(menuItem); add(password); add(radioButton); add(radionbuttonmenuitem); add(textfield); add(formattedTextField); add(toggle); } public static void main(String[]args){ run(new ex07(),800,600); }}
0 0
- ex07
- [Thinking in C++]CH02:Ex07 疑惑
- Learn Python the Hard Way 9: Ex07 More Printing
- hdu1863-畅通工程
- 实践出真知
- iframe请求失效重新登录后直接跳转到请求内容页面的解决方案
- 高阶MapReduce_2_链接多个MapReduce作业实例
- kiki’s game
- ex07
- 快速排序(含完整源码)
- iOS小技巧--用runtime 解决UIButton 重复点击问题
- Codeforces 460C Present
- HDOJ 1114 Piggy-Bank(完全背包)
- css3的display定义不同类型的盒
- 手写wsdl文件
- UI初学 按钮
- 将图片转成字节流