aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes SWING GUI  ADVICE,PLEASE Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "SWING GUI  ADVICE,PLEASE" Watch "SWING GUI  ADVICE,PLEASE" New topic
Author

SWING GUI ADVICE,PLEASE

nitin sharma
Ranch Hand

Joined: Feb 24, 2001
Posts: 290
Hello swing expert's,
I need your experienced adivice.I have created a GUI, code of which i will show to u in a moment.
Have a look at the given code and tell me whether that gui will look good in a real project or not.Any suggestions are most welcome.
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
class lap extends JFrame
{

boolean b=true;
JPanel p,p1,p3,p4;
GridBagLayout g;
GridBagConstraints c;
JLabel l2,l3,l4;
JButton b1,b2,b3;
JTextField f;
JPasswordField j;
JLabel h;
public lap()
{
g=new GridBagLayout();
c=new GridBagConstraints();
l2=new JLabel("GRAPHICAL USER INTERFACE");
l2.setForeground(Color.black);
p=new JPanel();
getContentPane().add(p,"North");
p.setLayout(g);
//c.gridx=;
p.add(l2,c);
setSize(700,700);
setVisible(true);
p.setBackground(Color.yellow);
l3=new JLabel("USER NAME");
p1=new JPanel();
getContentPane().add(p1,"Center");
c.gridx=100;
c.gridy=250;
//c.insets=new Insets(0,5,0,0);
l3.setForeground(Color.black);
p1.setLayout(g);
p1.add(l3,c);
p1.setBackground(Color.white);
l4=new JLabel("PASSWORD");
c.gridx=100;
c.gridy=350;
//c.insets=new Insets(30,0,0,0);
l4.setForeground(Color.black);
p1.add(l4,c);
f=new JTextField(20);
c.gridx=200;
c.gridy=250;
c.insets=new Insets(0,10,0,0);
f.setForeground(Color.white);
f.setBackground(Color.black);
p1.add(f,c);
j=new JPasswordField(20);
c.gridx=200;
c.gridy=350;
//c.insets=new Insets(0,10,0,0);
c.insets=new Insets(0,10,0,0);
j.setForeground(Color.white);
j.setBackground(Color.black);
//p1.setBackground(Color.white);
p1.add(j,c);

p3=new JPanel();
getContentPane().add(p3,"South");
b1=new JButton("CHECK PASSWORD");
p3.setLayout(g);
c.gridx=200;
c.gridy=400;
b1.setForeground(Color.white);
b1.setBackground(Color.black);
p3.add(b1,c);
b2=new JButton("CANCEL");
c.gridx=400;
c.gridy=400;
b2.setForeground(Color.white);
b2.setBackground(Color.black);
p3.add(b2,c);
p3.setBackground(Color.pink);

p4=new JPanel();
getContentPane().add(p4,"West");
p4.setLayout(g);
h=new JLabel("YOUR PASSWORD SHOULD BE NITIN");
p4.add(h);
h.setForeground(Color.white);
p4.setBackground(Color.black);

for(;
{
if(b)
{
l2.setVisible(false);
b=false;
try
{
Thread.sleep(2000);
}
catch(Exception e)
{
}
}
else
{
l2.setVisible(true);
b=true;
try
{
Thread.sleep(2000);
}
catch(Exception e)
{
}
}
}
}
public static void main(String[]args)
{
lap l=new lap();
}
}
Marcus Green
arch rival
Rancher

Joined: Sep 14, 1999
Posts: 2813
Do you mind if we wait till they add Swing to the Programmers Exam before we get back to you?
Marcus


SCWCD: Online Course, 50,000+ words and 200+ questions
http://www.examulator.com/moodle/course/view.php?id=5&topic=all
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: SWING GUI ADVICE,PLEASE
 
Similar Threads
Getting a problem while using database connectivity
how to fix the JLabel Text value in Swings
How to make the window (JPanel?) bigger in gridbaglayout
SWING GUI ADVICE,PLEASE
Adding Record Problem in JDBC ?