Results 1 to 3 of 3
  1. #1
    Feriscool is offline Member
    Join Date
    Nov 2010
    Posts
    28
    Rep Power
    0

    Question Couple Questions to have JFormDesigner Work

    Below is the code to a GUI I'm building JFormDesigner. I have a couple questions:
    1. How can I have the layout of the GUI change depending on what the person chooses in the "Editor" menu?
    2. When the person fills out all boxes, how can I make the Generate button work and then output the data in the "Output" box?


    Java Code:
    import java.awt.*;
    import javax.swing.*;
    /*
     * Created by JFormDesigner on Tue Jun 14 23:21:59 EDT 2011
     */
    
    
    
    /**
     * @author RS 2007
     */
    public class NPCSpawn extends JFrame {
    	public NPCSpawn() {
    		initComponents();
    	}
    
    	private void initComponents() {
    		// JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    		// Generated using JFormDesigner Evaluation license - RS 2007
    		menuBar1 = new JMenuBar();
    		menu1 = new JMenu();
    		menuItem1 = new JMenuItem();
    		menuItem2 = new JMenuItem();
    		menu2 = new JMenu();
    		menuItem3 = new JMenuItem();
    		scrollPane1 = new JScrollPane();
    		textArea1 = new JTextArea();
    		textField1 = new JTextField();
    		label1 = new JLabel();
    		button1 = new JButton();
    		textField2 = new JTextField();
    		textField3 = new JTextField();
    		textField4 = new JTextField();
    		textField5 = new JTextField();
    		textField6 = new JTextField();
    		textField7 = new JTextField();
    		textField8 = new JTextField();
    		textField9 = new JTextField();
    		textField10 = new JTextField();
    		textField11 = new JTextField();
    		label2 = new JLabel();
    		label3 = new JLabel();
    		textField12 = new JTextField();
    		label4 = new JLabel();
    		label5 = new JLabel();
    		label6 = new JLabel();
    		label7 = new JLabel();
    		label8 = new JLabel();
    		label9 = new JLabel();
    		label10 = new JLabel();
    		label11 = new JLabel();
    		label12 = new JLabel();
    		label13 = new JLabel();
    
    		//======== this ========
    		setTitle("GUI");
    		Container contentPane = getContentPane();
    		contentPane.setLayout(null);
    
    		//======== menuBar1 ========
    		{
    
    			//======== menu1 ========
    			{
    				menu1.setText("File");
    
    				//---- menuItem1 ----
    				menuItem1.setText("Save");
    				menuItem1.setIcon(new ImageIcon("C:\\Users\\Patrick\\Desktop\\save_icon.png"));
    				menu1.add(menuItem1);
    
    				//---- menuItem2 ----
    				menuItem2.setText("Exit");
    				menu1.add(menuItem2);
    			}
    			menuBar1.add(menu1);
    
    			//======== menu2 ========
    			{
    				menu2.setText("Editors");
    
    				//---- menuItem3 ----
    				menuItem3.setText("NPCSpawner");
    				menu2.add(menuItem3);
    			}
    			menuBar1.add(menu2);
    		}
    		setJMenuBar(menuBar1);
    
    		//======== scrollPane1 ========
    		{
    			scrollPane1.setViewportView(textArea1);
    		}
    		contentPane.add(scrollPane1);
    		scrollPane1.setBounds(305, 25, 185, 225);
    		contentPane.add(textField1);
    		textField1.setBounds(10, 75, 80, 20);
    
    		//---- label1 ----
    		label1.setText("Output");
    		contentPane.add(label1);
    		label1.setBounds(380, 5, 65, 20);
    
    		//---- button1 ----
    		button1.setText("Generate");
    		contentPane.add(button1);
    		button1.setBounds(95, 215, 100, 25);
    		contentPane.add(textField2);
    		textField2.setBounds(10, 25, 80, 20);
    		contentPane.add(textField3);
    		textField3.setBounds(10, 125, 80, 20);
    		contentPane.add(textField4);
    		textField4.setBounds(105, 125, 80, 20);
    		contentPane.add(textField5);
    		textField5.setBounds(200, 175, 80, 20);
    		contentPane.add(textField6);
    		textField6.setBounds(200, 125, 80, 20);
    		contentPane.add(textField7);
    		textField7.setBounds(105, 75, 80, 20);
    		contentPane.add(textField8);
    		textField8.setBounds(200, 75, 80, 20);
    		contentPane.add(textField9);
    		textField9.setBounds(10, 175, 80, 20);
    		contentPane.add(textField10);
    		textField10.setBounds(105, 175, 80, 20);
    		contentPane.add(textField11);
    		textField11.setBounds(105, 25, 80, 20);
    
    		//---- label2 ----
    		label2.setText("ID");
    		contentPane.add(label2);
    		label2.setBounds(45, 10, 15, 15);
    
    		//---- label3 ----
    		label3.setText("Name");
    		contentPane.add(label3);
    		label3.setBounds(new Rectangle(new Point(130, 10), label3.getPreferredSize()));
    		contentPane.add(textField12);
    		textField12.setBounds(200, 25, 80, 20);
    
    		//---- label4 ----
    		label4.setText("WalkingType");
    		contentPane.add(label4);
    		label4.setBounds(new Rectangle(new Point(210, 10), label4.getPreferredSize()));
    
    		//---- label5 ----
    		label5.setText("SpawnX");
    		contentPane.add(label5);
    		label5.setBounds(new Rectangle(new Point(30, 60), label5.getPreferredSize()));
    
    		//---- label6 ----
    		label6.setText("SpawnY");
    		contentPane.add(label6);
    		label6.setBounds(new Rectangle(new Point(125, 60), label6.getPreferredSize()));
    
    		//---- label7 ----
    		label7.setText("SpawnZ");
    		contentPane.add(label7);
    		label7.setBounds(new Rectangle(new Point(220, 60), label7.getPreferredSize()));
    
    		//---- label8 ----
    		label8.setText("MinX");
    		contentPane.add(label8);
    		label8.setBounds(new Rectangle(new Point(40, 110), label8.getPreferredSize()));
    
    		//---- label9 ----
    		label9.setText("MinY");
    		contentPane.add(label9);
    		label9.setBounds(new Rectangle(new Point(135, 110), label9.getPreferredSize()));
    
    		//---- label10 ----
    		label10.setText("MinZ");
    		contentPane.add(label10);
    		label10.setBounds(new Rectangle(new Point(230, 110), label10.getPreferredSize()));
    
    		//---- label11 ----
    		label11.setText("MaxX");
    		contentPane.add(label11);
    		label11.setBounds(new Rectangle(new Point(35, 160), label11.getPreferredSize()));
    
    		//---- label12 ----
    		label12.setText("MaxY");
    		contentPane.add(label12);
    		label12.setBounds(new Rectangle(new Point(130, 160), label12.getPreferredSize()));
    
    		//---- label13 ----
    		label13.setText("MaxZ");
    		contentPane.add(label13);
    		label13.setBounds(new Rectangle(new Point(225, 160), label13.getPreferredSize()));
    
    		{ // compute preferred size
    			Dimension preferredSize = new Dimension();
    			for(int i = 0; i < contentPane.getComponentCount(); i++) {
    				Rectangle bounds = contentPane.getComponent(i).getBounds();
    				preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
    				preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
    			}
    			Insets insets = contentPane.getInsets();
    			preferredSize.width += insets.right;
    			preferredSize.height += insets.bottom;
    			contentPane.setMinimumSize(preferredSize);
    			contentPane.setPreferredSize(preferredSize);
    		}
    		pack();
    		setLocationRelativeTo(getOwner());
    		// JFormDesigner - End of component initialization  //GEN-END:initComponents
    	}
    
    	// JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    	// Generated using JFormDesigner Evaluation license - RS 2007
    	private JMenuBar menuBar1;
    	private JMenu menu1;
    	private JMenuItem menuItem1;
    	private JMenuItem menuItem2;
    	private JMenu menu2;
    	private JMenuItem menuItem3;
    	private JScrollPane scrollPane1;
    	private JTextArea textArea1;
    	private JTextField textField1;
    	private JLabel label1;
    	private JButton button1;
    	private JTextField textField2;
    	private JTextField textField3;
    	private JTextField textField4;
    	private JTextField textField5;
    	private JTextField textField6;
    	private JTextField textField7;
    	private JTextField textField8;
    	private JTextField textField9;
    	private JTextField textField10;
    	private JTextField textField11;
    	private JLabel label2;
    	private JLabel label3;
    	private JTextField textField12;
    	private JLabel label4;
    	private JLabel label5;
    	private JLabel label6;
    	private JLabel label7;
    	private JLabel label8;
    	private JLabel label9;
    	private JLabel label10;
    	private JLabel label11;
    	private JLabel label12;
    	private JLabel label13;
    	// JFormDesigner - End of variables declaration  //GEN-END:variables
    }

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,585
    Rep Power
    25

  3. #3
    Feriscool is offline Member
    Join Date
    Nov 2010
    Posts
    28
    Rep Power
    0

Similar Threads

  1. Couple more questions on JAR Files :S
    By Lil_Aziz1 in forum New To Java
    Replies: 13
    Last Post: 06-05-2010, 08:44 AM
  2. Couple questions about Java
    By theadolescent in forum New To Java
    Replies: 3
    Last Post: 05-19-2010, 02:13 AM
  3. Couple Questions on Thread
    By Lil_Aziz1 in forum Threads and Synchronization
    Replies: 5
    Last Post: 01-06-2010, 02:02 PM
  4. Couple of questions regarding threading
    By exernet in forum New To Java
    Replies: 1
    Last Post: 12-15-2009, 12:23 PM
  5. Couple of newbie questions
    By ananasman in forum New To Java
    Replies: 11
    Last Post: 11-20-2008, 11:54 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •