[SOLVED] JAVA GUI.. why components are not visible on the JFrame?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
JAVA GUI.. why components are not visible on the JFrame?
hi.. I've written a java class wich extends the JFrame class and i did the whole thing and i compiled it with no problems what so ever but when i run it the frame comes out with no components on it!!!
I've created Jbuttons and JPanels and JPasswordFild and i made sure to make a container and I've surely added the components to the frame but IT IS STILL NOT WORKING!
here is the code:
Code:
// this is the log in window class
// Friday, June 25, 2010
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class LogInWindow extends JFrame {
private JPanel pan;
private JPanel pan2; // in the center
private JLabel lab;
private JLabel user;
private JLabel pass;
private JTextField userName;
private JPasswordField passWord;
private JButton log_in;
private BorderLayout border;
public LogInWindow() {
super("Bank system log in window");
Container cont = getContentPane();
cont.setLayout(border);
Icon logo = new ImageIcon("pic.jpg");
lab = new JLabel("LOG IN", logo, SwingConstants.RIGHT);
pan = new JPanel();
cont.add(pan,BorderLayout.NORTH);
pan.add(lab);
//pan.setVisible(true);
user = new JLabel("USER NAME");
userName = new JTextField(10);
pass = new JLabel("password");
passWord = new JPasswordField(10);
pan2 = new JPanel();
pan2.setLayout(new FlowLayout());
pan2.add(user);
pan2.add(userName);
pan2.add(pass);
pan2.add(passWord);
cont.add(pan2,BorderLayout.CENTER);
//userName = new JTextField("user name", 15);
setSize(600, 600);
setVisible(true);
} // end of constructor
public static void main(String[]args) {
LogInWindow logIn = new LogInWindow();
logIn.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
} // end of main method
}// end of class LogInWindow
sorry folks.. i didn't mean to "spam" or to be harmful.. all the story is that i was trying to show some friends how to "post a code"
but i have a little note about what you said MTK358.. that is not to use bad words like "WTF" you used.. try to be polit.. with my love.. yours.. linuxFreshMan :-|
hi folks, :-) how is everybody? i hope you are all fine and sound.. i would like to thank you alot for being understanding and kind.. thanks MTK358 for the link.. i visited it and it's great.. :-) best regards for you all.. MTK358,pixellany and vxc69 :-)
yours: linuxFreshMan
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.