Big Problem With My UI Components
Hey Guys, None Of My UI Components will display at run time (Actually only Frames do). I've tried JButtons, JTextFields, and JLabel with no luck. At first I thought maybe I screwed up on the source code so I went back literally called the void setVisible(boolean) method on every component. But unfortunately it was futile. So I downloaded some sample code made my some online tutorial and it proved me right. There is nothing shown on the screen except for a empty frame.
Here Is What I Got
import javax.swing.*;
import java.awt.event.*;
publicclass FrameSimpleextends JFrameimplements MouseListener
{
JButton jb1;
JButton jb2;
JTextField jt1;
public FrameSimple(String title)
{
super(title);
setDefaultCloseOperation(EXIT_ON_CLOSE);
JPanel p =new JPanel();
jb1 =new JButton("Delete Last");
jb2 =new JButton("Clear");
jt1 =new JTextField(40);
p.add(jb1);
p.add(jb2);
p.add(jt1);
jb1.addMouseListener(this);
jb2.addMouseListener(this);
setContentPane(p);
pack();
setVisible(true);
}
publicvoid mousePressed(MouseEvent e){}
publicvoid mouseClicked(MouseEvent e){}
publicvoid mouseEntered(MouseEvent e){}
publicvoid mouseExited(MouseEvent e){}
publicvoid mouseReleased(MouseEvent e){
if (e.getSource()==jb2)
{
jt1.setText("");
}
else
{
jt1.setText(jt1.getText().substring(0,jt1.getText().length()-1));
}
}
}
And The Main Method If Its Any Helpful
import javax.swing.UIManager;
publicclass Main
{
publicstaticvoid main(String[] args)
{
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e)
{
System.out.println(e);
}
FrameSimple fp =new FrameSimple("Simple");
}
}

