Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Problem related to JApplet with Swing Interface.

Posted on 2003-11-11
Medium Priority
Last Modified: 2008-03-17
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));
         setSize(500, 550);
         f = new Font("Verdana", 1, 10);
         fgColor = Color.lightGray;
         titleButton.setBounds(1, 1, 178, 25);
             antiButton.setToolTipText("<html>Please enter what, in your opinion , will be <br> the most likely conclusion of this study.</html>");
         antiButton.setBounds(179, 1, 178, 25);
             mainButton.setToolTipText("<html>Please enter either the risk factor for the <br>outcome or the treatment for the condition</html>");
             mainButton.setBounds(357, 1, 178, 25);
             outButton.setToolTipText("<html>Please enter the main outcomes resulting from<br> exposure to the risk factor or results from the treatment</html>");
         outButton.setBounds(1, 26, 178, 25);
             confButton.setToolTipText("<html>Please enter the main factors that may affect the <br>association between the main effects and outcomes</html>");
         confButton.setBounds(179, 26, 178, 25);
             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.setBounds(357, 26, 178, 25);
             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.setBounds(1, 51, 267, 25);
             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.setBounds(268, 51, 267, 25);
             String s1 = "<html>Please add any other comments about the <br>research question you have formulated.</html>";
         sfundButton.setBounds(1, 76, 267, 25);
             sgenButton.setToolTipText("<html>Please add any other comments about the <br>research Question you have formulated</html>");
         sgenButton.setBounds(268, 76, 267, 25);
             titleArea = new JTextPane();
         JScrollPane jscrollpane = new JScrollPane(titleArea);
         jscrollpane.setBounds(1, 101, 532, 417);
             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);

            titleArea.setParagraphAttributes(titlePara, true);
         catch(Exception exception1) { }
         StyleConstants.setBold(titleStyle, false);
             save = new JButton("Save Question Diagram");
         save.setToolTipText("Click to Save Question Diagram");
         save.setBounds(30, 520, 180, 25);
         view = new JButton("View Question Diagram");
         view.setToolTipText("Click to View Question Diagram in Browser");
         view.setBounds(300, 520, 180, 25);

      public void mouseClicked(MouseEvent mouseevent)
        qd_var_name = mouseevent.getSource();
       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;
      /*void SetBackGround(ButtonLabel)
            ButtonLabel.setBackground(new Color(51, 102, 153));
      public void actionPerformed(ActionEvent actionevent)
                  titleArea.setText("You have pressed "+titleButton.getText());
                  titleButton.setBackground(new Color(51, 102, 153));
            else if (actionevent.getSource().equals(antiButton))
                  titleArea.setText("You have pressed "+antiButton.getText());
                  antiButton.setBackground(new Color(51, 102, 153));
            else if (actionevent.getSource().equals(mainButton))
                  titleArea.setText("You have pressed " +mainButton.getText());
                  mainButton.setBackground(new Color(51, 102, 153));
            else if (actionevent.getSource().equals(outButton))
                  titleArea.setText("You have pressed " +outButton.getText());
                  outButton.setBackground(new Color(51, 102, 153));
            else if (actionevent.getSource().equals(inclButton))
                  titleArea.setText("You have pressed " +inclButton.getText());
                  inclButton.setBackground(new Color(51, 102, 153));
            else if (actionevent.getSource().equals(exclButton))
                  titleArea.setText("You have pressed " +exclButton.getText());
                  exclButton.setBackground(new Color(51, 102, 153));
            else if (actionevent.getSource().equals(slitButton))
                  titleArea.setText("You have pressed " +slitButton.getText());
                  slitButton.setBackground(new Color(51, 102, 153));
            else if (actionevent.getSource().equals(sfundButton))
                  titleArea.setText("You have pressed " +sfundButton.getText());
                  sfundButton.setBackground(new Color(51, 102, 153));
            else if (actionevent.getSource().equals(sgenButton))
                  titleArea.setText("You have pressed " +sgenButton.getText());
                  sgenButton.setBackground(new Color(51, 102, 153));
            else if (actionevent.getSource().equals(confButton))
                  titleArea.setText("You have pressed " +confButton.getText());
                  confButton.setBackground(new Color(51, 102, 153));
      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;
Question by:prajapativijay
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Author Comment

ID: 9728426
It's a very very importent question and i want solution for this very urgentely.

Accepted Solution

monkesdb earned 700 total points
ID: 9728517
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();



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


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question