Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: labels and fields

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Thanked 0 Times in 0 Posts

    Default labels and fields

    I am trying to get a label, then next to it on the right a text area, then underneath those another label and beside that a smaller text field.
    I haven't had very much luck so far. Each time I enter my second label, my first one disappears.
    I'm in a java class, I haven't heard from the professor, so I thought I might have better luck here.
    I hope so.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.Container;
    public class Index extends JFrame {
    	 * Program Name: Index.java
    	  * Program description: This program will take a character from a user and a               *line of text, 
    	 * and tell how many occurrences of that character there is.
    	private JTextField textInput;	
    	private FlowLayout layout;
    	private Container container;
    	public void actionPerformed(ActionEvent e)
    	public static void main(String[] args) {
    		JTextArea userCharFld;
    		JPanel panel, panel1;
    		JLabel label;
    		JFrame mainFrame = new JFrame("Character Finder");	
    		mainFrame.setSize(450, 250);
    Any help would be greatly appreciated.

  2. #2
    Forum old-timer
    Join Date
    Nov 2008
    Faversham, Kent, UK
    My Mood
    Thanked 58 Times in 54 Posts

    Default Re: labels and fields

    The code you posted doesn't create or display anything apart from the frame, so it's impossible to say what you may be doing wrong...

    Please post the code you wrote that tries to display the labels and text.

  3. #3
    Junior Member
    Join Date
    Jun 2011
    Thanked 0 Times in 0 Posts

    Default Re: labels and fields

    Sorry, I erased it all before I posted. I didn't really think about it at the time because I was a bit frustrated.
    I haven't tried to put it back in yet. I really need to move parts of it into a method but I'm just not sure how.
    I have to try and finish it all today so I may repost.

Similar Threads

  1. Renaming labels & text boxes
    By fride360 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 17th, 2011, 02:11 PM
  2. Applet Help: Parsing and displaying labels
    By katyprim in forum What's Wrong With My Code?
    Replies: 6
    Last Post: September 11th, 2010, 09:32 AM
  3. Cannot set class fields using textInput
    By javascrub in forum What's Wrong With My Code?
    Replies: 0
    Last Post: August 26th, 2010, 04:04 AM
  4. Need help understanding GUI screen layouts and labels
    By Bill_H in forum AWT / Java Swing
    Replies: 3
    Last Post: December 2nd, 2009, 10:50 PM