Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2015
    Posts
    2
    Rep Power
    0

    Unhappy Need Help With Positioning JLabels! (My first post)

    I'm making a GUI program and I can't get the JLabels to be put where I want them. Also, I DON'T WANT TO USE "SwingConstants.*"! Here is my code:

    Java Code:
    // Java class name should be “JavaClass#”
    // package should match that
    // class in left-side tree: JavaClass#.java
    
    package JavaClass#;
    
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    
    public class JavaClass# extends JFrame {
    public JavaClass#() {
    setSize(640,480);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLayout(null);
    
    JLabel mylabel = new JLabel(“These Are Some Words!”);
    mylabel.setLocation(100,100);
    add(label);
    
    }
    
    public static void main(String args[]) {
    new JavaClass#().setVisible(true);
    }
    }

    Any idea if this works or not? And how to fix it? I haven't tested it out yet because I am on vaca without a PC.
    Last edited by supamonkey2000; 11-03-2015 at 11:03 PM. Reason: Wrapping Code in code tags

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Need Help With Positioning JLabels! (My first post)

    I haven't tested it out yet
    No problem. There will be someone here when you have any questions after trying to compile and execute it.

    Please edit your post and wrap the code in code tags to preserve its formatting.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    Join Date
    Nov 2015
    Posts
    2
    Rep Power
    0

    Default Re: Need Help With Positioning JLabels! (My first post)

    Quote Originally Posted by Norm View Post
    No problem. There will be someone here when you have any questions after trying to compile and execute it.

    Please edit your post and wrap the code in code tags to preserve its formatting.
    Thanks, I edited it so the code was wrapped. :)

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Need Help With Positioning JLabels! (My first post)

    This would be an excellent time to learn about Layout Managers. Check out the tutorials in my signature.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Help in positioning and running to the web
    By jairoh_ in forum Java Applets
    Replies: 3
    Last Post: 10-10-2012, 07:36 PM
  2. Replies: 3
    Last Post: 05-04-2009, 03:15 AM
  3. Positioning using setBounds
    By thayalan in forum AWT / Swing
    Replies: 4
    Last Post: 04-28-2009, 01:59 AM
  4. panel positioning
    By shwein in forum New To Java
    Replies: 4
    Last Post: 09-09-2008, 05:15 PM

Posting Permissions

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