How do i update a JTextArea?

Hey
I have a main GUI class where i can add one number to an ArrayList in an ohter class (Basket). After i added the number to the ArrayList
i can click a button to open anohter window (which is created in BasketGUI class) where a JTextArea are showing the numbers i have
added in the ArrayList.
But notthing is showing, i know the addition to the ArrayList works because it works with a System.out.println.
I have to post alot of code, so you could just skip the code and eksplain to me in generel how to update a JTextArea.
BasketGUI:
* Basket.java
* Created on 5. februar 2008, 15:29
package userclasses;
import java.util.ArrayList;
* @author  Lille mus
public class BasketGUI extends javax.swing.JFrame {
    private Basket basket;
    private Stock stock;
    private String newline = "\n";
    /** Creates new form Basket */
    public BasketGUI() {
        stock = new Stock();
        basket = new Basket();
        initComponents();
    public String showBasket(){
        ArrayList newBasket = basket.getArrayList();
        String returnBasket = "";
        for(Object item : newBasket){
            returnBasket += item+newline;
        return returnBasket;
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Indk?bskurv");
        jLabel1.setText("Indk?bskurv");
        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jTextArea1.setText(stock.printAllStockItems());
        jTextArea1.setText(showBasket());
        jScrollPane1.setViewportView(jTextArea1);
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addComponent(jLabel1))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(224, Short.MAX_VALUE))
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(20, 20, 20)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(159, Short.MAX_VALUE))
        pack();
    }// </editor-fold>
     * @param args the command line arguments
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new BasketGUI().setVisible(true);
    // Variables declaration - do not modify
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    // End of variables declaration
}This code is what happends when i click the button which adds a number to the ArrayList:
private void putInBasket(java.awt.event.ActionEvent evt) {                            
        //Integer itemId = Integer.parseInt(itemIdField.getText());
        basket.addItemToBasket(3);
        System.out.println(basket.showBasket());
    }Basket class:
* To change this template, choose Tools | Templates
* and open the template in the editor.
package userclasses;
import java.util.ArrayList;
* @author Jesper
public class Basket {
    private ArrayList<Integer> basket;
    private String returnBasket;
    private Stock stock;
    private String newline = "\n";
    public Basket(){
        basket = new ArrayList<Integer>();
        add4ItemsToBasket();
    public void addItemToBasket(int itemId){
        basket.add(itemId);
    public void add4ItemsToBasket(){
        addItemToBasket(1);
        addItemToBasket(2);
    public String showBasket(){
        for(Integer item : basket){
            returnBasket += item+newline;
        return returnBasket;
    public ArrayList getArrayList(){      
        return basket;
}Thank you!

okay... i cant figure out the logic in this. i have put this code into the BasketGUI class:
public void setBasketList(){
        basketListTextArea.append(basket.showBasket());
    }this function i call in my MainGUI here:
private void putInBasket(java.awt.event.ActionEvent evt) {                            
        //Integer itemId = Integer.parseInt(itemIdField.getText());
        basket.addItemToBasket(3);
        basketGUI.setBasketList();
        System.out.println(basket.showBasket());
    }What am i doing wrong?

Similar Messages

  • How can I update a JTextArea from another class

    I am new to Java so forgive me if this is confusing, or if I seem to be taking an overly complex route to acheiving my goal.
    I've got a JTextArea component added to a JPanel object, which is then inserted into the JFrame. I have a JMenuBar with a JMenu "file" and a JMenuItem "connect" on this same JFrame. When clicked, the actionEvent of JMenuItem "connect" calls a class "ConnectToDb" to establish a connection with the Database. On a successful connection, I want to append the String "Connection Successful" to the JTextArea component, but since the component is a part of the JPanel object, I cannot seem to get access to the JTextArea component to update it. I tried instantiating the JPanel object from within the "ConnectToDb" class and then called a method I created to set the JTextArea. No luck. Can someone give me an idea of what I need to do that would allow me to update the text of the JTextArea component from anywhere in my program? Once it has been contained in the JPanel or JFrame, can it be updated?
    This is the class that establishes the simple Db Connection
    package cjt;
    import java.io.*;
    import java.sql.*;
    * Get a database connection
    * Creation date: (04/01/2002 4:08:39 PM)
    * @author: Yaffin
    public class ConnectToDB {
    public Connection dbConnection;
    // ConnectToDB constructor
    public ConnectToDB() {
    public Connection DbConnect() {
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String sourceURL = new String("jdbc:odbc:CJTSQL");
    Connection dbConnection = DriverManager.getConnection(sourceURL, "Encryptedtest", "pass");
    System.out.println("Connection Successful\n");
    //this is where I originally tried to append "Connection Successful
    //to the JTextArea Object in WelcomePane()          
    } catch (ClassNotFoundException cnfe) {
    //user code
    System.out.println("This ain't working because of a class not found exeption/n");
    } catch (SQLException sqle) {
    //user code
    System.out.println("SQL Exception caused your DB Connection to SUCK!/n");
    return dbConnection;
    This is the JPanel that contains the JTextArea "ivjStatusArea" I am trying to update from other classes. Specifically the "ConnectToDb" class above.
    package cjt;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import javax.swing.*;
    * Build Welcome Pane
    * Creation date: (04/01/2002 3:42:50 PM)
    * @author: yaffin
    public class WelcomePane extends JPanel {
         private JTextArea ivjtxtConnect = null;
         private JLabel ivjwelcomeLbl = null;
         private JTextArea ivjStatusArea = null;
    * WelcomePane constructor comment.
    public WelcomePane() {
         super();
         initialize();
    * Return the StatusArea property value.
    * @return javax.swing.JTextArea
    private javax.swing.JTextArea getStatusArea() {
         if (ivjStatusArea == null) {
              try {
                   ivjStatusArea = new javax.swing.JTextArea();
                   ivjStatusArea.setName("StatusArea");
                   ivjStatusArea.setLineWrap(true);
                   ivjStatusArea.setWrapStyleWord(true);
                   ivjStatusArea.setBounds(15, 153, 482, 120);
                   ivjStatusArea.setEditable(false);
                   // user code begin {1}
                   // user code end
              } catch (java.lang.Throwable ivjExc) {
                   // user code begin {2}
                   // user code end
                   handleException(ivjExc);
         return ivjStatusArea;
    * Initialize the class.
    private void initialize() {
         try {
              // user code begin {1}
              // user code end
              setName("WelcomePane");
              setLayout(null);
              setSize(514, 323);
              add(getStatusArea(), getStatusArea().getName());
         } catch (java.lang.Throwable ivjExc) {
              handleException(ivjExc);
         // user code begin {2}
         // user code end
    This is the main class where evrything is brought together. Notice the BuildMenu() method where the JMenuItem "connect" is located. Also notice the PopulateTabbedPane() method where WelcomePane() is first instantiated.
    * The main application window
    * Creation date: (04/01/2002 1:31:20 PM)
    * @author: Yaffin
    public class CjtApp extends JFrame {
    private JTabbedPane tabbedPane;
    private ConnectToDB cdb;
    private Connection dbconn;
    public CjtApp() {
    super("CJT Allocation Application");
    // Closes from title bar
    //and from menu
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    tabbedPane = new JTabbedPane(SwingConstants.TOP);
    tabbedPane.setForeground(Color.white);
    //add menubar to frame
    buildMenu();
    //populate and add the tabbed pane
    populateTabbedPane(dbconn);
    //tabbedPane.setEnabledAt(1, false);
    //tabbedPane.setEnabledAt(2, false);
    getContentPane().add(tabbedPane);
    pack();
    * Build menu bar and menus
    * Creation date: (04/01/2002 2:42:54 PM)
    private void buildMenu() {
    // Instantiates JMenuBar, JMenu,
    // and JMenuItem.
    JMenuBar menubar = new JMenuBar();
    JMenu menu = new JMenu("File");
    JMenuItem item1 = new JMenuItem("Connect");
    JMenuItem item2 = new JMenuItem("Exit");
    //Opens database connection screen
    item1.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    //call the ConnectToDb class for a database connection
    ConnectToDB cdb = new ConnectToDB();
    dbconn = cdb.DbConnect();
    }); // Ends buildMenu method
    //Closes the application from the Exit
    //menu item.
    item2.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    System.exit(0);
    }); // Ends buildMenu method
    //Adds the item to the menu object
    menu.add(item1);
    menu.add(item2);
    //Adds the menu object with item
    //onto the menu bar     
    menubar.add(menu);
    //Sets the menu bar in the frame
    setJMenuBar(menubar);
    } //closes buildMenu
    public static void main(String[] args) {
    CjtApp mainWindow = new CjtApp();
    mainWindow.setSize(640, 480);
    mainWindow.setBackground(Color.white);
    mainWindow.setVisible(true);
    mainWindow.setLocation(25, 25);
    * Add tabs to the tabbedPane.
    * Creation date: (04/01/2002 2:52:19 PM)
    private void populateTabbedPane(Connection dbconn) {
         Connection dbc = dbconn;
         tabbedPane.addTab(
         "Welcome",
    null,
    new WelcomePane(),
    "Welcome to CJT Allocation Application");
         tabbedPane.addTab(
         "Processing",
    null,
    new ProcessPane(dbc),
    "Click here to process an allocation");
         tabbedPane.addTab(
         "Reporting",
    null,
    new ReportPane(),
    "Click here for reports");
    //End
    Thanks for any assistance you can provide.
    Yaffin

    Thanks gmaurice1. I appreciate the response. I believe I understand your explanation. I am clear that the calling code needs access to the WelcomPane() object. I am assuming that the constructor for the calling class must have the JPanel WelcomePane() instance passed to it as an argument. This way I can refer directly to this specific instance of the object. Is this correct?
    Also, where would you create the set method? I tried to create a set method as part of the WelcomePane() class, and then call it from the calling class, but it didn't seem to work. Lastly, a globally accessible object? Can you explain this concept briefly? Thanks again for your help.
    yaffin

  • How do I update a JTextArea dynamically?

    Hello! This is my first post, so be gentle. :-)
    I am just getting started in Java and am writing a gui app to take a list of PC's from a JTextArea on the left, and reboot them one at a time. Then on the right, in another JTextArea, output whether the reboot was successful, or couldn't ping it, etc. The trouble is, when I run the program, it steps through each PC in the list just like I want it to. Reboots them just as designed. Appends to the JTextArea just as designed. But it does not update the text area until it makes it through the entire list. If I have 100 PCs in the list, it attempts to reboot them all, then BOOM all the appends to the log text area are applied at once. Is there any way to update the text area as an attempt is made on each PC in the list?
    Here's the reboot code.
    try
         Runtime runtime = Runtime.getRuntime();
         // TODO Auto-generated method stub
         if (e.getSource() == leave)
              System.exit(0);
         else if (e.getSource() == reboot)
              StringTokenizer tokenizer = new StringTokenizer(pclist.getText() + String.valueOf(CRLF));
              //StringTokenizer tokenizer = new StringTokenizer(pclist.getText());
              //System.out.println(String.valueOf(CRLF)+ "this");
              while(tokenizer.hasMoreTokens())
                   computers.add(tokenizer.nextToken());
              log.setText("");
              //System.out.println(computers.size());
              for(int i = 0; i < computers.size(); i++)
                   try
                        Process checkpulse = runtime.exec("ping " + computers.get(i) + " -n 1");// | find '"Reply"'");
                        int checkPulseExitVal = checkpulse.waitFor();
                        //System.out.println(checkPulseExitVal);
                             if (checkPulseExitVal != 0)
                                  log.append("Unable to Ping " + computers.get(i) + "\r\n");
                                  log.revalidate();
                                  //log.setCaretPosition(i);
                             else if(checkPulseExitVal == 0)
                                  //System.out.println(computers.size());
                                  Process restart = runtime.exec("shutdown -r -t 0 -m \\\\" + computers.get(i));
                                  int restartExitVal = restart.waitFor();
                                  if (restartExitVal == 0)
                                       log.append(computers.get(i) + " Rebooted\r\n");
                                       log.revalidate();
                                       //log.validate();
                                       //log.setCaretPosition(i);
                             else
                                  log.append("Sumpin happened and I'm not sure what.\r\n");
                                  log.revalidate();
                   catch (InterruptedException e1)
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
    catch (IOException e1)
         // TODO Auto-generated catch block
         e1.printStackTrace();
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Dang...I must be doing something not quite right. I'm going to post a largeish block of code. Can you nudge me in the correct direction please? This code compiles and runs. You can just type in bogus pc names on the left and the right pane won't update until it tries to ping and reboot them all.
    package pccontrol;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.BorderLayout;
    import java.awt.event.*;
    import com.sun.java.swing.plaf.motif.MotifLookAndFeel;
    import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
    import com.sun.org.apache.xml.internal.serialize.LineSeparator;
    import java.io.*;
    import java.lang.*;
    import java.util.*;
    import java.lang.Runtime;
    public class Control extends JFrame
         //private GuiFrame fr = new GuiFrame();
         private JFrame fr = new JFrame();
         private JLabel putlist = new JLabel();
         private JMenuBar topframe = new JMenuBar();
         private JButton reboot = new JButton("Reboot 'em!");
         private JButton leave = new JButton("Exit");
         private JTextArea pclist = new JTextArea(0, 20);
         private JTextArea log = new JTextArea();
         private JScrollPane scrollPane = new JScrollPane(pclist);
         private JScrollPane logScrollPane = new JScrollPane(log);
         private JPanel pan = new JPanel();
         final ArrayList computers = new ArrayList();
         //String[] computers = new String[getRandom(50)];
         char CRLF = 13;
         private Thread thread;
         Runtime runtime = Runtime.getRuntime();
         //private Process child;
         //private String comp;
         //private String command = "shutdown";
         public Control() throws HeadlessException
              // TODO Auto-generated constructor stub
              initialize();
         public Control(GraphicsConfiguration arg0)
              super(arg0);
              // TODO Auto-generated constructor stub
              initialize();
         public Control(String arg0) throws HeadlessException
              super(arg0);
              // TODO Auto-generated constructor stub
              initialize();
         public Control(String arg0, GraphicsConfiguration arg1)
              super(arg0, arg1);
              // TODO Auto-generated constructor stub
              initialize();
          * @param args
         public static void main(final String[] args)
              // TODO Auto-generated method stub
              new Control();
         public void initialize()
              fr.getContentPane();
              pan.setLayout(new BorderLayout());
              pan.add("North", topframe);
              topframe.add(reboot);
              topframe.add(leave);
              reboot.setToolTipText("Click here to REBOOT them all!");
              //pan.add("West",pclist);
              pan.add("West", scrollPane);
              pan.add("Center", logScrollPane);
              putlist.setText("            Paste PC list below                                              ");
              topframe.add(putlist, 0,0);
              fr.add(pan);
              //pclist.setLineWrap(false);
              fr.pack();
              //Create the FrameEventHandler
              FrameEventHandler feh = new FrameEventHandler();
              //Register this Frame with feh
              addWindowListener(feh);
              //Create the button event handler.
              ButtonEventHandler beh = new ButtonEventHandler();
              reboot.addActionListener(beh);
              leave.addActionListener(beh);
              try
                   //Change the look and feel of the UI manager.
                   UIManager.setLookAndFeel(new WindowsLookAndFeel());
                   //UIManager.setLookAndFeel(new MotifLookAndFeel());
              catch (Exception e)
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              fr.setTitle("PC Control");
              fr.setSize(600, 600);
              SwingUtilities.updateComponentTreeUI(fr);
              fr.setLocation(150, 150);
              fr.setVisible(true);
         class ButtonEventHandler implements ActionListener
              public void actionPerformed(ActionEvent e)
                        //Runtime runtime = Runtime.getRuntime();
                        // TODO Auto-generated method stub
                        if (e.getSource() == leave)
                             System.exit(0);
                        else if (e.getSource() == reboot)
                             StringTokenizer tokenizer = new StringTokenizer(pclist.getText() + String.valueOf(CRLF));
                             //StringTokenizer tokenizer = new StringTokenizer(pclist.getText());
                             //System.out.println(String.valueOf(CRLF)+ "this");
                             //thread = new Thread (new Runnable()
                                  //public void run()
                             while(tokenizer.hasMoreTokens())
                                  computers.add(tokenizer.nextToken());
                             log.setText("");
                             //System.out.println(computers.size());
              final Runnable runner = (new Runnable()
                   public void run()
                        for(int i = 0; i < computers.size(); i++)
                                  try
                                       Process checkpulse = runtime.exec("ping " + computers.get(i) + " -n 1");// | find '"Reply"'");
                                       int checkPulseExitVal = checkpulse.waitFor();
                                       //System.out.println(checkPulseExitVal);
                                       if (checkPulseExitVal != 0)
                                            log.append("Unable to Ping " + computers.get(i) + "\r\n");
                                       else //(checkPulseExitVal == 0)
                                            //System.out.println(computers.size());
                                            Process restart = runtime.exec("shutdown -r -t 0 -m \\\\" + computers.get(i));
                                            int restartExitVal = restart.waitFor();
                                            if (restartExitVal == 0)
                                                 log.append(computers.get(i) + " Rebooted\r\n");
                                  catch (IOException e)
                                       // TODO Auto-generated catch block
                                       e.printStackTrace();
                                  catch (InterruptedException e)
                                       // TODO Auto-generated catch block
                                       e.printStackTrace();
                   EventQueue.invokeLater(runner);
    class FrameEventHandler extends WindowAdapter
         //Everride the method / event that you are interested in.
         public void windowClosing (WindowEvent e)
              // TODO Auto-generated method stub
              //super.windowClosing(e);
              e.getWindow().setVisible(false);
              e.getWindow().dispose();
              System.exit(0);
    }{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Trouble updating a JtextArea from a JTable ListSelectionListener..

    Hi, I'm having trouble updating a JtextArea from a JTable ListSelectionListener, it is working for another JTextArea but I have created JNMTextArea which extends JTextArea and I am getting no data passed to it.
    Any help is really greatly appreciated. Im a relative newbie to Java.
    Here is the class declaration for JNMTextArea
    public class JNMTextArea extends JTextArea
         //Constructor
         public JNMTextArea(String text){
              super(text);
              setLineWrap(true);
              setEditable(false);
         //Constructor
         public JNMTextArea()
              this(new String());
         //This sets the data in setText, works ok.
         void displayPacket(Packet p){
              //Function works fine
              //Need to pass this data to the JNMTextArea!!!
              setText(buffer.toString());
              setCaretPosition(0);
    Here is where I use JNMTextArea, Im
    class JNMGui extends JFrame implements ActionListener, WindowListener{
         public static JNMTextArea txtPktContent;
         //Constructor
              JNMGui(){
                   buildGUI();
         private void buildGUI(){
         mainWindow = new JFrame("Monitor");
         tblPacket = new JTable(tblPacketM);
         tblPacket.setToolTipText("Packet Panel");
         tblPacket.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
         if (ALLOW_ROW_SELECTION) {
              ListSelectionModel rowSM = tblPacket.getSelectionModel();
              rowSM.addListSelectionListener(new ListSelectionListener() {                     public void valueChanged(ListSelectionEvent e) {
                        if (e.getValueIsAdjusting())
                             return;
                        ListSelectionModel lsm =      (ListSelectionModel)e.getSource();
                        if (lsm.isSelectionEmpty()) {
                             System.out.println("No rows are selected.");
                        else {
                             int selectedRow = lsm.getMinSelectionIndex();
                             selectedRow++;
                             String str;// = "";
                             //Unsure if I need to create this here!
                             txtPktContent = new JNMTextArea();
                             //This works perfectly
                             txtPktType.append ( "Packet No: " + Integer.toString(selectedRow) + "\n\n");
                             Packet pkt = new Packet();
                             pkt = (Packet) CaptureEngine.packets.elementAt(selectedRow);
                             if(pkt.datalink!=null && pkt.datalink instanceof EthernetPacket){
                                  str = "Ethernet ";
                                  //THis works txtPktType is another JTextArea!!          
                                  txtPktType.append ( s );
                                  //This is not working
                                  //I realise displayPacket return type is void but how do get
                                  //the setText it created to append to the JNMTextArea??               
                                  txtPktContent.displayPacket(pkt);
              //Adding to ScrollPane
              tblPane = new JScrollPane(tblPacket);
              txtPktTypePane = new JScrollPane ( txtPktType );
              txtPktTypePane.setToolTipText("Packet Type");
              txtPktContentPane = new JScrollPane ( txtPktContent );
              txtPktContentPane.setToolTipText("Packet Payload");
              panel.add( tblPane, BorderLayout.CENTER );
    //End Class JNMGui

    void displayPacket(Packet p){
              //Function works fine
              //Need to pass this data to the JNMTextArea!!!
              setText(buffer.toString());
              setCaretPosition(0);
    This seems really odd. Notice that you pass in "p" but use "buffer". Where is "buffer" defined?

  • How do I clear a JTextArea.

    well, as the title says.
    The only info I can find in my docs is selectALL but then what do I do with it.
    I've got a search result updating the JTextArea and I want to clear it after each search.
    cheers ;)

    now i really feel like an idiot.
    cheers.
    I won't tell you how long i've been trying to work that out.No need to feel ashamed; I know those situations: after hours and hours of
    hacking and trying, you simply have to give up because during those tedious
    hours you've developed nothing but a blind spot for the obvious solution ;-)
    kind regards,
    Jos

  • How can I update my app store account ?

    Hi, I have a new Iphone and I wanted to add some applications from apple store.
    Unfortunately, I had a message saying that I was using app store on a new device (true) and they needed to check some security thing from my visa card. Unfortunately, I had a new  card and do not have the previous one anylonger (the previous one expires in 1 year but had to be cancelled).
    Therefore I am blocked and cannot get into my account.
    How can I update my bank account and get into the apple store again ?
    Thanks
    Nadiege

    Great, it worked. i could update the account from the laptop (but not from the phone).
    Many thanks for such a swift feedback !!

  • I upgraded from 3gs and want to use my old 3gs as an ipod. how can i update my new apple ID on the 3gs as it still shows a previous one that I had?

    I recently upgraded from 3Gs to Iphone4 and want to use my old 3Gs as an ipod. how can i update
    the user ID on the 3gs to a new one that I have as it is still showing a previous user ID?

    Settings>Store...tap the ID shown...sign out...sign back in with the ID you want to use.

  • How can i update data in JTable at run time ?

    i am trying to build a client/server architecture for conducting quizzes & online tests.. My client will return a object to the server after the test is over, which contains details about the participant, his score and other details. i am putting the incoming object to an Vector. I'll create a new thread each time for the incoming connection and insert the object to the Vector.. Now, please tell me tat, how can i update my table automatically at run time so tat, my table is updated whenever a new object is entered into vector..
    here is my code for the table..
    public class MyTableModel extends AbstractTableModel {
        String columNames[] = { "ID", "NAME", "COLLEGE", "SCORE", "CELL" };
        /** Creates a new instance of MyTableModel */
        public MyTableModel() {
            Main.List = new Vector();
            SetDefaultData();
        public int getRowCount() {
            return Main.List == null ? 0 : Main.List.size();
        public int getColumnCount() {
            return columNames.length;
        public String getColumnName(int column) {
            return columNames[column];
        public boolean isCellEditable(int row,int col) {
            return false;
        public Object getValueAt(int rowindex, int columnindex) {
            if(rowindex < 0 || rowindex >= getRowCount())
                return "";
            Student row = (Student)Main.List.elementAt(rowindex);
            switch (columnindex)
                case 0 : return row.id;
                case 1 : return row.name;
                case 2 : return row.college;
                case 3 : return row.score;
                case 4 : return row.cell;
            return "";
        public String getTitle() {
            return "Student Table";
        private void SetDefaultData() {
            Main.List.removeAllElements();
            Main.List.addElement(new Student("CS041","Keerthivasan M","MNM",95,"9884326321"));
            Main.List.addElement(new Student("CS012","Arun M","MNM",90,"9884825780"));
            Main.List.addElement(new Student("CS019","Balaji S","MNM",79,"9841742068"));
            Main.List.addElement(new Student("CS005","Anand R","MNM",89,"9884130727"));
            Main.List.addElement(new Student("CS045","Manish J","MNM",55,"9841624625"));
            Main.List.addElement(new Student("CS013","Mangal S","MNM",5,"9841961742"));
    }

    In the future Swing related questions should be posted in the Swing forum.
    how can i update my table automatically at run time so tat, my table is
    updated whenever a new object is entered into vector..You don't update the Vector directly. You should be creating a method in your TableModel, called "addRow(...)". This method will do two things:
    a) add the Student object to the Vector
    b) invoke the fireTableRowsInserted(..) method of AbstractTableModel. This will cause the table to be repainted.

  • Steps to put itunes (50 gb) on external drive and delete from imac.  How would I update my ipods and ipad from the external drive if I do this

    I am planning to put itunes library on external hard drive. My Imac is running out of room and itunes is 50+ gb of music.
    What steps do I take to do this.  Also, if I do so, how do I update my ipods and my ipad 2.  I do back up my files with time machine.  This would be a completely separate new external hard drive.  Thanks in advance for any help.

    Two ways:
    1. After transferring to the external drive create an alias to the iTunes Music folder on the external drive.  Copy the alias into your Home folder.  Rename the alias to "iTunes Music."  Delete the alias from the external drive.
    2. In the iTunes preferences click on the Advanced icon in the toolbar.  You should see a field labeled, "iTunes Media Folder Location."  Click on the Change button and select the /iTunes Music/ folder on the external drive.

  • I have osx 10.6.8 and safari 5.1.10, how do I update safari?

    I been using MSN.com as my homepage for some time.  Suddenly I cannot access it using the Safari browser on my iMac.  Instead I get an MSN "preview" page with a message that I am using an outdated browser.  My browser is Safari 5.1.10.  I opened the Apple Menu and chose Software Updates, but it does not provide a Safari update.  How do I update Safari and what version should I use for OSX 10.6.8? 

    Safari is now a part of OS X and there are different versions (5, 6 and 7) of it.
    To update Safari you must update OS X.

  • How can we update data in LDAP server using PL/SQL.

    Hi,
    How can we update data in LDAP server using PL/SQL program.
    Is there any sample code for refrence.
    Thanks,
    Tarun

    Hi Justin,
    Thanks for your help. You got my correct requirements.
    Tim's example returning all the attributes of current user which is admin user. Please correct me if I am wrong.
    I have the following information:
    the admin user and password,server info , port and ldap_base for admin.
    I have uid and password for regular user, I am trying find the ldap_base for regular user, which may be different from adminuser.
    Please help me.
    Thanks,
    Edited by: james. on Jan 12, 2009 5:39 PM

  • HT3576 Ok so i have this iPod touch (3rd gen) and i'm trying to update it through iTunes and when i click  check for update it keeps saying this version of iPod software (2.2.1) is your current version. what do i do? how do i update it?

    Ok so i have this iPod touch (3rd gen) and i'm trying to update it through iTunes and when i click  check for update it keeps saying this version of iPod software (2.2.1) is your current version. what do i do? how do i update it?

    You have a 1st generation iPod Touch. It can not be upgraded beyond iOS 3.1.3, it is available at the link below.
    http://support.apple.com/kb/HT2052

  • How to refresh a JPanel/JTextArea

    My main problem is that I don't know how to correctly refresh a JTextArea in an Applet. I have an Applet with 2 internal frames. Each frame is comprised of a JPanel.
    The first internal frame calls the second one as shown below:
    // Set an internal frame for Confirmation and import the Confirm class into it//
    Container CF = nextFrame.getContentPane();
    //<Jpanel>
    confirmation = new Confirmation( );
    CF.add ( confirmation, BorderLayout.CENTER );
    mFrameRef.jDesktopPane1.add(nextFrame,JLayeredPane.MODAL_LAYER);
    currentFrame.setVisible(false); // Hide this Frame
    nextFrame.setVisible(true); // Show Next Frame/Screen of Program
    confirmation (Jpanel) has a JTextArea in it. When it's called the first time it displays the correct information (based on choices from the first frame). If a user presses the back button (to return to first frame) and changes something, it doesn't refresh in the JTextArea when they call the confirmation(Jpanel) again. I used System.out.println (called right after jtextareas code), and it shows the info has indeed changed...I guess I don't know how to correctly refresh a JTextArea in an Applet. Here is the relevent code for the 2nd Internal Frame (confirmation jpanel):
    // Gather Info to display to user for confirmation //
    final JTextArea log = new JTextArea(10,35);
    log.setMargin(new Insets(5,5,5,5));
    log.setEditable(false);
    log.append("Name: " storeInfoRef.getFirstName() " "
    +storeInfoRef.getLastName() );
    log.append("\nTest Project: " +storeInfoRef.getTestProject() );
    JScrollPane logScrollPane = new JScrollPane(log);

    Here is the relevant code that I am having the problem with...
    import javax.swing.*;
    import java.awt.*;
    import java.util.*;
    public class Confirmation extends JPanel {
    // Variables declaration
    private StoreInfo storeInfoRef; // Reference to StoreInfo
    private MFrame mFrameRef; // Reference to MFrame
    private Progress_Monitor pmd; // Ref. to Progress Monitor
    private JLabel ConfirmMessage; // Header Message
    private JButton PrevButton;                // Navigation Button btwn frames
    private JInternalFrame prevFrame, currentFrame; // Ref.to Frames
    // End of variables declaration
    public Confirmation(MFrame mFrame, StoreInfo storeInfo) {
    mFrameRef = mFrame; // Reference to MFrame
    storeInfoRef = storeInfo; // Reference to Store Info
    prevFrame = mFrameRef.FileChooserFrame; // Ref. to Previous Frame
    currentFrame = mFrameRef.ConfirmationFrame; // Ref. to this Frame
    initComponents();
    // GUI for this class //
    private void initComponents() {
    ConfirmMessage = new JLabel();
    PrevButton = new JButton();
    UploadButton = new JButton();
    setLayout(new GridBagLayout());
    GridBagConstraints gridBagConstraints1;
    ConfirmMessage.setText("Please confirm that the information "
    +"entered is correct");
    add(ConfirmMessage, gridBagConstraints1);
    // Gather Info to display to user for confirmation //
    final JTextArea log = new JTextArea(10,35);
    log.setMargin(new Insets(5,5,5,5));
    log.setEditable(false);
    log.append("Name: " storeInfoRef.getFirstName() " "
    +storeInfoRef.getLastName() );
    log.append("\nTest Project: " +storeInfoRef.getTestProject() );
    log.append("\nTest Director: " +storeInfoRef.getTestDirector() );
    log.append("\nTest Location: " +storeInfoRef.getTestLocation() );
    log.append("\nDate: " +storeInfoRef.getDate() );
    String fileOutput = "";
    Vector temp = new Vector( storeInfoRef.getFiles() );
    for ( int v=0; v < temp.size(); v++ )
    fileOutput += "\n " +temp.elementAt(v);  // Get File Names
    log.append("\nFile: " +fileOutput );
    // log.repaint();
    // log.validate();
    // log.revalidate();
    JScrollPane logScrollPane = new JScrollPane(log);
    System.out.println("Name: " storeInfoRef.getFirstName() " " +storeInfoRef.getLastName() );
    System.out.println("Test Project: " +storeInfoRef.getTestProject() );
    System.out.println("Test Director: " +storeInfoRef.getTestDirector() );
    System.out.println("Test Location: " +storeInfoRef.getTestLocation() );
    System.out.println("Date: " +storeInfoRef.getDate() );
    System.out.println("File: " +fileOutput );
    // End of Gather Info //
    add(logScrollPane, gridBagConstraints1);
    PrevButton.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(java.awt.event.MouseEvent evt) {
    PrevButtonMouseClicked(evt);
    PrevButton.setText("Back");
    JPanel Buttons = new JPanel();
    Buttons.add(PrevButton);
    add(Buttons, gridBagConstraints1);
    // If User Presses 'Prev' Button //
    private void PrevButtonMouseClicked(java.awt.event.MouseEvent evt) {
    try
    currentFrame.setVisible(false); // Hide this Frame
    prevFrame.setVisible(true); // Show Next Frame/Screen of Program
    catch ( Throwable e ) // If A Miscellaneous Error
    System.err.println( e.getMessage() );
    e.printStackTrace( System.err );
    }// End of Confirmation class

  • How do I update my ipod touch with my  new email address for my  itunes account?

    How do I update my ipod touch with my new email address for my itunes account?  I recently changed my email address and updated it on my itunes account but now my ipod keeps asking me for the password associated with my old email address.

    I did this and I still get a error message about either the
    password or the email account is incorrect!

  • How do I update my Macbook Air 10.6.8 to a newer version?

    How do i update my Macbook Air 10.6.8 to a newer version

    Open the Mac App Store and try downloading Mavericks. If you get told it's incompatible, choose About this Mac from the Apple menu, click here, and order a download code for Lion 10.7.
    Mac OS X 10.7 and newer don't support PowerPC programs such as Microsoft Office 2004.
    (97791)

Maybe you are looking for

  • Getting selected row values of a classic report

    Hi Guys, i'm using Apex 4.1, I have a classic report on my apex page. First column of this report is check box for row selection. and its binded to primary key of a table. i know that i can get the selected row's primary key (Check box value) using A

  • How can you tell where the time source is on solaris 9?

    we have a time synch issue that needs resolving and I have to check where each server involved gets its time from. I know in windows you just run a query of net time /querysntp what do you do on solaris 9?

  • Smartform: Problem with pages -  some do not load

    Hi, I am developing a 5 page Smart Form. Currently 1 page has been developed, with all 5 having the same header (1 logo and 3 windows). The 1st page has 1 main window and the 2nd page has another. Every page will have a different main window. The pro

  • I can't get Creative Cloud to download

    When I try to download the Creative Cloud trial version the download appears to start but just disappears without downloading anything. I've tried several times and always get the same results - basically nothings happens.  I'm on a Windows 8.1 box a

  • Ipad 2 backlight patches on white

    My ipad2 display features the slight patches and spots seen only on white or light grey areas. When I scroll the text on white pages the text moves while the screen patches are still. It looks a little bit like the dirty screen on some iMac displays.