⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 storage1.java

📁 中小型书店管理系统,主要是为了方便书店的管理而编写的管理系统.
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;


import javax.swing.*;

public class Storage1 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 = 40;
	private JTextField textFields[][];
	
	public Storage1()
	{
		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( "日" );
		JTextField textField1 = new JTextField( 24 );
		JTextField textField2 = new JTextField( 24 );
		JTextField textField3 = new JTextField( 24 );
		JTextField textField4 = new JTextField( 8 );
		JTextField textField5 = new JTextField( 4 );
		JTextField textField6 = new JTextField( 4 );
		JButton button1 = new JButton( "查询" );
		JButton button2 = new JButton( "入库" );
		JButton button3 = new JButton( "出库" );
//		JButton button4 = new JButton( "退出" );
		
		JLabel label8 = new JLabel( "编号" );
		JLabel label9 = new JLabel( "数量" );
		JLabel label10 = new JLabel( "地址" );
		JLabel label11 = new JLabel( "日期" );		
//		JTextField textField7 = new JTextField( 4 );
//		JTextField textField8 = new JTextField( 4 );
//		JTextField textField9 = new JTextField( 16 );
//		JTextField textField10 = new JTextField( 6 );
		
//		constraints.fill = GridBagConstraints.BOTH;
//		constraints.weightx = 1000;
//		constraints.weighty = 0;
		addComponent( label1, 1, 0, 0, 3, 1 );
		addComponent( label2, 1, 1, 0, 3, 1 );
		addComponent( label3, 1, 2, 0, 3, 1 );
		addComponent( label4, 1, 3, 0, 3, 1 );
		addComponent( label5, 1, 3, 7, 1, 1 );
		addComponent( label6, 1, 3, 10, 1, 1 );
		addComponent( label7, 1, 3, 13, 1, 1 );
		addComponent( textField1, 1, 0, 3, 12, 1 );
		addComponent( textField2, 1, 1, 3, 12, 1 );
		addComponent( textField3, 1, 2, 3, 12, 1 );
		addComponent( textField4, 1, 3, 3, 4, 1 );
		addComponent( textField5, 1, 3, 8, 2, 1 );
		addComponent( textField6, 1, 3, 11, 2, 1 );
		addComponent( button1, 1, 4, 0, 5, 1 );
		addComponent( button2, 1, 4, 5, 5, 1 );
		addComponent( button3, 1, 4, 10, 5, 1 );
		
		constraints.anchor = GridBagConstraints.NORTH;
		addComponent( label8, 2, 0, 0, 2, 1 );
		addComponent( label9, 2, 0, 2, 2, 1 );
		addComponent( label10, 2, 0, 4, 8, 1 );
		addComponent( label11, 2, 0, 12, 3, 1 );
		for( int count = 0; count < num; count++  ){
			textFields = new JTextField[ num ][ 4 ];
			textFields[ count ][ 0 ] = new JTextField( 4 );
			textFields[ count ][ 1 ] = new JTextField( 4 );
			textFields[ count ][ 2 ] = new JTextField( 16 );
			textFields[ count ][ 3 ] = new JTextField( 6);
			
			addComponent( textFields[ count ][ 0 ], 2, count+1, 0, 2, 1 );
			addComponent( textFields[ count ][ 1 ], 2, count+1, 2, 2, 1 );
			addComponent( textFields[ count ][ 2 ], 2, count+1, 4, 8, 1 );
			addComponent( textFields[ count ][ 3 ], 2, count+1, 12, 3, 1 );
		}
		
		container.add( panel1, BorderLayout.NORTH );
		container.add( panel2, BorderLayout.CENTER );
		container.add( new JScrollPane( panel2 ) );
/*		addComponent( button4, 3, 3, 0, 3, 1 );
		container.add( new JButton( "退出" ), BorderLayout.SOUTH );
		container.add( panel3, BorderLayout.SOUTH );
		
		button4.addActionListener(
			new ActionListener() {
				public void actionPerformed( ActionEvent event )
				{
					System.exit( 0 );
				}
			}
		);	
*/			
		setSize( 500,500 );
		setVisible( true );
		

	}
	
	private void addComponent( Component component, int panel , int row,
							   int column, int width, int height )
	{
		constraints.gridx = column;
		constraints.gridy = row;
		constraints.gridwidth = width;
		constraints.gridheight = height;
		layout.setConstraints( component, constraints );
		if( panel == 1 ) panel1.add( component );
		if( panel == 2 ) panel2.add( component );
		if( panel == 3 ) panel3.add( component );
	}
	
//	public static void main( String args[] )
//	{
//		Storage1 application = new Storage1();
//	}
}

⌨️ 快捷键说明

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