LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-25-2010, 02:26 AM   #1
linuxFreshMan
Member
 
Registered: Nov 2009
Distribution: Ubuntu 9, RedHatLinux
Posts: 47

Rep: Reputation: 0
Angry 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
please help
 
Old 06-25-2010, 04:08 AM   #2
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Quote:
cont.setLayout(border);
where is "border" initialized?

Why are the Container and Icon instances scoped within the CTOR (rather than being private members, like the other GUI elements)?
 
1 members found this post helpful.
Old 06-25-2010, 10:25 AM   #3
linuxFreshMan
Member
 
Registered: Nov 2009
Distribution: Ubuntu 9, RedHatLinux
Posts: 47

Original Poster
Rep: Reputation: 0
thanks a lot the border was NOT defined.. plus i did what you suggested to me thanks a lot
 
Old 08-01-2010, 04:58 AM   #4
linuxFreshMan
Member
 
Registered: Nov 2009
Distribution: Ubuntu 9, RedHatLinux
Posts: 47

Original Poster
Rep: Reputation: 0
Code:
 fgjgfkjgfkjg
 
Old 08-01-2010, 08:23 AM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by linuxFreshMan View Post
Code:
 fgjgfkjgfkjg
WTF?

Is that spamming?
 
Old 08-02-2010, 08:06 AM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
linux*;
I don't know why you did that, but don't do it again.
 
Old 08-02-2010, 09:23 AM   #7
linuxFreshMan
Member
 
Registered: Nov 2009
Distribution: Ubuntu 9, RedHatLinux
Posts: 47

Original Poster
Rep: Reputation: 0
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 :-|
 
Old 08-02-2010, 10:05 AM   #8
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
OK, I understand.

But you could have posted that someplace more appropriate, like this: http://www.linuxquestions.org/questi...67/page11.html
 
Old 08-02-2010, 04:38 PM   #9
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
WTF is OK....
http://www.wtf.org/wtf_eng/main/main_eng.html

seriously, abbreviations are normally OK---they are almost always ambiguous. SNAFU, LOL, etc.

remember that f*** is an acronym in which none of the individual words are considered offensive.
 
Old 08-02-2010, 10:37 PM   #10
vxc69
Member
 
Registered: Jul 2004
Distribution: Ubuntu
Posts: 387

Rep: Reputation: 33
Quote:
Originally Posted by pixellany View Post
WTF is OK....
http://www.wtf.org/wtf_eng/main/main_eng.html

seriously, abbreviations are normally OK---they are almost always ambiguous. SNAFU, LOL, etc.

remember that f*** is an acronym in which none of the individual words are considered offensive.
Fornication Under the Consent of King?
 
Old 08-03-2010, 06:48 AM   #11
linuxFreshMan
Member
 
Registered: Nov 2009
Distribution: Ubuntu 9, RedHatLinux
Posts: 47

Original Poster
Rep: Reputation: 0
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Java JFrame and JPanel listener hunterfighter Programming 3 07-01-2009 09:28 AM
Find a Visible JFrame in a java application MRMadhav Programming 0 11-29-2006 05:47 AM
java JFrame sizes. byteframe Programming 8 10-25-2005 02:09 AM
(jwstric2) JFrame error on JAVA nedian123 Programming 2 07-02-2004 05:10 AM
JAVA : cannot find class JFrame? OmniXBro Programming 11 06-04-2004 02:53 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration