Nuwang 0 Newbie Poster


pls modify this program and reply.

I have 3 points ask from u.

1. I could increase Font size and Button sizes But in first form still I cant mange spacing in Box layout which I used as totally fill the form

2. Want to manage Second form with radio buttons in two columns and when one button select other buttons must be remove their selection (deselect)

3. One example with database connection in any form
Delete and add a data row with and Access database Eg:- Test.mdb

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class MyBank extends JFrame implements ActionListener{
//------------------------------------------------------------------Panels Add
JPanel mainPanel=new JPanel();
JPanel BalancePanel=new JPanel();
JPanel DepositPanel=new JPanel();
JPanel WithDrawPanel=new JPanel();
JPanel TransferPanel=new JPanel();
JPanel WithDrAmPanel=new JPanel();
//------------------------------------------------------------------main Panel
static MyBank w1;
 public void mainPanel(){
        Container mainWindow=getContentPane();
        mainPanel.setBackground(new Color(50,180,250));
 
        mainPanel.setLayout(new BoxLayout(mainPanel,BoxLayout.Y_AXIS));
        //BoxLayout boxLayout1 = new BoxLayout();
 //mainPanel.setLayout(boxLayout1); 
 JButton btn1=new JButton();
 JButton btn2=new JButton();
 JButton btn3=new JButton();
 JButton btn4=new JButton();
 
 mainPanel.add(btn1);
 mainPanel.add(btn2);
 mainPanel.add(btn3);
 mainPanel.add(btn4);
 
 btn1.setFont(new java.awt.Font("Courier New", Font.BOLD, 30));
        btn1.setForeground(new Color(110, 150, 200));
        btn1.setText("Check Balance");
 btn1.setAlignmentX(Component.CENTER_ALIGNMENT);
 btn2.setFont(new java.awt.Font("Courier New", Font.BOLD, 30));
        btn2.setForeground(new Color(110, 150, 200));
        btn2.setText("Deposit");
 btn2.setAlignmentX(Component.CENTER_ALIGNMENT);
 btn3.setFont(new java.awt.Font("Courier New", Font.BOLD, 30));
        btn3.setForeground(new Color(110, 150, 200));
        btn3.setText("WithDraw");
 btn3.setAlignmentX(Component.CENTER_ALIGNMENT);
 
 btn4.setFont(new java.awt.Font("Courier New", Font.BOLD, 30));
        btn4.setForeground(new Color(110, 150, 200));
        btn4.setText("Money Transfer");
 btn4.setAlignmentX(Component.CENTER_ALIGNMENT);
 
 
 //boxLayout1.setColumns(0);
        //boxLayout1.setHgap(10);
        //boxLayout1.setRows(2);
        //boxLayout1.setVgap(10);
 btn1.addActionListener(this);
 btn2.addActionListener(this);
 btn3.addActionListener(this);
 btn4.addActionListener(this);
 }
//------------------------------------------------------------------Balance Panel
 public void BalancePanel(){
 JLabel lbl1=new JLabel("Account Balance", SwingConstants.CENTER);
 BalancePanel.add(lbl1);
 JButton btn11=new JButton("Back");
 BalancePanel.add(btn11);
 btn11.addActionListener(this);
 
 JLabel lbl10=new JLabel("Your Balance is", SwingConstants.CENTER);
 BalancePanel.add(lbl10);
 JButton btn12=new JButton("Print Account Details");
 BalancePanel.add(btn12);
 btn12.addActionListener(this);
 //lbl1.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
 BalancePanel.setBackground(new Color(205,10,110));
 }
 
//------------------------------------------------------------------Deposit Panel 
 public void DepositPanel(){
 JLabel lbl2=new JLabel("Deposit Panel");
 DepositPanel.add(lbl2);
 JLabel lbl20=new JLabel("How Much you want to Deposit");
 DepositPanel.add(lbl20);
 DepositPanel.setLayout(new BoxLayout(DepositPanel,BoxLayout.Y_AXIS));
  DepositPanel.add(new JRadioButton("500 Rs", null, true));
  DepositPanel.add(new JRadioButton("1000 Rs"));
  DepositPanel.add(new JRadioButton("2000 Rs"));
 DepositPanel.add(new JRadioButton("5000 Rs"));
  DepositPanel.add(new JRadioButton("10000 Rs"));
 DepositPanel.add(new JRadioButton("Others"));
 
 JButton btn21=new JButton("Back");
 DepositPanel.add(btn21);
 btn21.addActionListener(this);
 DepositPanel.setBackground(new Color(185,105,50));
 }
 
//------------------------------------------------------------------Withdraw Panel 
 public void WithDrawPanel(){
 JLabel lbl3=new JLabel("WithDraw Panel");
 WithDrawPanel.add(lbl3);
 JLabel lbl30=new JLabel("How Much you want to WithDraw");
 WithDrawPanel.add(lbl30);
 WithDrawPanel.setLayout(new BoxLayout(WithDrawPanel,BoxLayout.Y_AXIS));
  WithDrawPanel.add(new JRadioButton("500 Rs", null, true));
  WithDrawPanel.add(new JRadioButton("1000 Rs"));
  WithDrawPanel.add(new JRadioButton("2000 Rs"));
 WithDrawPanel.add(new JRadioButton("5000 Rs"));
  WithDrawPanel.add(new JRadioButton("8000 Rs"));
 WithDrawPanel.add(new JRadioButton("10000 Rs"));
  WithDrawPanel.add(new JRadioButton("12000 Rs"));
 WithDrawPanel.add(new JRadioButton("15000 Rs"));
  WithDrawPanel.add(new JRadioButton("20000 Rs"));
 
 JRadioButton Rbtn32=new JRadioButton("Other Amount");
 //WithDrawPanel.add(new JRadioButton("Other Amount"));
 WithDrawPanel.add(Rbtn32);
 Rbtn32.addActionListener(this);
 
 JButton btn31=new JButton("Back");
 WithDrawPanel.add(btn31);
 btn31.addActionListener(this);
 WithDrawPanel.setBackground(new Color(205,225,10));
 }
 
 public void WithDrAmPanel(){
 JLabel lbl5=new JLabel("How much, Please Input");
 WithDrAmPanel.add(lbl5);
 JButton btn51=new JButton("Back to WithDraw");
 WithDrAmPanel.add(btn51);
 btn51.addActionListener(this);
 WithDrAmPanel.setBackground(new Color(15,225,10));
 w1.pack();
 w1.setVisible(true);
 w1.setSize(500,500);
 }
//------------------------------------------------------------------Transfer Panel 
 public void TransferPanel(){
 JLabel lbl4=new JLabel("Transfer Panel");
 TransferPanel.add(lbl4);
 JButton btn41=new JButton("Back");
 TransferPanel.add(btn41);
 btn41.addActionListener(this);
 TransferPanel.setBackground(new Color(15,225,10));
 }
 
//------------------------------------------------------------------ActionEvents
//-------------------------------------------------------Withdraw Event
public void actionPerformed(ActionEvent e){
 if(e.getActionCommand()=="WithDraw"){
  getContentPane().add(w1.WithDrawPanel);
  getContentPane().remove(w1.mainPanel);
  //w1.pack();
  w1.setVisible(true);
  System.out.println("Do something");
 }
 
 if(e.getActionCommand()=="Other Amount"){
  getContentPane().add(w1.WithDrAmPanel);
  getContentPane().remove(w1.WithDrawPanel);
  //w1.pack();
  w1.setVisible(true);
  System.out.println("Withdraw");
 }
 
 if(e.getActionCommand()=="Back to WithDraw"){
  getContentPane().add(w1.WithDrawPanel);
  getContentPane().remove(w1.mainPanel);
  getContentPane().remove(w1.WithDrAmPanel);
  WithDrawPanel.setBackground(new Color(205,225,10));
  //WithDrawPanel.Rbtn32.Null
  w1.pack();
  w1.setVisible(true);
  w1.setSize(500,500);
  System.out.println("Back to Withdraw");
 } 
//-------------------------------------------------------Deposit Event    
 if(e.getActionCommand()=="Deposit"){
  getContentPane().add(w1.DepositPanel);
  getContentPane().remove(w1.mainPanel);
  //w1.pack();
  w1.setVisible(true);
  System.out.println("How to Deposit");
 } 
//-------------------------------------------------------Check Balance Event  
 if(e.getActionCommand()=="Check Balance"){
  getContentPane().add(w1.BalancePanel);
  getContentPane().remove(w1.mainPanel);
  //w1.pack();
  //w1.setDefaultLookAndFeelDecorated(true);
  w1.setVisible(true);
  System.out.println("Tell me balance"); 
 }
//-------------------------------------------------------Money Transfer Event 
 if(e.getActionCommand()=="Money Transfer"){
  getContentPane().add(w1.TransferPanel);
  getContentPane().remove(w1.mainPanel);
  //w1.pack();
  w1.setVisible(true);
  System.out.println("Money Transfer");
 
 }
//-------------------------------------------------------Back Event  
 if(e.getActionCommand()=="Back"){
  getContentPane().add(w1.mainPanel);
  getContentPane().remove(w1.BalancePanel);
  getContentPane().remove(w1.DepositPanel);
  getContentPane().remove(w1.WithDrawPanel);
  getContentPane().remove(w1.TransferPanel);
  System.out.println("I'm Back");
 mainPanel.setBackground(new Color(50,180,250));
 w1.pack();
 w1.setVisible(true);
 w1.setSize(500,500);
 } 
}
//------------------------------------------------------------------Main
public static void main(String arg[]){
 w1= new MyBank();
 w1.mainPanel();
 w1.BalancePanel();
 w1.DepositPanel();
 w1.WithDrawPanel();
 w1.WithDrAmPanel();
 w1.TransferPanel();
 w1.getContentPane().add(w1.mainPanel);
 w1.pack();
 w1.setVisible(true);
 w1.setSize(500,500);
 w1.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
 }
}

Once u run this and can identify errors:rolleyes:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.