DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4
  1. #1
    Join Date
    May 2005

    Swing into oblivion

    I have 2 threads (i think) on Swing, so i thought i might as well put all my Swings questions into 1 thread.. (sorry moderators for the extra threads)

    I have read Absolute Java by Walter Savitch, but his chapters on Swing and GUI are very basic and the googling my queries did not help, so heres the situation...

    I have created an application to solve the travelling salesman problem using breadth first search. Now i want to create a GUI for it..i understand how to create a basic GUI, with buttons panels frames etc...but there is still more i need to know...

    How do i transfer all the outputs that was previously sent to dos prompt into my GUI?

  2. #2
    Join Date
    Aug 2005
    Since you already know how to create the GUI stuff you can add a panel and a text area component to it and simple replace all of your System.out.println(stuff_to_print) with for example:

    JTextArea txt = new JTextArea(); //using swing

  3. #3
    Join Date
    May 2005
    But the thing is, my TextArea would b in my GUI class..and my System.out.printlns are scattered across other classes...

    I have tried the same way using label. I set the labelin my GUI class as static
    public static JLabel displayPanel=new JLabel ();
    so that other classes can access it through...
    GUI.displayLabel.setText("bla bla")
    and i tried changing all my System.outs into the code above...

    But it doesn't work...the display label does not change....

  4. #4
    Join Date
    Aug 2005
    Quote Originally Posted by Ant_Magma
    But the thing is, my TextArea would b in my GUI class..and my System.out.printlns are scattered across other classes...
    You could try making a GuiInterface class for example, where it would handle all of the printing, so you could replace your System.out.println() with GuiInterface.printMessage(String messageToPrint), and make this method be the one in charge of appending it to the textarea. This way, you wouldn't have to modify all of your original classes if you choose to go back to printing into the terminal, since all you would have to do would be rewrite you GuiInterface class.

Similar Threads

  1. Swing is dead, long live SWT
    By Darren Bell in forum Talk to the Editors
    Replies: 2
    Last Post: 09-20-2002, 10:32 AM
  2. Replies: 3
    Last Post: 09-16-2002, 08:15 PM
  3. swing Components
    By Valarmathy in forum Java
    Replies: 0
    Last Post: 01-19-2002, 05:35 AM
  4. Using Swing with JSP
    By Shaun Botha in forum Java
    Replies: 5
    Last Post: 06-25-2001, 09:19 PM
  5. VisualCafe3Pro and Swing 1.1.1?
    By Fabio Luis De Paoli in forum Java
    Replies: 0
    Last Post: 08-17-2000, 01:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.