View Single Post
  #1 (permalink)  
Old 05-04-2008, 08:02 AM
bobleny's Avatar
bobleny bobleny is offline
Member
 
Join Date: Apr 2008
Posts: 36
bobleny is on a distinguished road
[SOLVED] Building a nice GUI applet?
Hi, me again!
I'm trying to work on a GUI applet for a program, but I'm dead in the water...

I'm trying to do a GridBagLayout because I think that is exactly what I need.
I don't know why, but it doesn't work?

Code:
import java.awt.Color; import java.awt.Container; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import javax.swing.JApplet; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JTextField; public class AppTest extends JApplet { Font font01 = new Font("Helvetica", Font.BOLD, 20); Font font02 = new Font("Courier New", Font.PLAIN, 14); public void init() { Container window = getContentPane(); GridBagConstraints c = new GridBagConstraints(); GridBagLayout grid = new GridBagLayout(); window.setLayout(grid); window.setBackground(Color.WHITE); { JLabel label01 = new JLabel("Hang Man!"); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 2; c.gridy = 0; label01.setFont(font01); window.add(label01, c); } { JLabel label03 = new JLabel("Guess a Letter: "); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 1; c.gridy = 1; label03.setFont(font02); window.add(label03); } { JTextField field01 = new JTextField(2); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 2; c.gridy = 1; field01.setFont(font02); window.add(field01); } { JButton button01 = new JButton("Guess!"); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 3; c.gridy = 1; button01.setFont(font02); window.add(button01); } { JButton button01 = new JButton("Next Phrase ->"); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 3; c.gridy = 2; button01.setFont(font02); window.add(button01); } } }

What am I doing wrong?

Thanks!
__________________
--
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
--
Cheer up, the worst has yet to come...
Reply With Quote
Sponsored Links