information.java

来自「中小型书店管理系统,主要是为了方便书店的管理而编写的管理系统.」· Java 代码 · 共 117 行

JAVA
117
字号
import java.awt.*;
import java.awt.event.*;


import javax.swing.*;

public class Information extends JFrame {
/*	private JLabel label1,label2,label3,label4,label5,label6;
	private JTextField textField1,textField2,textField3,textField4,textField5;
	private JButton button1,button2,button3;
	private JComboBox comboBox1,comboBox2;
*/	
	private JPanel panel1,panel2,panel3;
	private Container container;
	private GridBagLayout layout;
	private GridBagConstraints constraints;
	private int num = 4;
	private JTextField textFields[][];
	
	public Information()
	{
		super( "书籍信息管理" );
		
		container = getContentPane();
		layout = new GridBagLayout();
		container.setLayout( layout );
		
		constraints = new GridBagConstraints();
/*		
		panel1 = new JPanel();
		panel1.setLayout( layout );
		
		panel2 = new JPanel();
		panel2.setLayout( layout );
		
		panel3 = new JPanel();
		panel3.setLayout( layout );
*/		
		JLabel label1 = new JLabel( "编号" );
		JLabel label2 = new JLabel( "书名" );
		JLabel label3 = new JLabel( "出版社" );
		JLabel label4 = new JLabel( "作者" );
		JLabel label5 = new JLabel( "出版日期" );
		JLabel label6 = new JLabel( "书价" );
		JLabel label7 = new JLabel( "销售量排行" );
		JLabel label8 = new JLabel( "类别" );	
		JTextField textField1 = new JTextField( 24 );
		JTextField textField2 = new JTextField( 24 );
		JTextField textField3 = new JTextField( 24 );
		JTextField textField4 = new JTextField( 24 );
		JTextField textField5 = new JTextField( 24 );
		JTextField textField6 = new JTextField( 24 );
		JTextField textField7 = new JTextField( 24 );
		JTextField textField8 = new JTextField( 24 );
		JButton button1 = new JButton( "修改" );
		JButton button2 = new JButton( "增加" );
		JButton button3 = new JButton( "删除" );
		JButton button4 = new JButton( "查询" );
//		JButton button5 = new JButton( "退出" );
		
		constraints.fill = GridBagConstraints.BOTH;
//		constraints.weightx = 1000;
//		constraints.weighty = 0;
		addComponent( label1, 0, 0, 4, 1 );
		addComponent( label2, 1, 0, 4, 1 );
		addComponent( label3, 2, 0, 4, 1 );
		addComponent( label4, 3, 0, 4, 1 );
		addComponent( label5, 4, 0, 4, 1 );
		addComponent( label6, 5, 0, 4, 1 );
		addComponent( label7, 6, 0, 4, 1 );
		addComponent( label8, 7, 0, 4, 1 );
		addComponent( textField1, 0, 4, 12, 1 );
		addComponent( textField2, 1, 4, 12, 1 );
		addComponent( textField3, 2, 4, 12, 1 );
		addComponent( textField4, 3, 4, 12, 1 );
		addComponent( textField5, 4, 4, 12, 1 );
		addComponent( textField6, 5, 4, 12, 1 );
		addComponent( textField7, 6, 4, 12, 1 );
		addComponent( textField8, 7, 4, 12, 1 );
		addComponent( button1, 8, 0, 4, 1 );
		addComponent( button2, 8, 4, 4, 1 );
		addComponent( button3, 8, 8, 4, 1 );
		addComponent( button4, 8, 12, 4, 1 );
//		addComponent( button5, 10, 12, 4, 1 );
		
//		constraints.anchor = GridBagConstraints.NORTH;
/*		button5.addActionListener(
			new ActionListener() {
				public void actionPerformed( ActionEvent event )
				{
					System.exit( 0 );
				}
			}
		);	
*/			
		setSize( 500,500 );
		setVisible( true );
		
		
	}
	
	private void addComponent( Component component, int row,
							   int column, int width, int height )
	{
		constraints.gridx = column;
		constraints.gridy = row;
		constraints.gridwidth = width;
		constraints.gridheight = height;
		layout.setConstraints( component, constraints );
		container.add( component );
	}
	
//	public static void main( String args[] )
//	{
//		Information application = new Information();
//	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?