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?
Code :
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?
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.
Re: Noob at GUI's, need layout help.
I mean, it looks horrible,
http://i1109.photobucket.com/albums/...yb97/MyGUI.png
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 ;)
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.
Re: Noob at GUI's, need layout help.
Oh thanks, the GroupLayout really catches my eye, I going to try it.
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
Re: Noob at GUI's, need layout help.
Thanks for this! I just got the pdf, looks promising!