推荐-JAVA程序综合设计数据库设计 精品

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

北华大学开放实验报告
实验项目名称: JAVA程序综合设计(数据库设计)所属课程名称: 面对象程序设计——JAVA
实验类型: 设计型
班级: 信息11—2
一、实验目的与要求
1.学会基于JDBC的数据库编程技术
2.了解服务器端和客户端的类
3.学会使用Sever类、GetConnection类、SocketIO和Client类等类的设
计。

4.学会运用AWT和Swing组件美化系统用户界面。

二、实验环境
XP操作传统、Eclipse开发环境和JDK6.0
三、实验原理
JDBC(Java Data Base Connectivity,java数据库连接)是一种用于执行SQL语句的Java API,可以为多种关系数据库提供统一访问,它由一组用Java 语言编写的类和接口组成。

JDBC提供了一种基准,据此可以构建更高级的工具和接口,使数据库开发人员能够编写数据库应用程序。

AWT(Abstract Windowing Toolkit),中文译为抽象窗口工具包,是Java 提供的用来建立和设置Java的图形用户界面的基本工具。

AWT由Java中的java.awt包提供,里面包含了许多可用来建立与平台无关的图形用户界面(GUI)的类,这些类又被称为组件(ponents)。

Swing是由100%纯Java实现的,Swing组件是用Java实现的轻量级( light-weight)组件,没有本地代码,不依赖操作系统的支持,这是它与AWT组件的最大区别。

四、实验内容
1、图书管理系统登录
程序代码为:
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
@SuppressWarnings("serial")
public class t1 extends JApplet implements ActionListener {
Container cp=getContentPane();
Icon ro=new ImageIcon(getClass().getResource("g1.gif"));
JLabel lb0=new JLabel("",ro,JLabel.CENTER);
JLabel lb1=new JLabel();
JTextField tf1=new JTextField(10);
JLabel lb2=new JLabel("密码:",JLabel.CENTER);
JTextField tf2=new JTextField(10);
JButton bt1=new JButton("登入");
JButton bt2=new JButton("重置");
String IP=null;
public void init()
{
cp.setLayout(new FlowLayout());
cp.add(lb0);
cp.add(lb1);
lb1.setText("用户名:");
cp.add(tf1);
cp.add(lb2);
cp.add(tf2);
cp.add(bt1);
bt1.addActionListener(this);
cp.add(bt2);
bt2.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{}
}
运行结果:
2、新书订购管理
程序代码为:
package jihu;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.Font;
import javax.swing.JLabel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import java.awt.Color;
import java.awt.SystemColor;
import youtStyleponentPlacement;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.border.TitledBorder;
import javax.swing.UIManager;
import javax.swing.JboBox;
public class t2 extends JFrame
{
private static final long serialVersionUID = 4180756712362285535L;
private JPanel contentPane;
private JTextField textField;
private JTextField textField_1;
private JTextField textField_2;
private JTextField textField_3;
private JTextField textField_4;
private JTextField textField_5;
private JTextField textField_6;
public static void main(String[] args)
{
EventQueue.invokeLater(new Runnable()
{
public void run()
{
try
{
t2 frame = new t2();
frame.setVisible(true);
}
catch (Exception e)
{e.printStackTrace();}
}
});
}
public t2()
{
setFont(new Font("华文楷体", Font.BOLD, 16));
setTitle("\u65B0\u4E66\u8BA2\u8D2D\u7BA1\u7406");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 627, 410);
contentPane = new JPanel();
contentPane.setForeground(Color.CYAN);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JPanel panel = new JPanel();
panel.setBorder(new
TitledBorder(UIManager.getBorder("TitledBorder.border"),
"\u56FE\u4E66\u4FE1\u606F", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(51, 153, 255)));
JPanel panel_1 = new JPanel();
panel_1.setBorder(new TitledBorder(null,
"\u8BA2\u8D2D\u4FE1\u606F", TitledBorder.LEADING, TitledBorder.TOP, null, SystemColor.textHighlight));
JButton btnNewButton = new JButton("\u6DFB\u52A0");
btnNewButton.setFont(new Font("宋体", Font.BOLD, 12));
JButton btnNewButton_1 = new JButton("\u9000\u51FA");
btnNewButton_1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e) {}
});
btnNewButton_1.setFont(new Font("宋体", Font.BOLD, 12));
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addponent(panel, GroupLayout.DEFAULT_SIZE, 601, Short.MAX_VALUE)
.addponent(panel_1, GroupLayout.DEFAULT_SIZE, 601, Short.MAX_VALUE)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(211)
.addponent(btnNewButton)
.addGap(33)
.addponent(btnNewButton_1)
.addContainerGap(239, Short.MAX_VALUE))
);
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addponent(panel, GroupLayout.PREFERRED_SIZE, 163, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ponentPlacement.RELATED)
.addponent(panel_1, GroupLayout.PREFERRED_SIZE, 153, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ponentPlacement.UNRELATED) .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addponent(btnNewButton_1)
.addponent(btnNewButton))
.addContainerGap(GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);
JLabel lblNewLabel_5 = new
JLabel("\u8BA2\u8D2D\u65E5\u671F\uFF1A");
lblNewLabel_5.setFont(new Font("宋体", Font.BOLD, 12));
JLabel lblNewLabel_6 = new JLabel("\u64CD\u4F5C\u5458\uFF1A");
lblNewLabel_6.setFont(new Font("宋体", Font.BOLD, 12));
JLabel lblNewLabel_7 = new JLabel("\u6298\u6263\uFF1A");
lblNewLabel_7.setFont(new Font("宋体", Font.BOLD, 12));
JLabel lblNewLabel_8 = new
JLabel("\u8BA2\u8D2D\u6570\u91CF\uFF1A");
lblNewLabel_8.setFont(new Font("宋体", Font.BOLD, 12));
JLabel lblNewLabel_9 = new
JLabel("\u662F\u5426\u9A8C\u6536\uFF1A");
lblNewLabel_9.setFont(new Font("宋体", Font.BOLD, 12));
textField = new JTextField();
textField.setColumns(10);
textField_1 = new JTextField();
textField_1.setBackground(UIManager.getColor("Button.light"));
textField_1.setColumns(10);
textField_2 = new JTextField();
textField_2.setColumns(10);
textField_3 = new JTextField();
textField_3.setColumns(10);
JRadioButton rdbtnNewRadioButton = new JRadioButton("\u662F");
rdbtnNewRadioButton.setFont(new Font("宋体", Font.BOLD, 12));
rdbtnNewRadioButton.setSelected(true);
JRadioButton rdbtnNewRadioButton_1 = new JRadioButton("\u5426");
rdbtnNewRadioButton_1.setFont(new Font("宋体", Font.BOLD, 12));
GroupLayout gl_panel_1 = new GroupLayout(panel_1);
gl_panel_1.setHorizontalGroup(
gl_panel_1.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_1.createSequentialGroup() .addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
.addponent(lblNewLabel_5)
.addponent(lblNewLabel_6)
.addponent(lblNewLabel_7))
.addGap(101)
.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING, false)
.addponent(textField_2)
.addponent(textField, Alignment.TRAILING)
.addponent(textField_1, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE))
.addPreferredGap(ponentPlacement.RELATED) .addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
.addponent(lblNewLabel_9)
.addponent(lblNewLabel_8))
.addGap(47)
.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_1.createSequentialGroup()
.addponent(rdbtnNewRadioButton)
.addGap(18)
.addponent(rdbtnNewRadioButton_1)
.addContainerGap())
.addponent(textField_3, GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)))
);
gl_panel_1.setVerticalGroup(
gl_panel_1.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_1.createSequentialGroup()
.addGap(21)
.addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE)
.addponent(lblNewLabel_5)
.addponent(lblNewLabel_8)
.addponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addponent(textField_3,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ponentPlacement.RELATED, 13, Short.MAX_VALUE)
.addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE)
.addponent(lblNewLabel_6)
.addponent(lblNewLabel_9)
.addponent(textField_1,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)
.addponent(rdbtnNewRadioButton)
.addponent(rdbtnNewRadioButton_1))
.addGap(18)
.addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE)
.addponent(lblNewLabel_7)
.addponent(textField_2,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
panel_1.setLayout(gl_panel_1);
JLabel lblNewLabel = new
JLabel("\u4E66\u7C4D\u7F16\u53F7\uFF1A");
lblNewLabel.setFont(new Font("宋体", Font.BOLD, 12));
JLabel lblNewLabel_1 = new
JLabel("\u56FE\u4E66\u7C7B\u522B\uFF1A");
lblNewLabel_1.setFont(new Font("宋体", Font.BOLD, 12));
JLabel lblNewLabel_2 = new
JLabel("\u56FE\u4E66\u4EF7\u683C\uFF1A");
lblNewLabel_2.setFont(new Font("宋体", Font.BOLD, 12));
JLabel lblNewLabel_3 = new
JLabel("\u56FE\u4E66\u540D\u79F0\uFF1A");
lblNewLabel_3.setFont(new Font("宋体", Font.BOLD, 12));
JLabel lblNewLabel_4 = new JLabel("\u51FA\u7248\u793E\uFF1A");
lblNewLabel_4.setFont(new Font("宋体", Font.BOLD, 12));
textField_4 = new JTextField();
textField_4.setColumns(10);
textField_5 = new JTextField();
textField_5.setColumns(10);
textField_6 = new JTextField();
textField_6.setColumns(10);
JboBox boBox = new JboBox();
JboBox boBox_1 = new JboBox();
GroupLayout gl_panel = new GroupLayout(panel);
gl_panel.setHorizontalGroup(
gl_panel.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel.createSequentialGroup()
.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
.addponent(lblNewLabel)
.addponent(lblNewLabel_1)
.addponent(lblNewLabel_2))
.addGap(102)
.addGroup(gl_panel.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_panel.createSequentialGroup() .addGroup(gl_panel.createParallelGroup(Alignment.TRAILING, false)
.addponent(boBox, 0,
GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addponent(textField_4,
GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE))
.addPreferredGap(ponentPlacement.UNRELATED) .addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
.addponent(lblNewLabel_3)
.addponent(lblNewLabel_4))
.addPreferredGap(ponentPlacement.RELATED, 69, Short.MAX_VALUE)
.addGroup(gl_panel.createParallelGroup(Alignment.LEADING, false)
.addponent(boBox_1, 0,
GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addponent(textField_5,
GroupLayout.DEFAULT_SIZE, 143, Short.MAX_VALUE))
.addContainerGap())
.addGroup(gl_panel.createSequentialGroup()
.addponent(textField_6,
GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)
.addGap(297))))
);
gl_panel.setVerticalGroup(
gl_panel.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel.createSequentialGroup()
.addContainerGap()
.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
.addponent(lblNewLabel)
.addponent(lblNewLabel_3)
.addponent(textField_4,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)
.addponent(textField_5,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel.createSequentialGroup()
.addGap(30)
.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
.addponent(lblNewLabel_1)
.addponent(lblNewLabel_4)
.addponent(boBox,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(32)
.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
.addponent(lblNewLabel_2)
.addponent(textField_6, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
.addGroup(gl_panel.createSequentialGroup()
.addGap(18)
.addponent(boBox_1,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
panel.setLayout(gl_panel);
contentPane.setLayout(gl_contentPane);
}
}
运行结果为:
3、图书验收
程序代码为:
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JTable;
import java.awt.Font;
import youtStyleponentPlacement;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JRadioButton;
import javax.swing.table.DefaultTableModel;
import javax.swing.border.LineBorder;
import java.awt.Color;
public class t3 extends JFrame
{
private static final long serialVersionUID= -7319664947163365781L;
private JPanel contentPane;
private JTable table;
private JLabel lblNewLabel;
private JLabel lblNewLabel_1;
private JLabel lblNewLabel_2;
private JLabel lblNewLabel_3;
private JLabel lblNewLabel_4;
private JLabel lblNewLabel_5;
private JLabel lblNewLabel_6;
private JLabel lblNewLabel_7;
private JLabel lblNewLabel_8;
private JTextField textField;
private JTextField textField_1;
private JTextField textField_2;
private JTextField textField_3;
private JTextField textField_4;
private JTextField textField_5;
private JTextField textField_6;
private JTextField textField_7;
private JButton btnNewButton;
private JButton btnNewButton_1;
private JRadioButton rdbtnNewRadioButton;
private JRadioButton rdbtnNewRadioButton_1;
public static void main(String[] args)
{
EventQueue.invokeLater(new Runnable()
{
public void run()
{
try
{
t3 frame = new t3();
frame.setVisible(true);
}
catch (Exception e) {e.printStackTrace();
}
}
});
}
public t3()
{
setFont(new Font("宋体", Font.BOLD, 18));
setTitle("\u56FE\u4E66\u9A8C\u6536");
setAlwaysOnTop(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 632, 396);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
table = new JTable();
table.setBorder(new LineBorder(new Color(0, 0, 0)));
table.setModel(new DefaultTableModel(
new Object[][]
{
{null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null}, },
new String[]
{"New column", "New column", "New column", "New column", "New column", "New column", "New column", "New column", "New column"} ));
table.setColumnSelectionAllowed(true);
lblNewLabel = new JLabel("\u8BA2\u8D2D\u65E5\u671F\uFF1A");
lblNewLabel.setFont(new Font("宋体", Font.BOLD, 12));
lblNewLabel_1 = new JLabel("\u8BA2\u8D2D\u6570\u91CF\uFF1A");
lblNewLabel_1.setFont(new Font("宋体", Font.BOLD, 12));
lblNewLabel_2 = new JLabel("\u56FE\u4E66\u7C7B\u522B\uFF1A");
lblNewLabel_2.setFont(new Font("宋体", Font.BOLD, 12));
lblNewLabel_3 = new JLabel("\u662F\u5426\u9A8C\u6536\uFF1A");
lblNewLabel_3.setFont(new Font("宋体", Font.BOLD, 12));
lblNewLabel_4 = new JLabel("\u8BA2\u8D2D\u4EF7\u683C\uFF1A");
lblNewLabel_4.setFont(new Font("宋体", Font.BOLD, 12));
lblNewLabel_5 = new JLabel("\u4E66\u7C4D\u7F16\u53F7\uFF1A");
lblNewLabel_5.setFont(new Font("宋体", Font.BOLD, 12));
lblNewLabel_6 = new JLabel("\u64CD\u4F5C\u5458\uFF1A");
lblNewLabel_6.setFont(new Font("宋体", Font.BOLD, 12));
lblNewLabel_7 = new
JLabel("\u56FE\u4E66\u539F\u4EF7\u683C\uFF1A");
lblNewLabel_7.setFont(new Font("宋体", Font.BOLD, 12));
lblNewLabel_8 = new JLabel("\u6298\u6263\uFF1A");
lblNewLabel_8.setFont(new Font("宋体", Font.BOLD, 12));
textField = new JTextField();
textField.setColumns(10);
textField_1 = new JTextField();
textField_1.setColumns(10);
textField_2 = new JTextField();
textField_2.setColumns(10);
textField_3 = new JTextField();
textField_3.setColumns(10);
textField_4 = new JTextField();
textField_4.setColumns(10);
textField_5 = new JTextField();
textField_5.setColumns(10);
textField_6 = new JTextField();
textField_6.setColumns(10);
textField_7 = new JTextField();
textField_7.setColumns(10);
btnNewButton = new JButton("\u9A8C\u6536");
btnNewButton.setFont(new Font("宋体", Font.BOLD, 12));
btnNewButton_1 = new JButton("\u9000\u51FA");
btnNewButton_1.setFont(new Font("宋体", Font.BOLD, 12));
rdbtnNewRadioButton = new JRadioButton("\u662F");
rdbtnNewRadioButton.setSelected(true);
rdbtnNewRadioButton_1 = new JRadioButton("\u5426");
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addponent(table, GroupLayout.DEFAULT_SIZE, 558, Short.MAX_VALUE)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(80)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addponent(lblNewLabel)
.addponent(lblNewLabel_1)
.addponent(lblNewLabel_2)
.addponent(lblNewLabel_3)
.addponent(lblNewLabel_4))
.addGap(38)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING) .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false)
.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
.addponent(textField,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addponent(textField_1,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)
.addponent(textField_2,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE))
.addGroup(Alignment.TRAILING,
gl_contentPane.createSequentialGroup()
.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
.addponent(btnNewButton)
.addGroup(gl_contentPane.createSequentialGroup()
.addponent(rdbtnNewRadioButton)
.addPreferredGap(ponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addponent(rdbtnNewRadioButton_1, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(ponentPlacement.RELATED)))
.addponent(textField_3,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE))
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(64)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addponent(lblNewLabel_5)
.addponent(lblNewLabel_6)
.addponent(lblNewLabel_7)
.addponent(lblNewLabel_8))
.addPreferredGap(ponentPlacement.RELATED) .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addponent(textField_7,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)
.addponent(textField_6,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)
.addponent(textField_5,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)
.addponent(textField_4,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)))
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(22)
.addponent(btnNewButton_1)))
.addContainerGap(82, Short.MAX_VALUE))
);
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addponent(table, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE)
.addGap(42)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addponent(lblNewLabel)
.addponent(lblNewLabel_5)
.addponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addponent(textField_4,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ponentPlacement.RELATED) .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addponent(lblNewLabel_1)
.addponent(lblNewLabel_6)
.addponent(textField_1,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)
.addponent(textField_5,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ponentPlacement.RELATED) .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addponent(lblNewLabel_2)
.addponent(lblNewLabel_7)
.addponent(textField_2,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)
.addponent(textField_6,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ponentPlacement.RELATED) .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addponent(lblNewLabel_3)
.addponent(lblNewLabel_8)
.addponent(textField_7,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addponent(rdbtnNewRadioButton_1)
.addponent(rdbtnNewRadioButton))
.addPreferredGap(ponentPlacement.RELATED) .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addponent(lblNewLabel_4)
.addponent(textField_3,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(18)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addponent(btnNewButton)
.addponent(btnNewButton_1))
.addContainerGap(36, Short.MAX_VALUE))
);
contentPane.setLayout(gl_contentPane);
}
}
运行结果为:
4、图书信息添加
程序代码为:
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.SystemColor;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import youtStyleponentPlacement;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
public class t4 extends JFrame
{
private static final long serialVersionUID = 4961483621957067486L;
private JPanel contentPane;
private JTextField textField;
private JTextField textField_1;
private JTextField textField_3;
private JTextField textField_2;
private JTextField textField_4;
private JTextField textField_5;
public static void main(String[] args)
{
EventQueue.invokeLater(new Runnable()
{
public void run()
{
try
{
t4 frame = new t4();
frame.setVisible(true);
}
catch (Exception e)
{e.printStackTrace();}
}
});
}
public t4()
{
setFont(new Font("宋体", Font.BOLD, 14));
setTitle("\u56FE\u4E66\u4FE1\u606F\u6DFB\u52A0");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 512, 387);
contentPane = new JPanel();
contentPane.setForeground(UIManager.getColor("InternalFrame.activ eTitleGradient"));
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JLabel lblNewLabel_1 = new
JLabel("\u56FE\u4E66\u7F16\u53F7\uFF1A");
lblNewLabel_1.setFont(new Font("宋体", Font.BOLD, 12));
JLabel lblNewLabel_2 = new JLabel("\u4E66\u540D\uFF1A");
lblNewLabel_2.setFont(new Font("宋体", Font.BOLD, 12));
JLabel lblNewLabel_3 = new JLabel("\u51FA\u7248\u793E\uFF1A");
lblNewLabel_3.setFont(new Font("宋体", Font.BOLD, 12));
JLabel lblNewLabel_4 = new
JLabel("\u51FA\u7248\u65E5\u671F\uFF1A");
lblNewLabel_4.setFont(new Font("宋体", Font.BOLD, 12));
JLabel lblNewLabel_5 = new JLabel("\u7C7B\u522B\uFF1A");
lblNewLabel_5.setFont(new Font("宋体", Font.BOLD, 12));
JLabel lblNewLabel_6 = new JLabel("\u4F5C\u8005\uFF1A");
lblNewLabel_6.setFont(new Font("宋体", Font.BOLD, 12));
JLabel lblNewLabel_7 = new JLabel("\u8BD1\u8005\uFF1A");
lblNewLabel_7.setFont(new Font("宋体", Font.BOLD, 12));
JLabel lblNewLabel_8 = new JLabel("\u5355\u4EF7\uFF1A");
lblNewLabel_8.setFont(new Font("宋体", Font.BOLD, 12));
textField = new JTextField();
textField.setColumns(10);
textField_1 = new JTextField();
textField_1.setColumns(10);
textField_3 = new JTextField();
textField_3.setColumns(10);
textField_2 = new JTextField();
textField_2.setColumns(10);
textField_4 = new JTextField();
textField_4.setColumns(10);
textField_5 = new JTextField();
textField_5.setColumns(10);
JboBox boBox = new JboBox();
JboBox boBox_1 = new JboBox();
JLabel lblNewLabel_9 = new JLabel("");
JLabel lblNewLabel_10 = new JLabel("");
JButton btnNewButton = new JButton("\u6DFB\u52A0");
btnNewButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent arg0) {} });
btnNewButton.setFont(new Font("宋体", Font.BOLD, 12));
JButton btnNewButton_1 = new JButton("\u5173\u95ED");
btnNewButton_1.setFont(new Font("宋体", Font.BOLD, 12));
JPanel panel = new JPanel();
panel.setBackground(SystemColor.activeCaption);
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addponent(lblNewLabel_1)
.addponent(lblNewLabel_2)
.addponent(lblNewLabel_3)
.addponent(lblNewLabel_4))
.addGap(30)
.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING, false)
.addponent(boBox, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addponent(textField, 79, 79, Short.MAX_VALUE)
.addponent(textField_1, 79, 79, Short.MAX_VALUE)
.addponent(textField_3, 79, 79, Short.MAX_VALUE)
.addponent(lblNewLabel_9, Alignment.LEADING))
.addPreferredGap(ponentPlacement.RELATED, 20, Short.MAX_VALUE)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addponent(lblNewLabel_6)
.addponent(lblNewLabel_5)
.addponent(lblNewLabel_7)
.addponent(lblNewLabel_8))
.addGap(55)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addponent(textField_5, 188, 188, 188)
.addponent(textField_4, 188, 188, 188)。

相关文档
最新文档