Results 1 to 3 of 3
- 03-27-2012, 03:40 AM #1
Member
- Join Date
- Mar 2012
- Posts
- 2
- Rep Power
- 0
Does anyone know why this happens?
* Fixed *
Hey guys on my second day on Java, and I'm using the JFrame and I guess I'm having some sorta problem.
Heres the source
[Java] JFrame Problem - Pastebin.com
Any help would be nice.gif)
import javax.swing.*;
import java.awt.*;
public class dashboard extends JFrame {
public static void main(String[] agrs)
{
new dashboard();
}
public dashboard()
{
this.setSize(500,500);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
this.setTitle("OEMGE APP");
this.setLocationRelativeTo(null);
this.setResizable(false);
JPanel p = new JPanel(new FlowLayout());
JTextField welcomeMSG = new JTextField("Hello There");
JButton randomButton = new JButton("Click Me :D");
p.add(welcomeMSG);
p.add(randomButton);
this.add(p);
}
}
Had to change it to
import javax.swing.*;
import java.awt.*;
public class dashboard extends JFrame {
public static void main(String[] agrs)
{
new dashboard().setVisible(true);
}
public dashboard()
{
this.setSize(500,500);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
this.setTitle("OEMGE APP");
this.setLocationRelativeTo(null);
this.setResizable(false);
JPanel p = new JPanel(new FlowLayout());
JTextField welcomeMSG = new JTextField("Hello There");
JButton randomButton = new JButton("Click Me :D");
p.add(welcomeMSG);
p.add(randomButton);
this.add(p);
}
}Last edited by Timzy921; 03-27-2012 at 03:54 AM.
-
Re: Does anyone know why this happens?
Please post your code in the forum, not in a link. Since you're asking for free help, is it asking too much for you to try to make it easy for others to help you? Also, write out your question in the forum itself. Not everyone has the same band width as you, and not all understand spoken English as well as written English.
But regarding your problem, look at where you're calling setVisible(true) on your JFrame vs. where you are adding components. Try playing with order that some.
- 03-27-2012, 03:51 AM #3
Member
- Join Date
- Mar 2012
- Posts
- 2
- Rep Power
- 0


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks