package com.fxb.gui;

import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import javax.swing.GroupLayout.Alignment;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.UIManager; public class Test2_JFrame extends JFrame{ JButton button1 = new JButton("Button1");
JButton button2 = new JButton("Button2");
JButton button3 = new JButton("Button3");
TextField field = new TextField(10);
JComboBox comboBox = new JComboBox();
JCheckBox checkBox = new JCheckBox("Check1");
JRadioButton radioButton1 = new JRadioButton("Radio1");
JRadioButton radioButton2 = new JRadioButton("Radio1"); ButtonGroup buttonGroup = new ButtonGroup(); public Test2_JFrame(){
// try{
//// UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName( ) );
//// UIManager.setLookAndFeel( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" );
//// UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel" );
// }catch(Exception e){
// e.printStackTrace();
// } setVisible(true);
setLayout(new FlowLayout(FlowLayout.LEFT ));
// setLayout(new FlowLayout(FlowLayout.CENTER ));
setSize(300, 300);
setAutoRequestFocus(false);
setResizable(false); JPanel panel = new JPanel();
panel.setLayout(new GridLayout(4, 2, 10, 5));
panel.setSize(200, 200);
add(panel); panel.add(button1);
panel.add(button2);
panel.add(button3);
//panel.add(field); comboBox.addItem("Item1");
comboBox.addItem("Item2");
comboBox.addItem("Item3");
panel.add(comboBox); panel.add(checkBox);
buttonGroup.add(radioButton1);
buttonGroup.add(radioButton2);
panel.add(radioButton1);
panel.add(radioButton2); JTextArea textArea = new JTextArea();
textArea.setSize(100, 100);
add(textArea); // add(button1);
// add(button2);
// add(button3); button1.addActionListener(actionListener);
button2.addActionListener(actionListener);
button3.addActionListener(actionListener);
} private ActionListener actionListener = new ActionListener(){
public void actionPerformed(ActionEvent e) {
if(e.getSource() == button1){
pt("button1");
}else if(e.getSource() == button2){
pt("button2");
}else if(e.getSource() == button3){
pt("button3");
}
}
}; private static StringBuilder builder = new StringBuilder();
public static void pt(Object a){
builder.setLength(0);
builder.append(a);
System.out.println(builder.toString());
} public static void main(String[] args){
new Test2_JFrame();
} }

JFrame2的更多相关文章

随机推荐

  1. 3Delight feats. OpenVDB

    Full GI, no multiple scattering now (no point-cloud similar solution in 3Delight now) Blackbody Cart ...

  2. Android 设计模式对比

    引言: Android框架的发展的过程就是一个不断化繁为简的过程,大家都在研究如何正确方便高效的规范代码.当然这条路也永远不会停止,就像新的芽儿,随着时间的流逝,每天都在长出新的枝叶,每天都在成长.对 ...

  3. Velodyne VLP-16 gmapping 建图

    1. 测试环境 Ubuntu 16.04 x64.ROS Kinetic.Velodyne VLP-16.RoboWare Studio 2. 安装 ROS 功能包 sudo apt-get inst ...

  4. Wu反走样算法绘制直线段

    Wu反走样算法 原理:在我看来,Wu反走样算法是在Bresenham算法基础上改进了一番,它给最靠近理想直线/曲线的两个点以不同的亮度值,以达到模糊锯齿的效果.因为人眼看到的是线附近亮度的平均值. M ...

  5. [20181130]如何猜测那些值存在hash冲突.txt

    [20181130]如何猜测那些值存在hash冲突.txt --//今年6月份开始kerrycode的1个帖子提到子查询结果缓存在哈希表中情况:--//链接:http://www.cnblogs.co ...

  6. [20180927]ora-01426.txt

    [20180927]ora-01426.txt --//链接:http://www.itpub.net/thread-2105458-1-1.html1.环境:SCOTT@test01p> @ ...

  7. [20180814]慎用查看表压缩率脚本.txt

    [20180814]慎用查看表压缩率脚本.txt --//最近看exadata方面书籍,书中提供1个脚本,查看某些表采用那些压缩模式压缩比能达到多少.--//通过调用DBMS_COMPRESSION. ...

  8. wifi破解基础及工具的使用

    cdlinux学习,WiFi破解 cdlinux下载.vm安装 cdlinux下载 密码:vxao - 注意:cdlinux必须是在连接网卡的情况下,才能使用 水滴的使用 抓包.跑包 选择信号强度高, ...

  9. C#实现CRC校验

    using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Web; ...

  10. Python 3 iter函数用法简述

    Python 3中关于iter(object[, sentinel)]方法有两个参数. 使用iter(object)这种形式比较常见. iter(object, sentinel)这种形式一般较少使用 ...