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

📄 accountframe.java

📁 Java banking application with GUI add/delete/update new account partially generic GUI
💻 JAVA
字号:
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JLabel;
import java.awt.Container;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFormattedTextField;
import java.text.NumberFormat;
import javax.swing.text.NumberFormatter;
import javax.swing.text.DefaultFormatterFactory;
import javax.swing.JSpinner;
import javax.swing.SpinnerListModel;
import javax.swing.JComboBox;
import java.util.Locale;
import java.util.ResourceBundle;
import java.awt.Dimension;
import java.awt.GridLayout;

public class AccountFrame extends JFrame {
    private JTextField holdername;
    private JFormattedTextField balance;
    private JTextField size;
    private JComboBox type;
    private JButton submit;
    private AccountDAO accountdao=new AccountDAO();
    
    public AccountFrame(){
		super("Account");

      Container contentpane=this.getContentPane();
      contentpane.setLayout(new FlowLayout());
    //setJMenuBar(new MyMenuBar(this));
      contentpane.add(new JLabel("Add New Account"));
	JPanel jp1=new JPanel();
	jp1.setLayout(new GridLayout(5,2));

      jp1.add(new JLabel("Type"));
      type=new JComboBox();
		type.addItem("Current");
		type.addItem("Saving");
      jp1.add(type);

      jp1.add(new JLabel("Holder Name"));
      holdername=new JTextField(10);
      jp1.add(holdername);

     jp1.add(new JLabel("Balance"));
     DefaultFormatterFactory dff=new DefaultFormatterFactory(
		 new NumberFormatter(NumberFormat.getCurrencyInstance()),
		 new NumberFormatter(NumberFormat.getCurrencyInstance()),
		 new NumberFormatter(NumberFormat.getNumberInstance()));
      balance = new JFormattedTextField(dff);
      balance.setValue(new Double(0.0));
      balance.setColumns(10);
      jp1.add(balance);

      contentpane.add(jp1);
      submit=new JButton("Submit");
      submit.addActionListener(new ButtonListener(this));
      contentpane.add(submit);
      setBounds(200,200,300,250);
      setVisible(true);
    }
    private class ButtonListener implements ActionListener{
     private JFrame jframe;
      public ButtonListener(JFrame jf)
      {
        jframe=jf;
      }
    public void actionPerformed(ActionEvent ae)
      {
        Object source=ae.getSource();
        if(source.equals(submit))
        {
           jframe.setVisible(false);
          String temp=type.getSelectedItem().toString();
          accountdao.addAccount(holdername.getText(),temp,((Number)balance.getValue()).doubleValue());
	  MainMenu menu=new MainMenu();
        }
      }
  }
  }

⌨️ 快捷键说明

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