Been sitting here at my computer for about 13 hours and I think my eyes are bleeding.
I found a little gui editor I love called GuiGenie.
It works perfect for creating the window with the buttons and all that good stuff.
The problem is i want to click a button in my first menu and have it open my other menu i made.
I just starting programming 4 weeks ago so I'm a complete noob.
I have a feeling its messing up because of the main methods but I have no idea and 13 hours of sitting here trying millions of things is making me go crazy : )
here is what i got so far
import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; public class MyPanel extends JPanel { private JTextField How; private JLabel jcomp2; private JLabel jcomp3; private JButton jcomp4; public MyPanel() { //construct components How = new JTextField (1); jcomp2 = new JLabel ("How long were you parked?"); jcomp3 = new JLabel ("Minutes"); jcomp4 = new JButton ("openNewWindow"); //adjust size and set layout setPreferredSize (new Dimension (315, 85)); setLayout (null); //add components add (How); add (jcomp2); add (jcomp3); add (jcomp4); //set component bounds (only needed by Absolute Positioning) How.setBounds (245, 50, 60, 25); jcomp2.setBounds (35, 30, 185, 50); jcomp3.setBounds (250, 30, 60, 20); jcomp4.setBounds (0, 0, 315, 25); jcomp4.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { } }); } public static void main (String[] args) { JFrame frame = new JFrame ("MyPanel"); frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); frame.getContentPane().add (new MyPanel()); frame.pack(); frame.setVisible (true); } }
When the button is pressed, I want it to open this new window
//Generated by GuiGenie - Copyright (c) 2004 Mario Awad. //Home Page http://guigenie.cjb.net - Check often for new versions! import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; public class MyPanel2 extends JPanel { private JButton jcomp1; private JButton jcomp2; private JButton jcomp3; private JTextField jcomp4; public MyPanel2() { //construct components jcomp1 = new JButton ("test1"); jcomp2 = new JButton ("test2"); jcomp3 = new JButton ("test3"); jcomp4 = new JTextField (5); //adjust size and set layout setPreferredSize (new Dimension (395, 156)); setLayout (null); //add components add (jcomp1); add (jcomp2); add (jcomp3); add (jcomp4); //set component bounds (only needed by Absolute Positioning) jcomp1.setBounds (20, 45, 100, 25); jcomp2.setBounds (135, 60, 100, 25); jcomp3.setBounds (260, 35, 100, 25); jcomp4.setBounds (105, 115, 100, 25); } public static void main (String[] args) { JFrame frame = new JFrame ("MyPanel"); frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); frame.getContentPane().add (new MyPanel2()); frame.pack(); frame.setVisible (true); } }
If anyone could help I would appreciate it greatly!!
I have a lot of respect for you pros out there because if you are a pro at this, you are probably smarter than 99.9% of the world.
This stuff hurts my brain.