|
-
Aug 27th, 2003, 11:35 AM
#1
Thread Starter
Fanatic Member
Basic Questions Swing
Hi all,
I am a VB dev by nature but I am tyring to get through a Java course. I need to build a class using swing that places the date in the upper left hand corner. Has an input field for a social security number. Has six inpuit boxes where a person could sign in or out during the day, etc. I just need to get the layout done. But I am haxing a real hard time just getting the labels to display. Here is my code:
Code:
import java.awt.*;
import javax.swing.*;
public class EmpTimeCard extends JFrame
{
public static void main(String[] args)
{
//first thing we need to do is create a new panel (container)
JFrame j = new JFrame();
j.setSize(300,300);
JPanel p1 = new JPanel();
int cols = 5;
int cols1 =15;
int cols2 = 13;
//then we need to setup the areas that the text boxes will reside
JLabel lblLName = new JLabel("Last Name:", JLabel.RIGHT);
JTextField LName = new JTextField(cols);
p1.add(lblLName);
p1.add(LName);
p1.setVisible(true);
j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
j.setVisible(true);
}
It displays the window, but nothing inside of it. What is going on?
-
Aug 28th, 2003, 09:56 AM
#2
Dazed Member
No need to extend JFrame in your case. Swing follows a different containment model then awt so you would have to add any components to the content pane instead of to the JFrame itself.
Last edited by Dilenger4; Aug 28th, 2003 at 10:01 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|