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

📄 firstawt.java

📁 GUI银行管理系统,包括一系列的用户操作功能
💻 JAVA
字号:
package denglu;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;


public class FirstAwt extends JPanel{
	private Image bg;
	public static int Next_month;//存放用户输入的时间,备用数据库查询
	public static int Next_year;//存放年份
	public static int  Next_days;//存放日
	private JFrame FirstWin;
	public static int Flag;
	private JButton buttonture,buttonexit,button_A_Month,button_T_Month,button_Th_Month;
	private JLabel Label_TS_Month,Label_Action;
	private JTextField Text_Month;
	private String TextStrmonth;
	private String TextStryear;
	FirstAwt()
		{
			initOther();
			initWindows();
		}
	public void initWindows()
		{
			
			this.setLayout(null);
			this.add(getJButtonture());
			this.add(getJButtonexit());
			this.add(getJButton_A_Month());
			this.add(getJButton_T_Month());
			this.add(getJButton_Th_Month());
			this.add(getJLabel_TS_Month());
			this.add(getJText_Month());
			this.add(getJLabel_Action());
		     try{
		            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		            SwingUtilities.updateComponentTreeUI(this);
		        } catch(Exception exe){
		            exe.printStackTrace();
		        }
				FirstWin = new JFrame();
				FirstWin.getContentPane().add(this,null);
				FirstWin.validate();
				FirstWin.setSize(700,500);
				FirstWin.setResizable(false);
				FirstWin.setUndecorated(true);
				FirstWin.setLocationRelativeTo(null);
				FirstWin.setVisible(true);
		}
	private JLabel getJLabel_TS_Month()
	{
		Label_TS_Month = new JLabel("请输入你想查询的月份:");
		Label_TS_Month.setBounds(300, 150, 150, 30);
		return Label_TS_Month;
	}
	private JLabel getJLabel_Action()
	{
		Label_Action = new JLabel("输入格式如:20080501");
		Label_Action.setBounds(300, 300, 150, 30);
		return Label_Action;
	}
	private JTextField getJText_Month() {
		Text_Month = new JTextField(2);
		Text_Month.setBounds(300, 200, 150, 30);
		Text_Month.setBackground(Color.WHITE);
		Text_Month.addActionListener(new ActionListener (){
			public void actionPerformed (ActionEvent e)
			{
				try{
					if(Text_Month.getText()==null)
					{
						Label_Action.setText("输入年份不能为空!");
					}
					String TextStr = Text_Month.getText();
					TextStryear = TextStr.substring(0,4);
					TextStrmonth = TextStr.substring(4,6);
			}catch(StringIndexOutOfBoundsException ex){
						Label_Action.setText("输入格式不正确");
					}
				try{
					Next_year = Integer.parseInt(TextStryear);
					Next_month = Integer.parseInt(TextStrmonth);
						if(Next_year>1900&&Next_year<2009)
						{								
							if(Next_month>0&&Next_month<=12)
							{
									FirstWin.dispose();
									Flag = 100;
									NextSecond ke = new NextSecond();
							}else{
								Label_Action.setText("输入出错,请重新输入!(1-12)");
							}
						}else{
								Label_Action.setText("输入出错,请重新输入!(1970-2008)");
							}
				}catch(NumberFormatException ex)
				{
					Label_Action.setText("输入格式化异常,请正确输入!(1-12)");
					Text_Month.setText(null);
					Label_Action.setText("输入格式如:200805");
				}
			}
		});
		return Text_Month;
	}
	private JButton getJButtonture() {
		buttonture = new JButton("查询"); 
		buttonture.setBounds(550, 450, 100, 30);
		buttonture.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
					String TextStr = Text_Month.getText();
					if(Text_Month.getText()==null)
					{
						Label_Action.setText("输入年份不能为空!");
					}
					TextStryear = TextStr.substring(0,4);
					TextStrmonth = TextStr.substring(4,6);
					Next_year = Integer.parseInt(TextStryear);
					Next_month =Integer.parseInt(TextStrmonth);
					Flag = 100;
					NextSecond ke = new NextSecond();
			}
			
		});
		return buttonture;
	}
	private JButton getJButtonexit() {
		buttonexit = new JButton("退出");
		buttonexit.setBounds(20, 450, 100, 30);
		buttonexit.addActionListener(new ActionListener (){
			public void actionPerformed (ActionEvent e)
			{
				new jiemian();
				FirstWin.dispose();
			}
		});
		return buttonexit;
	}
	private JButton getJButton_A_Month() {
		button_A_Month = new JButton("当月记录");
		button_A_Month.setBounds(20, 150, 100, 30);
		button_A_Month.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				Flag=0;
				NextSecond ke = new NextSecond();
			}
		});	
		return button_A_Month;
	}
	private JButton getJButton_T_Month() {
		button_T_Month = new JButton("前月记录");
		button_T_Month.setBounds(20, 250, 100, 30);
		button_T_Month.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				Flag=1;
				NextSecond ke = new NextSecond();
			}
		});
		return button_T_Month;
	}
	private JButton getJButton_Th_Month() {
		button_Th_Month = new JButton("上前月记录");
		button_Th_Month.setBounds(20, 350, 100, 30);
		button_Th_Month.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				Flag=2;
				NextSecond ke = new NextSecond();
			}
		});
		return button_Th_Month;
	}
	
    private void initOther(){
        bg=Toolkit.getDefaultToolkit().createImage(this.getClass().getResource("login/bj3.jpg"));      
        MediaTracker mt=new MediaTracker(this);
        mt.addImage(bg,0);
        try{
            mt.waitForAll();
        } catch(Exception exe){
            exe.printStackTrace();
        }
    }
    protected void paintComponent(Graphics g){
        super.paintComponent(g);
        g.drawImage(bg,0,0,this);
    }
}

⌨️ 快捷键说明

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