File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SWING GUI ADVICE,PLEASE

 
nitin sharma
Ranch Hand
Posts: 290
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2813
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mind if we wait till they add Swing to the Programmers Exam before we get back to you?
Marcus
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic