Results 1 to 5 of 5
  1. #1
    Mapisto is offline Senior Member
    Join Date
    Dec 2011
    Posts
    102
    Rep Power
    0

    Default problem with combining JFrame+JLabel+JTextField

    Hi,

    I've been asked to make a program that pops up a form with textfields and stuff.

    I've started working on it and saw that textfields i've made wouldn't show up on the frame when i run the program.

    The idea is to create a frame which has labels and in every label there're text fields. I didn't add all the test fields yet (because i've realized I'm not doing it right ), thought the first label "PersonalInformation is written already so u can see what I've done wrong.

    Here's the class:

    Java Code:
    class ApplicationForm extends JFrame {
    	
    	private JLabel PersonalInformation = new JLabel("Personal Information");
    	private JLabel ListOfReferences = new JLabel("List of references");
    	private JLabel ProgramingLanguages = new JLabel("Programing Languages");
    	
    	private JTextField FirstName = new JTextField("First Name:",10);
    	private JTextField LastName = new JTextField("Last Name:");
    	private JTextField Adress = new JTextField("Adress:");
    	private JTextField Cellular = new JTextField("Cellular:");
    	
    	
    	public ApplicationForm (){
    		
    		super("Application Form");
    		setSize(550,400);
    		setVisible(true);
    		setAlwaysOnTop(isAlwaysOnTop());
    		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		this.PersonalInformation.add(FirstName);
    		this.PersonalInformation.add(LastName);
    		this.PersonalInformation.add(Adress);
    		this.PersonalInformation.add(Cellular);
    		
    		add(PersonalInformation,BorderLayout.NORTH);
    		add(ListOfReferences,BorderLayout.CENTER);
    		add(ProgramingLanguages,BorderLayout.SOUTH);
    	}
    	
    	
    	
    	
    	
    }
    Thanks a lot guys. (dunno what I'd have done without this forum )

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,409
    Rep Power
    25

    Default Re: problem with combining JFrame+JLabel+JTextField

    Can you change the code so that it will compile and execute for testing. It needs imports and a main method
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    Mapisto is offline Senior Member
    Join Date
    Dec 2011
    Posts
    102
    Rep Power
    0

    Default Re: problem with combining JFrame+JLabel+JTextField

    yea, I've done it on my own program ofc.
    I've just copied this class here though coz the main class has only the main method which has only one row that creates the object of the class above.

    I've figured the last one out myself eventually, I haven't realized I can't add stuff into a JLabel, I thought it's some kind of JFrame.

    I think I'll try to handle it now. in case I'll have another problem with it (surely i will : \ ), I'll post here the whole program and not just the specific class.

    Thanks for your time :)

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,409
    Rep Power
    25

    Default Re: problem with combining JFrame+JLabel+JTextField

    You don't need to post any more code than is necessary to compile, execute and show the problem. Often the whole program has a lot of unrelated stuff in it that gets in the way. A minimum sized working test program is preferred.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    Mapisto is offline Senior Member
    Join Date
    Dec 2011
    Posts
    102
    Rep Power
    0

    Default Re: problem with combining JFrame+JLabel+JTextField

    I'll remember that. Thanks.

Similar Threads

  1. Replies: 0
    Last Post: 08-30-2011, 09:18 AM
  2. Cannot refresh a JLabel on a JFrame
    By carnotan in forum AWT / Swing
    Replies: 11
    Last Post: 03-25-2011, 03:02 PM
  3. JLabel/JTextfield Animation
    By weikang in forum AWT / Swing
    Replies: 1
    Last Post: 01-05-2011, 02:55 PM
  4. [SOLVED] Adding JLabel to JFrame
    By mlfatty in forum AWT / Swing
    Replies: 3
    Last Post: 03-04-2009, 11:33 PM
  5. help me with JFrame and JLabel
    By michcio in forum New To Java
    Replies: 5
    Last Post: 11-20-2007, 07:44 AM

Posting Permissions

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