package swingdemo;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
public class Frame1 extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
JPanel contentPane;
BorderLayout borderLayout1 = new BorderLayout();
JTabbedPane jTabbedPane1 = new JTabbedPane();
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JTextField jTextField1 = new JTextField();
JTextField jTextField2 = new JTextField();
JTextField jTextField3 = new JTextField();
JPasswordField jPasswordField1 = new JPasswordField();
JPanel jPanel3 = new JPanel();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
TitledBorder titledBorder1;
TitledBorder titledBorder2;
JPanel jPanel4 = new JPanel();
JTextField jTextField4 = new JTextField();
JCheckBox jCheckBox1 = new JCheckBox();
JCheckBox jCheckBox2 = new JCheckBox();
JPanel jPanel5 = new JPanel();
JTextField jTextField5 = new JTextField();
JRadioButton jRadioButton1 = new JRadioButton();
JRadioButton jRadioButton2 = new JRadioButton();
JRadioButton jRadioButton3 = new JRadioButton();
JRadioButton jRadioButton4 = new JRadioButton();
ButtonGroup buttonGroup1 = new ButtonGroup();
JPanel jPanel6 = new JPanel();
JComboBox jComboBox1 = new JComboBox();
JLabel jLabel4 = new JLabel();
private Icon icons[] = {new ImageIcon("C:/myjava/bug1.GIF"),
new ImageIcon("C:/myjava/bug2.gif"),
new ImageIcon("C:/myjava/travelbug.gif"),
new ImageIcon("C:/myjava/buganim.gif"), }; //add by hand
private final String colorNames[] = { "Black", "Blue", "Cyan",
"Dark Gray", "Gray", "Green", "Light Gray", "Magenta",
"Orange", "Pink", "Red", "White", "Yellow" }; //add by hand
private final Color colors[] = { Color.BLACK, Color.BLUE, Color.CYAN,
Color.DARK_GRAY, Color.GRAY, Color.GREEN, Color.LIGHT_GRAY,
Color.MAGENTA, Color.ORANGE, Color.PINK, Color.RED, Color.WHITE,
Color.YELLOW }; //add by hand
TitledBorder titledBorder3;
JPanel jPanel7 = new JPanel();
JScrollPane jScrollPane1 = new JScrollPane();
JList jList1 = new JList(colorNames);
JPanel jPanel8 = new JPanel();
JScrollPane jScrollPane2 = new JScrollPane();
JList jList2 = new JList(colorNames);
JButton jButton3 = new JButton();
JScrollPane jScrollPane3 = new JScrollPane();
JList jList3 = new JList();
//Construct the frame
public Frame1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
titledBorder1 = new TitledBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED,Color.white,Color.white,new Color(124, 124, 124),new Color(178, 178, 178)),"");
titledBorder2 = new TitledBorder("");
titledBorder3 = new TitledBorder("");
contentPane.setLayout(borderLayout1);
this.setSize(new Dimension(400, 300));
this.setTitle("Frame Title");
jTabbedPane1.setPreferredSize(new Dimension(49, 54));
jTabbedPane1.setRequestFocusEnabled(true);
jLabel1.setFont(new java.awt.Font("Serif", 0, 18));
jLabel1.setToolTipText("This is label1");
jLabel1.setText("Label with text");
jLabel1.setBounds(new Rectangle(42, 26, 127, 32));
jPanel1.setLayout(null);
jLabel2.setFont(new java.awt.Font("Serif", 0, 18));
jLabel2.setToolTipText("This is label2");
jLabel2.setHorizontalTextPosition(SwingConstants.TRAILING);
jLabel2.setIcon(new ImageIcon(new java.net.URL("file:///C:/myjava/bug1.GIF")));
jLabel2.setText("Label with text and icon");
jLabel2.setVerticalTextPosition(SwingConstants.CENTER);
jLabel2.setBounds(new Rectangle(43, 80, 231, 37));
jLabel3.setFont(new java.awt.Font("Serif", 0, 18));
jLabel3.setToolTipText("This is label3");
jLabel3.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel3.setIcon(new ImageIcon(new java.net.URL("file:///C:/myjava/bug1.png")));
jLabel3.setText("Label with icon and text at bottom");
jLabel3.setVerticalAlignment(SwingConstants.CENTER);
jLabel3.setVerticalTextPosition(SwingConstants.BOTTOM);
jLabel3.setBounds(new Rectangle(38, 145, 266, 70));
jTextField1.setText("");
jTextField1.setBounds(new Rectangle(41, 27, 114, 22));
jTextField1.addActionListener(new Frame1_jTextField1_actionAdapter(this));
jPanel2.setLayout(null);
jTextField2.setText("Enter text here");
jTextField2.setBounds(new Rectangle(191, 26, 142, 25));
jTextField2.addActionListener(new Frame1_jTextField2_actionAdapter(this));
jTextField3.setBackground(Color.lightGray);
jTextField3.setBorder(BorderFactory.createLineBorder(Color.black));
jTextField3.setEditable(false);
jTextField3.setText("Uneditable text field");
jTextField3.setBounds(new Rectangle(16, 99, 231, 28));
jTextField3.addActionListener(new Frame1_jTextField3_actionAdapter(this));
jPasswordField1.setText("Hidden text");
jPasswordField1.setEchoChar('*');
jPasswordField1.setBounds(new Rectangle(88, 150, 151, 28));
jPasswordField1.addActionListener(new Frame1_jPasswordField1_actionAdapter(this));
jButton1.setBounds(new Rectangle(49, 80, 123, 31));
jButton1.setFont(new java.awt.Font("Serif", 1, 16));
jButton1.setBorder(titledBorder2);
jButton1.setText("Plain Button");
jButton1.addActionListener(new Frame1_jButton1_actionAdapter(this));
jPanel3.setLayout(null);
jButton2.setBounds(new Rectangle(48, 134, 179, 49));
jButton2.setFont(new java.awt.Font("Serif", 1, 16));
jButton2.setBorder(titledBorder2);
jButton2.setIcon(new ImageIcon(new java.net.URL("file:///C:/myjava/bug1.GIF")));
jButton2.setRolloverIcon(new ImageIcon(new java.net.URL("file:///C:/myjava/bug2.GIF")));
jButton2.setText("Fancy Button");
jButton2.addActionListener(new Frame1_jButton2_actionAdapter(this));
jTextField4.setBackground(Color.white);
jTextField4.setFont(new java.awt.Font("Serif", 0, 14));
jTextField4.setBorder(titledBorder1);
jTextField4.setToolTipText("");
jTextField4.setText("Watch the font style change");
jTextField4.setBounds(new Rectangle(79, 48, 219, 35));
jPanel4.setLayout(null);
jCheckBox1.setText("Bold");
jCheckBox1.setBounds(new Rectangle(85, 116, 83, 25));
jCheckBox1.addItemListener(new Frame1_jCheckBox1_itemAdapter(this));
jCheckBox2.setSelected(false);
jCheckBox2.setText("Italic");
jCheckBox2.setBounds(new Rectangle(190, 116, 83, 25));
jCheckBox2.addItemListener(new Frame1_jCheckBox2_itemAdapter(this));
jTextField5.setFont(new java.awt.Font("Serif", 0, 14));
jTextField5.setBorder(titledBorder2);
jTextField5.setText("Watch the font style change");
jTextField5.setBounds(new Rectangle(41, 21, 294, 41));
jPanel5.setLayout(null);
jRadioButton1.setSelected(true);
jRadioButton1.setText("Plain");
jRadioButton1.setBounds(new Rectangle(37, 98, 59, 25));
jRadioButton1.addItemListener(new Frame1_jRadioButton1_itemAdapter(this));
jRadioButton2.setText("Bold");
jRadioButton2.setBounds(new Rectangle(114, 98, 59, 25));
jRadioButton2.addItemListener(new Frame1_jRadioButton2_itemAdapter(this));
jRadioButton3.setText("Italic");
jRadioButton3.setBounds(new Rectangle(190, 98, 70, 25));
jRadioButton3.addItemListener(new Frame1_jRadioButton3_itemAdapter(this));
jRadioButton4.setText("Bold/Italic");
//jRadioButton4.setBounds(new Rectangle(267, 98, 90, 25));
jRadioButton4.setBounds(new Rectangle(37, 130, 120, 25));
jRadioBu
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Swingdemo.rar (8个子文件)
Swingdemo
MenuTest.java 8KB
Application1.java 1KB
Frame1.java 19KB
KeyDemo.java 2KB
SimpleDialogDemo.java 4KB
MouseTracker.java 3KB
ScrollBarSliderDemo.java 2KB
Painter.java 2KB
共 8 条
- 1
资源评论
苏州好风光
- 粉丝: 1
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功