JFrame2
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的更多相关文章
随机推荐
- C# 利用ReportViewer生成报表
本文主要是利用微软自带的控件ReportViewer进行报表设计的小例子,仅供学习分享使用,如有不足之处,还请指正. 涉及知识点: ReportViewer :位于Microsoft.Reportin ...
- C# 使用System.Data.OleDb;避免oracle中文乱码问题
首先,需要保证oracle客户端服务器的字符集是一样的,并且保证该字符集支持中文.你可以使用plsql查看是否乱码. 代码: using System; using System.Collection ...
- [iOS]创建界面方法的讨论
以前在入门的时候,找的入门书籍上编写的 demo 都是基于 Storyboards 拖界面的.后来接触公司项目,发现界面都是用纯代码去写复杂的 autoLayout 的.再然后,领导给我发了个 Mas ...
- Java常考面试题(经典)
什么是Java虚拟机?为什么Java被称作是“平台无关的编程语言”? Java虚拟机是一个可以执行Java字节码的虚拟机进程.Java源文件被编译成能被Java虚拟机执行的字节码文件. Java被设计 ...
- 简单易懂的程序语言入门小册子(5):基于文本替换的解释器,递归,不动点,fix表达式,letrec表达式
这个系列有个显著的特点,那就是标题越来越长.忽然发现今天是读书节,读书节多读书. ==下面是没有意义的一段话============================================== ...
- CMM/CMMI的基本概念
"CMM是指“能力成熟度模型”,其英文全称为Capability Maturity Model for Software,英文缩写为SW-CMM,简称CMM. 它是对于软件组织在定义.实施. ...
- Ubuntu下使用终端ssh访问设置了密钥的云服务器
首先先安装OpenSSH客户端,可以直接apt-get安装 sudo apt-get install openssh-server 然后将私钥权限修改为600 chmod 600 keyfile 最后 ...
- 《Java大学教程》—第21章 高级案例研究
21.3 需求:P510用例模型(use case model):用例图(use case diagram).用例(use case).行为说明(behaviour specification) ...
- python 基础操作--数据类型
一.变量 1.定义:将运算的中间结果暂存到内存,以便后续程序调用. 2.命名规则 1.变量由字母.数字.下划线搭配组合而成: 2.不可以用数字开头,也不能全都是数字: 3.不能是python 关键字, ...
- Maven将中央仓库修改为阿里云的仓库地址
<mirror> <id>nexus-aliyun</id> <mirrorOf>*</mirrorOf> <name>Nexu ...