I made an application and it works perfectly when I compile it in the command window with javac. Here is the code for that:
import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.AbstractButton; import javax.swing.JFrame; import javax.swing.JPanel; public class RegF extends JFrame { protected static JTextField textfield1, textfield2, textfield3, textfield4, textfield5; protected static JButton ok, cancel; protected static JLabel label1, label2, label3, label4, label5; public static void main(String args[]) { JFrame frame = new JFrame("Registration Form"); GridBagLayout lay = new GridBagLayout(); JPanel pane = new JPanel(lay); GridBagConstraints c = new GridBagConstraints(); textfield1 = new JTextField(20); textfield2 = new JTextField(20); textfield3 = new JTextField(30); textfield4 = new JTextField(20); textfield5 = new JTextField(20); ok = new JButton("Ok"); ok.setMnemonic(KeyEvent.VK_O); cancel = new JButton("Cancel"); cancel.setMnemonic(KeyEvent.VK_C); ok.setToolTipText("Click if you you are ok with the your entries"); cancel.setToolTipText("Click if would like to cancel"); label1 = new JLabel("First Name"); label2 = new JLabel("Last Name"); label3 = new JLabel("Address"); label4 = new JLabel("City"); label5 = new JLabel("State"); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.gridx = 1; c.gridy = 0; pane.add(textfield1, c); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.gridx = 1; c.gridy = 1; pane.add(textfield2, c); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.gridx = 1; c.gridy = 2; pane.add(textfield3, c); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.gridx = 1; c.gridy = 3; pane.add(textfield4, c); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.gridx = 1; c.gridy = 4; pane.add(textfield5, c); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.gridx = 0; c.gridy = 0; pane.add(label1, c); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.gridx = 0; c.gridy = 1; pane.add(label2, c); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.gridx = 0; c.gridy = 2; pane.add(label3, c); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.gridx = 0; c.gridy = 3; pane.add(label4, c); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.gridx = 0; c.gridy = 4; pane.add(label5, c); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.gridx = 0; c.gridy = 6; pane.add(ok, c); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.gridx = 2; c.gridy = 6; pane.add(cancel, c); frame.setDefaultCloseOperation(JFrame.EX… frame.getContentPane().add(pane); frame.pack(); frame.setVisible(true); } }
So that one compiles fine and the ok and cancel buttons aren't supposed to do anything. If anyone has any ideas for those that would be cool but I don't even need that so don't really worry about it. The main question here is how do I convert that to work in a browser window because I tried and I searched Google more than I like to say and I can't figure out how to get it to work.
Thank you to anyone that can help I am just learning this stuff and it is driving me nuts!