Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Noob at GUI's, need layout help.

  1. #1
    Member
    Join Date
    Sep 2011
    Posts
    40
    My Mood
    Inspired
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Noob at GUI's, need layout help.

    I am making a very simple Gui at the moment, but don't know how to make it look good. it looks horrible right now, could someone teach me at how to make it look better?

    import java.awt.*;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
     
    import javax.swing.*;
     
    public class Gui extends JFrame {
    	/**
    	 * 
    	 */
    	private static final long serialVersionUID = 1L;
    	JCheckBox Google = new JCheckBox("Google.com");
    	JCheckBox Yahoo = new JCheckBox("Yahoo.com");
    	JCheckBox Bing = new JCheckBox("Bing.com");
    	JTextField Search = new JTextField();
    	JButton Go = new JButton("Go");
        JFrame frame = new JFrame();
        JPanel panel = new JPanel();
     
    	public Gui() {
    		setTitle("Tyler's Auto Searcher");
    		setLayout(new GridLayout(8, 5));
    		setDefaultCloseOperation(EXIT_ON_CLOSE);
    		pack();
    		add(Search);
    		add(Go);
    		add(Google);
    		add(Yahoo);
    		add(Bing);
    		add(new Label("Type what you want to search, then press enter, after selecting what sites you want to search with."));
    		setSize(800, 200);
    		setVisible(true);
     
     
     
    	}
     
     
    }
    This is the code for the GUI, any ideas?


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Noob at GUI's, need layout help.

    Depends what exactly you mean by "make it look better". You could try jazzing it up a bit just by adding some borders, fonts, and icon images. This is less a code question and more a design question, which is a bit trickier to answer because it's so subjective.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Member
    Join Date
    Sep 2011
    Posts
    40
    My Mood
    Inspired
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Re: Noob at GUI's, need layout help.

    I mean, it looks horrible,



    What are some layout options that I have to make this better? Like adjust where the buttons are, and make the "go" appear next to the chat box? Also, I just blocked out the info for the protection of my genius idea

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Noob at GUI's, need layout help.

    Again, it's really subjective, so I can't really help you other than to point you to the tutorials: Lesson: Laying Out Components Within a Container (The Java™ Tutorials > Creating a GUI With JFC/Swing)

    If you had a more specific question, we could probably be more helpful- putting the go button next to the chat box is a good start. Hint- You can nest JPanels with different layouts inside other JPanels.

    And just a word to the wise, blocking things out "to protect your ideas" generally just annoys people and decreases your chances of getting help. Chances are, nobody is going to want to steal your idea- I'm not saying your idea is bad, but it's probably been done before anyway, and most people won't care enough to steal from you. And, didn't you include what's in there in the source code anyway? If you really care that much, just put some dummy values in there. Otherwise we can't really help you.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Member
    Join Date
    Sep 2011
    Posts
    40
    My Mood
    Inspired
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Re: Noob at GUI's, need layout help.

    Oh thanks, the GroupLayout really catches my eye, I going to try it.

  6. #6
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Noob at GUI's, need layout help.

    Also, for nifty design code, you might want to check out the book Filthy Rich Clients by Chet Haase and Romain Guy, and its companion website. It really takes Java applications to the next level.

    Filthy Rich Clients
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. The Following User Says Thank You to KevinWorkman For This Useful Post:

    tyb97 (November 2nd, 2011)

  8. #7
    Member
    Join Date
    Sep 2011
    Posts
    40
    My Mood
    Inspired
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Re: Noob at GUI's, need layout help.

    Thanks for this! I just got the pdf, looks promising!

Similar Threads

  1. NOOB: Array Help
    By DEAF in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 30th, 2011, 08:39 PM
  2. Is there a layout for this?
    By gkffjcs in forum AWT / Java Swing
    Replies: 2
    Last Post: September 27th, 2011, 09:15 AM
  3. Replies: 1
    Last Post: April 14th, 2011, 07:50 AM
  4. Grid bag layout inside grid bag layout
    By kiddkoder in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 29th, 2011, 08:07 AM
  5. Programming noob here, need help!
    By artenuga54 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 18th, 2010, 04:04 PM