Hi
i came across a problem with for my GUI project.
for my class project i am designing an appointment calendar. for the layout i am using absolute positioning. so when i run my login class, some times the frame pops-up to a weird default Java frame (not re sizable) there is nothing one can do except close it and run it again. and it decides to pop-up weird randomly i don't notice a pattern.
not sure if the problem is with the absolute positioning layout or something else. will really appreciate if any one can help
Thanks

We can only help if we can see the code, otherwise there is no way for us to know what is wrong, it could be something simple your overlooking.

the only thing I can think of is that the frame is not resizeable try setResizeable(true)

heres the code for my login. i dont want my window to be re-sizeable. i can't really put my finger as to what exactly is wrong. the only thing i can think of is layout. Doe absolute positioning run into any similar kind of problems?

public class login extends JFrame  implements ActionListener
{

	 JTextField user;
	 JLabel UserId;
	 JLabel welcome;
	 JButton login;
	 JButton exit;
	 static Control c;
	 BackEnd be;
	 User currentuser;
	 
	 
	 
	 
	 public login(String s) throws IOException, ClassNotFoundException
	 {
		 
		 JPanel pane = new JPanel();
		 pane.setVisible(true);
		 pane.setLayout(null);
		 
		 c=new Control();
		 be=new BackEnd();
		 login = new JButton("Login");
		 login.addActionListener(this);
		 exit= new JButton("Exit");
		 exit.addActionListener(this);
		UserId = new JLabel("UserID");
		 welcome = new JLabel("Welcome!");
		 user = new JTextField(15);

		 pane.add(login);
		 pane.add(exit);
		 pane.add(UserId);
		 pane.add(welcome);
		 pane.add(user);
		 
		 login.setBounds(125, 250, 100, 35);
			
			exit.setBounds(350,250 ,100,35);
			
			UserId.setBounds(75, 135, 50,35);
			user.setBounds(130, 135,320, 45);
			
			welcome.setBounds(265,30, 200, 60);
			
			 
			 	add(pane);
		 
	 }
public void actionPerformed(ActionEvent e) {
	 }
	 
private static final long serialVersionUID = 2547870885372185472L;

public static void main(String[] args) throws IOException, ClassNotFoundException {
		
		login l = new login("Login");
		//l.setSize(500,400);
		l.setPreferredSize(new Dimension(550, 400));
		l.pack();
		l.setVisible(true);
		l.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      
		l.setResizable(false);
		
		

	
	}
 


}

Edited 7 Years Ago by __avd: Add [code] tags. Encase your code in: [code] and [/code] tags.

I didn't run into any problems with your code, I added the necessary imports to run it, and commented out the five lines of code that deal with classes that you did not include:

static Control c
BackEnd be
User currentuser
...
c=new Control();
be=new BackEnd()

and your code runs fine, the frame was just what I expected it to look like. The only thing I see that your code isn't doing, is using the String argument for the constructor of login, I assume you meant that to be the title of the frame, so I suggest that you put super(s) at the first line of the constructor.

I'm not sure if it matters, but what JRE and JDK is your system using?
and what IDE are you using (shouldn't make a difference) I used BlueJ to test your code, if your using netbeans or eclipse I can test on those later.

This article has been dead for over six months. Start a new discussion instead.