Problem related to JApplet with Swing Interface.

Posted on 2003-11-11
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.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 350 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse apache tomcat admin console 52 156
tomcat startup error 5 136
Is Applet the way to go for my drag and drop system? 8 36
What browser will run Java? 7 128
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

730 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