I have a class that has a text area. the code is as follows

package view;

import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;

public class LabelStatus extends JPanel {
    private static final long serialVersionUID = 1L;
    JFrame frame; 
    public static JTextArea test;
    JLabel title;

    public LabelStatus() {
        JLabel title = new JLabel ("INCOMING MESSAGES  ",JLabel.CENTER);
        title.setFont(new Font ("Serif", Font.BOLD,30));
        GridBagConstraints k = new GridBagConstraints();       
        k.gridx = 10;
        k.gridy = 10; 
        test = new JTextArea(60,60);

        JScrollPane spane = new JScrollPane(test);
        GridBagLayout gbl = new GridBagLayout(); 
        JPanel panel = new JPanel(gbl);

    public static void writetext(){

        test.setText("I have a message ");



In this situation I want to write some thing I use the writetext method. I want to write in this place from another class.

that is as follows

package control;

import generated.IMaritimeRadarControlCommand;

import generated.IMaritimeRadarControlState;
import generated.IMaritimeRadarTrackUpdates;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

import org.apache.log4j.Logger;

import view.LabelStatus;

public class CommandSubscriber implements MessageListener {
    IMaritimeRadarControlCommand mradarcontrolcommand;
     * Logger
    private static final Logger logger = Logger.getLogger(CommandSubscriber.class);

    private PluginTester plugin;

    public CommandSubscriber(final PluginTester plugin) {
        this.plugin = plugin;


     * Overwritten method.
     * Called from JMS to handle control command.
     * @param message Received message
    public final void onMessage(final Message message) {

        logger.info("entering onMessage()");
            if (message instanceof TextMessage) {
                TextMessage textMsg = (TextMessage) message;

                String type = null;
                try {
                  type = textMsg.getStringProperty("TYPE");
                } catch (JMSException e) {
                    // TODO Auto-generated catch block
                String xml = null;
                try {
                    xml = textMsg.getText();
                } catch (JMSException e) {
                    // TODO Auto-generated catch block

                logger.info("received message: '" + xml);

                if (type.equals("MaritimeRadarControlCommand")) {
                    System.out.println("\n SENDING THE MESSAGE TO LABEL STATUS");


                else {
                    logger.warn("Unknown TextMessage received. type: " + type);
     * @return PluginTester for xml schema for jaxb unmarshalling
    public final PluginTester getPlugin() {
        return plugin;
    //  logger.info("leaving onMessage()");

You can see

that in the onMessage method I call the writetext method of the labelStatus class. But it does not work. Let me know how to work with it.

Recommended Answers

All 4 Replies

it does not work.

Can you explain? If there are error messages, please post them.

hello Norm R1 the problem is it does not do anything. it suppose to write that string on the text field.There is no error message, it seems like that it is just not there I mean LabelStatus.writetext() just does not execute. If I print it on the System out it works.


Can you make a testing program without the third party packages the compiles, executes and shows the problem?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.