6 Replies - 14590 Views - Last Post: 10 October 2012 - 01:59 PM Rate Topic: -----

#1 prerak09  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 1
  • Joined: 14-June 11

Java GUI for beginners

Posted 14 June 2011 - 10:49 AM

here is an article for beginners in Java to create a GUI in it:
http://www.fortyston...-java-tutorial/
Is This A Good Question/Topic? 1
  • +

Replies To: Java GUI for beginners

#2 n8schatten  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 144
  • View blog
  • Posts: 263
  • Joined: 07-December 10

Re: Java GUI for beginners

Posted 18 June 2011 - 03:13 AM

I like that the author did not extend JFrame, but instead created a class that has a JFrame to work on. However, there some things I would really not recommend:

  • The author named his class frame, which is not only against Java's naming conventions (classes begin with uppercase letters), but may also lead to confusion with AWT's frame. Especially when using an IDE there are few things that are more annoying than third party classes that are named like classes of the JDK. Something like ExampleFrame would have done a great job here.
  • As to my experience it is really a bad idea to create the every Component and to build the while UI in the constructor! Setting up the UI and working with it should always be performed on the EventDispatchThread (EDT), disobeying this rule leads to GUIs stopping now and then.
    So, either the constructor is called on the EDT, or the application is likely to have a lagging GUI. The snippet below shows how I usually handle setting up the GUI etc. so that I don't have to take care of EDT stuff in the controller or anywhere else.


public abstract class AbstractFrame {

    protected JFrame frame;

    /**
     * Intended to be implemented by subclasses in order to set up their GUI
     */
    protected abstract void buildUI();

    public final void show() {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                if (null == AbstractFrame.this.frame) {
                    buildUI();
                }
                AbstractFrame.this.frame.setVisible(true);
            }
        });
    }
}


PS: There are some more methods in AbstractFrame that I did not post here. The snippet is only intended to provide the idea of what I usually do. Will post the whole AbstractFrame as a snippet soon.

This post has been edited by n8schatten: 18 June 2011 - 03:16 AM

Was This Post Helpful? 2
  • +
  • -

#3 dhussey111  Icon User is offline

  • New D.I.C Head

Reputation: -40
  • View blog
  • Posts: 33
  • Joined: 22-September 12

Re: Java GUI for beginners

Posted 06 October 2012 - 08:35 AM

what if i wanted to learn eclipse for GUI can you recommend anything more better then this?
Was This Post Helpful? -1
  • +
  • -

#4 Ytry  Icon User is offline

  • D.I.C Head

Reputation: 16
  • View blog
  • Posts: 120
  • Joined: 25-July 12

Re: Java GUI for beginners

Posted 06 October 2012 - 08:47 AM

Wait, did you just say learn eclipse... how does one go about learning an IDE?
Was This Post Helpful? 0
  • +
  • -

#5 dhussey111  Icon User is offline

  • New D.I.C Head

Reputation: -40
  • View blog
  • Posts: 33
  • Joined: 22-September 12

Re: Java GUI for beginners

Posted 08 October 2012 - 08:46 AM

View PostYtry, on 06 October 2012 - 08:47 AM, said:

Wait, did you just say learn eclipse... how does one go about learning an IDE?

no no .. i can code but i can not import classes so i can view it in a new window with good GUI..
i just want to use graphics in eclipse..
Was This Post Helpful? 0
  • +
  • -

#6 Ytry  Icon User is offline

  • D.I.C Head

Reputation: 16
  • View blog
  • Posts: 120
  • Joined: 25-July 12

Re: Java GUI for beginners

Posted 10 October 2012 - 06:25 AM

Honestly I am not trying to be mean, but what are you talking about?
Was This Post Helpful? 0
  • +
  • -

#7 Ghlavac  Icon User is offline

  • D.I.C Addict

Reputation: 84
  • View blog
  • Posts: 519
  • Joined: 14-January 09

Re: Java GUI for beginners

Posted 10 October 2012 - 01:59 PM

He means this.

https://developers.g.../download-wbpro

Keep in mind it is not a substitute for being able to write UI code, but simply another tool to help speed your development.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1