How I can get output from 1st frame textfield input text to 2nd frame textArea

Posted by soulgreen on Stack Overflow See other posts from Stack Overflow or by soulgreen
Published on 2010-04-24T08:56:19Z Indexed on 2010/04/24 9:03 UTC
Read the original article Hit count: 271

Filed under:
|
|

Here is my 1st frame - I want went I input text in textfield example name then click button report will display output to 2nd frame using textArea... please help me

import java.awt.; import java.awt.event.; import javax.swing.; import javax.swing.border.;

public class Order extends JFrame implements ActionListener {

private JPanel pInfo,pN, pIC, pDate,Blank,pBlank, button, pTotal;

private JLabel nameL,icL,DateL;

private JTextField nameTF, icTF;

private JFormattedTextField DateTF;

private JButton calB,clearB,exitB,reportB;


public Order()
{
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.setBackground(Color.gray);


      pInfo             = new JPanel();     

      pN                = new JPanel();
      pIC               = new JPanel();
      pDate             = new JPanel();


        nameTF      = new JTextField(30);
        icTF        = new JTextField(30);    
        DateTF      = new JFormattedTextField(java.util.Calendar.getInstance().getTime());
        DateTF.setEditable (false);
        DateTF.addActionListener(this);


    nameL      = new JLabel(" NAME : ",SwingConstants.RIGHT);
    icL        = new JLabel(" IC   :   ",SwingConstants.RIGHT);
    DateL      = new JLabel(" DATE :",SwingConstants.RIGHT);


    pInfo.setLayout(new GridLayout(10,2,5,5));

    pInfo.setBorder(BorderFactory.createTitledBorder
    (BorderFactory.createEtchedBorder(),"ORDER"));


    pN.add(nameL); 
    pN.add(nameTF);

    pIC.add(icL); 
    pIC.add(icTF);

    pDate.add(DateL);
    pDate.add(DateTF);


  pInfo.add(pN);
    pInfo.add(pIC);
    pInfo.add(pDate);


    pInfo.setBackground(Color.GRAY);

    pN.setBackground(Color.gray);    
    pIC.setBackground(Color.gray);
    pDate.setBackground(Color.gray);

    nameL.setForeground(Color.black); 
    icL.setForeground(Color.black); 
    DateL.setForeground(Color.black); 

    nameTF.setBackground(Color.pink);
    icTF.setBackground(Color.pink);
    DateTF.setBackground(Color.pink);


      contentPane.add(pInfo,BorderLayout.CENTER);



    Blank   = new JPanel();
    pBlank  = new JPanel();
    button  = new JPanel();

    calB = new JButton("CALCULATE");
    calB.setToolTipText("Click to calculate");

    clearB  = new JButton("RESET");
    clearB.setToolTipText("Click to clear");

        reportB = new JButton ("REPORT");
        reportB.setToolTipText ("Click to print");

    exitB   = new JButton("EXIT");
    exitB.setToolTipText("Click to exit");

    Blank.setLayout(new GridLayout(2,2));

    Blank.setBorder(BorderFactory.createTitledBorder
    (BorderFactory.createEtchedBorder(),""));

        button.setLayout(new GridLayout(1,4));

        button.add(calB,BorderLayout.WEST);
        button.add(clearB,BorderLayout.CENTER);
        button.add(reportB,BorderLayout.CENTER);
        button.add(exitB,BorderLayout.EAST);

        Blank.add(pBlank); 
        Blank.add(button);   

  contentPane.add(Blank,BorderLayout.SOUTH);    


    Blank.setBackground(Color.gray);
    pBlank.setBackground(Color.gray);

    calB.setForeground(Color.black);
    clearB.setForeground(Color.black);
    reportB.setForeground(Color.black);
    exitB.setForeground(Color.black);
    calB.setBackground(Color.pink);
    clearB.setBackground(Color.pink);
    reportB.setBackground(Color.pink);        
    exitB.setBackground(Color.pink);          


        calB.addActionListener(this);
        clearB.addActionListener(this);
        reportB.addActionListener(this);
        exitB.addActionListener(this);

}


   public void actionPerformed(ActionEvent p)
    {

     if (p.getSource() == calB)
    {
    }   

else if (p.getSource() == clearB)
{
}

else if (p.getSource () == reportB)
{

}

else if (p.getSource() == exitB)
    {
    }

}

public static void main (String [] args)
    {

    Order frame = new Order();
    frame.setTitle("Order");
    frame.setSize(500,500);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setResizable(false);
    frame.setVisible(true);
    frame.setLocationRelativeTo(null);//center the frame
}

}

© Stack Overflow or respective owner

Related posts about java

Related posts about gui