Results 1 to 3 of 3
Thread: problem with JTextfield..
- 10-03-2011, 10:56 AM #1
Member
- Join Date
- Sep 2011
- Posts
- 20
- Rep Power
- 0
problem with JTextfield..
hey there, i wrote this code for a form. its just GUI for now, but it won't display JTextfield.. :(
import javax.swing.*;
import java.awt.*;
import java.sql.*;
public class assignmnt {
public static void main(String[] args)
{
JFrame fr = new JFrame("Aup Student Database");
fr.setVisible(true);
fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fr.setSize(500,500);
JPanel p = new JPanel(new GridBagLayout());
fr.getContentPane().add(p, BorderLayout.PAGE_START);
JLabel lb = new JLabel("Aup Student Database.");
p.add(lb);
JPanel p2= new JPanel(new GridBagLayout());
fr.add(p2);
fr.getContentPane().add(p2, BorderLayout.WEST);
GridBagConstraints c= new GridBagConstraints();
JLabel l1 = new JLabel("<---Search--->");
c.gridx=0;
c.gridy=10;
p2.add(l1,c);
JLabel l2=new JLabel("Student id: ");
c.gridx=0;
c.gridy=11;
p2.add(l2,c);
JButton b1=new JButton("Search");
c.gridx=10;
c.gridy=12;
p2.add(b1,c);
JTextField tf = new JTextField(20);
c.gridx=10;
c.gridy=11;
p2.add(tf,c);
}
}
- 10-03-2011, 11:07 AM #2
Senior Member
- Join Date
- Feb 2010
- Posts
- 128
- Rep Power
- 0
Re: problem with JTextfield..
Your JFrame should be set to visible at the end of the code not at the start. Move the setVisible(true) to the end of the main method.
Measuring programming progress by lines of code is like measuring aircraft building progress by weight.
- 10-04-2011, 09:16 AM #3
Member
- Join Date
- Sep 2011
- Posts
- 20
- Rep Power
- 0
Similar Threads
-
Problem Loading JTextField in JFrame / Problema al cargar JTextField en JFrame
By thor_inc in forum AWT / SwingReplies: 0Last Post: 08-30-2011, 10:18 AM -
Problem with JTextField.. please help!!
By Asvin in forum New To JavaReplies: 21Last Post: 12-18-2010, 04:49 PM -
Problem with setColumns in JTextField
By shai in forum New To JavaReplies: 3Last Post: 07-26-2010, 06:41 AM -
Problem's with JTextField
By DC% in forum AWT / SwingReplies: 4Last Post: 03-10-2009, 06:33 PM -
Got problem with JtextField
By hungleon88 in forum AWT / SwingReplies: 4Last Post: 12-06-2008, 04:01 PM
Bookmarks