Advertisement

04.24.2007 at 12:43PM PDT, ID: 22531491
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

Send text to text area in GUI

Asked by MrManderson in Programming Languages, New to Java Programming

Tags: , , ,

Hi all,

I am looking to print text to a textarea within a scrollableTextArea in my GUI how could I do this from another class ?

GUI Class
____________________________________________________________

import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public abstract class GUI extends JFrame implements ActionListener
{
     /**
     * Create the GUI and show it.  For thread safety,
     * this method should be invoked from the
     * event-dispatching thread.
     */
   
    private Rooms currentRoom;
   
        public static void createAndShowGUI() {
        //Make sure we have nice window decorations.
        JFrame.setDefaultLookAndFeelDecorated(false);
       
        //Create and set up the window.
        JFrame frame = new JFrame("World Of Steve");
        frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
     
        //Create panel to house objects.
        JPanel panel = new JPanel(null);
       
        //Add buttons to GUI
        JButton N = new JButton("North");
        JButton S = new JButton("South");
        JButton E = new JButton("East");
        JButton W = new JButton("West");
       
        //Set button locations x,y,w,h
        N.setBounds(150, 10, 70, 20);
        S.setBounds(150, 140, 70, 20);
        E.setBounds(170, 120, 70, 20);
        W.setBounds(10, 120, 70, 20);
       
        //Add labels to GUI
        JLabel lblLocationCaption    = new JLabel("Current Location is: ");
        JLabel lblCurrentLocation   = new JLabel();
        JLabel lblExits   = new JLabel("Exits;");
       
        //Add Main Text Area
        JTextArea textArea = new JTextArea();
        JScrollPane scrollableTextArea = new JScrollPane(textArea);
       
        //Set textarea location
        scrollableTextArea.setBounds(160, 30, 380, 400);
       
        //Set label locations x,y,w,h
        lblLocationCaption.setBounds(5, 5, 150, 20);
        lblCurrentLocation.setBounds(155, 5, 150, 20);
        lblExits.setBounds(5, 30, 50, 20);
       
        //Add objects to panel to display in frame
        panel.add(N);
        panel.add(S);
        panel.add(E);
        panel.add(W);
        panel.add(lblLocationCaption);
        panel.add(lblCurrentLocation);
        panel.add(lblExits);
        panel.add(scrollableTextArea);
        frame.getContentPane().add(panel);

        //Display the window.
        int width = 700;
        int height = 500;
        frame.setSize(width, height);
        frame.show();
        frame.setVisible(true);
    }
   
        // Create an action
        Action N = new AbstractAction("North") {
        // This method is called when the button is pressed
        public void actionPerformed(ActionEvent evt) {
            System.out.println("North hs been pressed via GUI");
        }
    };
   
}


Many Thanks
SteveStart Free Trial
[+][-]04.24.2007 at 12:59PM PDT, ID: 18969016

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Programming Languages, New to Java Programming
Tags: text, send, area, how
Sign Up Now!
Solution Provided By: Jathrek
Participating Experts: 2
Solution Grade: A
 
 
[+][-]04.24.2007 at 06:50PM PDT, ID: 18970933

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.24.2007 at 08:56PM PDT, ID: 18971330

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04.24.2007 at 10:46PM PDT, ID: 18971600

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04.25.2007 at 11:20AM PDT, ID: 18975982

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.25.2007 at 12:16PM PDT, ID: 18976409

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.25.2007 at 02:30PM PDT, ID: 18977534

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.25.2007 at 11:48PM PDT, ID: 18979614

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-44