Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Java
  4. Java GUI

Java GUI

Scheduled Pinned Locked Moved Java
javahelptutoriallearning
9 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dirk Higbee
    wrote on last edited by
    #1

    I have done a lot of research and am currently learning Java in college, but I am having trouble displaying a program in a Java GUI. I know I can use JPanel, etc. but can't see how to just make my already written program display in a window without rewriting a whole bunch of my program. I think I am having a super brain fart. I am not asking for code, I am asking for ideas or direction to study content. I have Googled and Yahooed till I am blue in the face and cannot seem to get this. I am using Notepad by the way not NetBeans. Any help is much appreciated. Thank you.

    My reality check bounced.

    C L 2 Replies Last reply
    0
    • D Dirk Higbee

      I have done a lot of research and am currently learning Java in college, but I am having trouble displaying a program in a Java GUI. I know I can use JPanel, etc. but can't see how to just make my already written program display in a window without rewriting a whole bunch of my program. I think I am having a super brain fart. I am not asking for code, I am asking for ideas or direction to study content. I have Googled and Yahooed till I am blue in the face and cannot seem to get this. I am using Notepad by the way not NetBeans. Any help is much appreciated. Thank you.

      My reality check bounced.

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      It's very difficult to answer such a question because it depends a lot of how your code is written. What do you have actually ? A simple console application that you would like to replace by a GUI application ? If yes, you will probably need to rewrite a lot of your code, unless you made a clear separation between the "logic" of your program and the "presentation". If that's the case, you'll need to rewrite the "presentation" part of your code and leave the "logic" untouched.

      Cédric Moonen Software developer
      Charting control [v3.0] OpenGL game tutorial in C++

      D 1 Reply Last reply
      0
      • D Dirk Higbee

        I have done a lot of research and am currently learning Java in college, but I am having trouble displaying a program in a Java GUI. I know I can use JPanel, etc. but can't see how to just make my already written program display in a window without rewriting a whole bunch of my program. I think I am having a super brain fart. I am not asking for code, I am asking for ideas or direction to study content. I have Googled and Yahooed till I am blue in the face and cannot seem to get this. I am using Notepad by the way not NetBeans. Any help is much appreciated. Thank you.

        My reality check bounced.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Dirk Higbee wrote:

        I have Googled and Yahooed till I am blue in the face and cannot seem to get this.

        Not really too difficult to find your way to this[^]. Whatever methods you decide to implement you will have no choice but to rewrite the code when it comes to displaying your data in a GUI window as opposed to using System.out.

        It's time for a new signature.

        D D 2 Replies Last reply
        0
        • C Cedric Moonen

          It's very difficult to answer such a question because it depends a lot of how your code is written. What do you have actually ? A simple console application that you would like to replace by a GUI application ? If yes, you will probably need to rewrite a lot of your code, unless you made a clear separation between the "logic" of your program and the "presentation". If that's the case, you'll need to rewrite the "presentation" part of your code and leave the "logic" untouched.

          Cédric Moonen Software developer
          Charting control [v3.0] OpenGL game tutorial in C++

          D Offline
          D Offline
          Dirk Higbee
          wrote on last edited by
          #4

          I have an inventory list program that displays in the console. All I need it to do is display in a GUI window. I have the part that creates, sizes and displays the window, but I need to get the list in the window when it runs. I'm just learning here but I think I may be having a brain fart. ;)

          My reality check bounced.

          1 Reply Last reply
          0
          • L Lost User

            Dirk Higbee wrote:

            I have Googled and Yahooed till I am blue in the face and cannot seem to get this.

            Not really too difficult to find your way to this[^]. Whatever methods you decide to implement you will have no choice but to rewrite the code when it comes to displaying your data in a GUI window as opposed to using System.out.

            It's time for a new signature.

            D Offline
            D Offline
            Dirk Higbee
            wrote on last edited by
            #5

            Thanks. That's what I figured. It's a school assignment and our study material is five years old. :( I am not writing the correct code for the output to display.

            My reality check bounced.

            1 Reply Last reply
            0
            • L Lost User

              Dirk Higbee wrote:

              I have Googled and Yahooed till I am blue in the face and cannot seem to get this.

              Not really too difficult to find your way to this[^]. Whatever methods you decide to implement you will have no choice but to rewrite the code when it comes to displaying your data in a GUI window as opposed to using System.out.

              It's time for a new signature.

              D Offline
              D Offline
              David Skelly
              wrote on last edited by
              #6

              Richard MacCutchan wrote:

              Whatever methods you decide to implement you will have no choice but to rewrite the code when it comes to displaying your data in a GUI window as opposed to using System.out.

              Not entirely true. You can redirect System.out to an OutputStream and then feed that output to a Swing component like a JTextArea. This trick is used in IDEs like NetBeans and Eclipse, both of which show the console output in a panel in the IDE. You can do something similar with System.in although that is a little more involved.

              L 1 Reply Last reply
              0
              • D David Skelly

                Richard MacCutchan wrote:

                Whatever methods you decide to implement you will have no choice but to rewrite the code when it comes to displaying your data in a GUI window as opposed to using System.out.

                Not entirely true. You can redirect System.out to an OutputStream and then feed that output to a Swing component like a JTextArea. This trick is used in IDEs like NetBeans and Eclipse, both of which show the console output in a panel in the IDE. You can do something similar with System.in although that is a little more involved.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                I am not sure that that would be a simpler method for a newbie.

                It's time for a new signature.

                D 1 Reply Last reply
                0
                • L Lost User

                  I am not sure that that would be a simpler method for a newbie.

                  It's time for a new signature.

                  D Offline
                  D Offline
                  David Skelly
                  wrote on last edited by
                  #8

                  I thought you were going to point out that Eclipse is not a Swing application. But the trick works for SWT as well as Swing. Redirecting System.out is not hard, there are examples on the net if you search for "redirect system.out jtextarea" or similar. You can also redirect System.err and System.in in a similar way. Whether it is easy in this case depends largely on how the original code is written and how it is structured. The hard part for a newbie is likely to be getting the threading right in a Swing environment.

                  L 1 Reply Last reply
                  0
                  • D David Skelly

                    I thought you were going to point out that Eclipse is not a Swing application. But the trick works for SWT as well as Swing. Redirecting System.out is not hard, there are examples on the net if you search for "redirect system.out jtextarea" or similar. You can also redirect System.err and System.in in a similar way. Whether it is easy in this case depends largely on how the original code is written and how it is structured. The hard part for a newbie is likely to be getting the threading right in a Swing environment.

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    David Skelly wrote:

                    Redirecting System.out is not hard

                    I'm well aware of that; I've been writing programs with redirected streams over many years. I just felt that adding that to my original question would possibly cloud the issue.

                    It's time for a new signature.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups