How to maximize a JFrame Form?
Hello friends..
Posting for the first time since i am really an amateur to java.
What i am trying to do is making a GUI based Application in Netbeans.
I have a JFrame form in my application. Now i need to open this JFrame Form into full screen and maximized(obviouslyd different systems have different resolutions. So how to get to open my application in fullscreen on any machine??)
Also I Would like to ask about how to put up a picture in a JPanel. I have a surface knowledge of the topic that you have to pass the image as an object but i really don't know how.
Please help
Thanks in Advance..
And Thanks to all the members of the forum, You guys are doing a really Great Job helping out people with their problems.:)
Regards.
Re: How to maximize a JFrame Form?
To maximize a JFrame you need the following code.
Code Java:
myFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
And to put an image in a JPanel you would create a JLabel and set the ImageIcon for that JLabel.
Code Java:
someLabel.setIcon(new ImageIcon("C:\\Documents and Settings\\User\\Desktop\\image.png"));
1 Attachment(s)
Re: How to maximize a JFrame Form?
Thanks buddy...:) I think that shall work :) cheers...:)
The Maximizing worked..
but the code to place an image ain't working
Basically I am using a JDesktopPane to place internal frames in my Application and i want to apply Image to this JDesktopPane as a background.
Now what happens is when i use a label inside this DesktopPane to place an image as :
Code :
public class User extends javax.swing.JFrame
{
public User()
{
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
image.setIcon(new ImageIcon("D:\\Visuals\\walls\\Windows-8-Grass-Wallpaper1.jpg"));
initComponents();
paneltransact.setVisible(false);
panelmastershoots.setVisible(false);
panelmasterview.setVisible(false);
//int height,width;
}
where during runtime the following error is generated:
Attachment 1348
please help i also tried placing a panel inside the desktop pane and then placing a label inside the panel and then working out and same error showed up.
Re: How to maximize a JFrame Form?
Where did you initialize the JLabel? It seems like you might be missing the following.
Code Java:
JLabel image = new JLabel();
// And then then set the imageicon
image.setIcon(new ImageIcon("D:\\Visuals\\walls\\Windows-8-Grass-Wallpaper1.jpg"));
Re: How to maximize a JFrame Form?
I placed a JLabel component named "image" and it was automatically initialized inside the class(as it is done in netbeans). And then used the code :
Code :
image.setIcon(new ImageIcon("D:\\Visuals\\walls\\Windows-8-Grass-Wallpaper1.jpg"));
and it still ain't working...:( sorry...i think will have to live without an image in project...
its okay...i can manage with that :)
By the way thanks for ur efforts..:)