Problem related to JApplet with Swing Interface.

I have used 10 JButton and 1 JTextPane(text area) on one JContentPane.Now I want that when i will press one button then cursor goes to text area and i will enter information on text area and this text data have to stored and referenced with that pressed button, then when i will press on other button then text area will become clear and i will enter information on text area and this data also store and referenced with this second one. Now when i will presss that first button then by default that stored text data will have to enter in text area means i can see text data related to first pressed button on text area when i will again press on it. So how can i do this ? i want to map one text area with 9 JButton. I am sending my applet class file with this question so please refer this for reference.

import java.applet.AppletContext;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.util.StringTokenizer;
import java.util.Vector;
import javax.swing.*;
import javax.swing.text.*;

public class GBAJTP1 extends JApplet
    implements ActionListener, MouseListener
{
       //String ButtonLabel = null;

       public GBAJTP1()
    {
        antiButton = new JButton("Anticipated Conclusion");
        titleButton = new JButton("Title of Question Diagram");
        mainButton = new JButton("Primary predictor variable");
        outButton = new JButton("Outcome");
        inclButton = new JButton("Inclusion Criteria");
        exclButton = new JButton("Exclusion Criteria");
        slitButton = new JButton("Suggested Literature");
        sfundButton = new JButton("Suggested Sources Of Funding");
        sgenButton = new JButton("General Comments");
        confButton = new JButton("Confounder");
            //ButtonLabel = new JButton("");
        /*url1 = null;
        urlc1 = null;
        db_name = "";
        URLtxt = null; */
        fontb = new Font("Arial", 1, 12);
            
    }

      public void init()
      {
             //URLtxt = readTextFromJar("url.txt");
             ac = getAppletContext();
             Con = getContentPane();
             Con.setBackground(new Color(51, 102, 153));
         Con.setLayout(null);
         setSize(500, 550);
         f = new Font("Verdana", 1, 10);
         fgColor = Color.lightGray;
             titleButton.setFont(fontb);
         titleButton.setBackground(fgColor);
         titleButton.setBounds(1, 1, 178, 25);
             Con.add(titleButton);
             titleButton.addActionListener(this);
             antiButton.setToolTipText("<html>Please enter what, in your opinion , will be <br> the most likely conclusion of this study.</html>");
         antiButton.setFont(fontb);
         antiButton.setBackground(fgColor);
         antiButton.setBounds(179, 1, 178, 25);
             Con.add(antiButton);
             antiButton.addActionListener(this);
             mainButton.setToolTipText("<html>Please enter either the risk factor for the <br>outcome or the treatment for the condition</html>");
             mainButton.setFont(fontb);
             mainButton.setBackground(fgColor);
             mainButton.setBounds(357, 1, 178, 25);
             Con.add(mainButton);
             mainButton.addActionListener(this);
             outButton.setToolTipText("<html>Please enter the main outcomes resulting from<br> exposure to the risk factor or results from the treatment</html>");
             outButton.setFont(fontb);
         outButton.setBackground(fgColor);
         outButton.setBounds(1, 26, 178, 25);
             Con.add(outButton);
             outButton.addActionListener(this);
             confButton.setToolTipText("<html>Please enter the main factors that may affect the <br>association between the main effects and outcomes</html>");
         confButton.setFont(fontb);
         confButton.setBackground(fgColor);
         confButton.setBounds(179, 26, 178, 25);
         Con.add(confButton);
             confButton.addActionListener(this);
             inclButton.setToolTipText("<html>Please enter very specific inclusion and exclusion criteria <br>adding information to the variables present in the database<br> For example:If your patient population should be restricted <br> to persons with age greater than 65 years old, select the variable  <br>corresponding to age and then add greater than 65 years old. <br>If the patient population should only include certain diagnosis<br> or procedures, select the variable corresponding to the diagnosis<br> and procedure and then select the specific ICD or CPT<br> code using the searching engine at the bottom of the page.</html>");
         inclButton.setFont(fontb);
         inclButton.setBackground(fgColor);
         inclButton.setBounds(357, 26, 178, 25);
         Con.add(inclButton);
             inclButton.addActionListener(this);
             String s = "<html>Please enter very specific inclusion and exclusion criteria adding <br>informationto the variables present in the database. For example:<br>If your patient population should be restricted . to persons with age  <br>greater than 65 years old select the variable,corresponding to age and <br> then add \uFFFDgreater than 65 years old If the patient population should <br>  only include certain diagnosis. or procedures, select the variable      <br>corresponding tothe diagnosis and procedure and then select the specific .<br>  ICD or CPT code using the searching engine at the bottom of the page.</html>";
         exclButton.setToolTipText(s);
         exclButton.setFont(fontb);
         exclButton.setBackground(fgColor);
         exclButton.setBounds(1, 51, 267, 25);
         Con.add(exclButton);
             exclButton.addActionListener(this);
             slitButton.setToolTipText("<html>Please add any references that may help us better understand your.<br>clinical question and/or serve as background for the analysis and.<br>writing. Please also add any comments about the.literature that may <br>be helpful.</html>");
         slitButton.setFont(fontb);
         slitButton.setBackground(fgColor);
         slitButton.setBounds(268, 51, 267, 25);
         Con.add(slitButton);
             slitButton.addActionListener(this);
             String s1 = "<html>Please add any other comments about the <br>research question you have formulated.</html>";
         sfundButton.setToolTipText(s1);
         sfundButton.setFont(fontb);
         sfundButton.setBackground(fgColor);
         sfundButton.setBounds(1, 76, 267, 25);
         Con.add(sfundButton);
             sfundButton.addActionListener(this);
             sgenButton.setToolTipText("<html>Please add any other comments about the <br>research Question you have formulated</html>");
         sgenButton.setFont(fontb);
         sgenButton.setBackground(fgColor);
         sgenButton.setBounds(268, 76, 267, 25);
         Con.add(sgenButton);
             sgenButton.addActionListener(this);
             titleArea = new JTextPane();
         titleArea.setBackground(Color.white);
         JScrollPane jscrollpane = new JScrollPane(titleArea);
         jscrollpane.setBounds(1, 101, 532, 417);
         Con.add(jscrollpane);
             dtitleArea = titleArea.getDocument();
             titleStyle = new SimpleAttributeSet();
         titlePara = new SimpleAttributeSet();
         StyleConstants.setAlignment(titlePara, 1);
         StyleConstants.setFontFamily(titleStyle, "Verdana");
         StyleConstants.setFontSize(titleStyle, 10);
         StyleConstants.setBold(titleStyle, true);

         try
         {
            titleArea.setParagraphAttributes(titlePara, true);
         }
         catch(Exception exception1) { }
         StyleConstants.setBold(titleStyle, false);
             titleArea.addMouseListener(this);
             save = new JButton("Save Question Diagram");
         save.setFont(fontb);
         save.setBackground(Color.yellow);
         save.setToolTipText("Click to Save Question Diagram");
         save.setBounds(30, 520, 180, 25);
         Con.add(save);
         view = new JButton("View Question Diagram");
         view.setFont(fontb);
         view.setBackground(Color.yellow);
         view.setToolTipText("Click to View Question Diagram in Browser");
         view.setBounds(300, 520, 180, 25);
             Con.add(view);
         save.addActionListener(this);
         view.addActionListener(this);

      }
      
      public void mouseClicked(MouseEvent mouseevent)
    {
        qd_var_name = mouseevent.getSource();
            
            //titleArea.setText(qd_var_name.getLabel());
            //titleArea.gotFocus();
    }
      
       public void mousePressed(MouseEvent mouseevent)
    {
    }

    public void mouseReleased(MouseEvent mouseevent)
    {
    }

    public void mouseEntered(MouseEvent mouseevent)
    {
    }

    public void mouseExited(MouseEvent mouseevent)
    {
    }
      void backGround()
      {
            fgColor = Color.lightGray;
            titleButton.setBackground(fgColor);
            titleButton.setForeground(Color.black);
            antiButton.setBackground(fgColor);
            antiButton.setForeground(Color.black);
            mainButton.setBackground(fgColor);
            mainButton.setForeground(Color.black);
            outButton.setBackground(fgColor);
            outButton.setForeground(Color.black);
            inclButton.setBackground(fgColor);
            inclButton.setForeground(Color.black);
            exclButton.setBackground(fgColor);
            exclButton.setForeground(Color.black);
            slitButton.setBackground(fgColor);
            slitButton.setForeground(Color.black);
            sfundButton.setBackground(fgColor);
            sfundButton.setForeground(Color.black);
            sgenButton.setBackground(fgColor);
            sgenButton.setForeground(Color.black);
            confButton.setBackground(fgColor);
            confButton.setForeground(Color.black);
      }
      /*void SetBackGround(ButtonLabel)
      {
            ButtonLabel.setBackground(new Color(51, 102, 153));
            ButtonLabel.setForeground(Color.white);
      }*/
      public void actionPerformed(ActionEvent actionevent)
    {
            titleArea.requestFocus();
            
            if(actionevent.getSource().equals(titleButton))
            {
                  titleArea.setText("You have pressed "+titleButton.getText());
                  backGround();
                  titleButton.setBackground(new Color(51, 102, 153));
                  titleButton.setForeground(Color.white);
            }
            else if (actionevent.getSource().equals(antiButton))
            {
                  titleArea.setText("You have pressed "+antiButton.getText());
                  backGround();
                  antiButton.setBackground(new Color(51, 102, 153));
                  antiButton.setForeground(Color.white);
            }
            else if (actionevent.getSource().equals(mainButton))
            {
                  titleArea.setText("You have pressed " +mainButton.getText());
                  backGround();
                  mainButton.setBackground(new Color(51, 102, 153));
                  mainButton.setForeground(Color.white);
            }
            else if (actionevent.getSource().equals(outButton))
            {
                  titleArea.setText("You have pressed " +outButton.getText());
                  backGround();
                  outButton.setBackground(new Color(51, 102, 153));
                  outButton.setForeground(Color.white);
            }
            else if (actionevent.getSource().equals(inclButton))
            {      
                  titleArea.setText("You have pressed " +inclButton.getText());
                  backGround();
                  inclButton.setBackground(new Color(51, 102, 153));
                  inclButton.setForeground(Color.white);
            }
            else if (actionevent.getSource().equals(exclButton))
            {
                  titleArea.setText("You have pressed " +exclButton.getText());
                  backGround();
                  exclButton.setBackground(new Color(51, 102, 153));
                  exclButton.setForeground(Color.white);
            }
            else if (actionevent.getSource().equals(slitButton))
            {
                  titleArea.setText("You have pressed " +slitButton.getText());
                  backGround();
                  slitButton.setBackground(new Color(51, 102, 153));
                  slitButton.setForeground(Color.white);
            }
            else if (actionevent.getSource().equals(sfundButton))
            {
                  titleArea.setText("You have pressed " +sfundButton.getText());
                  backGround();
                  sfundButton.setBackground(new Color(51, 102, 153));
                  sfundButton.setForeground(Color.white);
            }
            else if (actionevent.getSource().equals(sgenButton))
            {
                  titleArea.setText("You have pressed " +sgenButton.getText());
                  backGround();
                  sgenButton.setBackground(new Color(51, 102, 153));
                  sgenButton.setForeground(Color.white);
            }
            else if (actionevent.getSource().equals(confButton))
            {
                  titleArea.setText("You have pressed " +confButton.getText());
                  backGround();
                  confButton.setBackground(new Color(51, 102, 153));
                  confButton.setForeground(Color.white);
            }
                              
            
      }
      JButton antiButton;
    JButton titleButton;
    JButton mainButton;
    JButton outButton;
    JButton inclButton;
    JButton exclButton;
    JButton slitButton;
    JButton sfundButton;
    JButton sgenButton;
    JButton confButton;
      JButton ButtonLabel;
    JPanel titlePanel;
      JButton save;
    JButton view;
      Color fgcolor;
      Font f;
      Font fontb;
    Container Con;
    Color fgColor;
      AppletContext ac;
      Object qd_var_name;
      JTextPane titleArea;
    Document dtitleArea;
      MutableAttributeSet titleStyle;
    MutableAttributeSet titlePara;
}
prajapativijayAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

prajapativijayAuthor Commented:
It's a very very importent question and i want solution for this very urgentely.
0
monkesdbCommented:
never ever post your whole code

narrow it down. make it academic and not a debugging exercise.

firstly you're very very little so we'll go slow shall we.

String TheStoredString;

...

TheStoredString = TheTextBox.getText();

...

TheTextBox.setText(TheStroedString);


now go crawl back under that rock and NEVER POST YOUR WHOLE CODE AGAIN.

newb
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.