Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set AppFrame (JFrame) Properties

Status
Not open for further replies.

karlomutschler

Programmer
Jun 5, 2001
75
DE
Hi all,
I have created an AppFrame (GUI) by using JFrame and following code:

import javax.swing.JFrame;

public class SimpleFrame extends JFrame {
public SimpleFrame() {
super("Application Title");
setSize(800, 600);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public static void main(String[] args) {
SimpleFrame sf = new SimpleFrame();
}
}

How do I set the following AppFrame Properties ?
Border Type None Single Double Resize
Initial Size Maximised Normal Iconized

and set the FramePosition (TopLeftCorner) to
X-Pos Center
Y-Pos Center meistertools@gmx.net
 
Frame Position :
setLocation(200, 200); //roughly centre - change ints to suit!

Initial Size :
default is Frame.NORMAL, but you can use the method :
setState(Frame.NORMAL) //need to import java.awt.Frame

As regards to the Border, I'm not sure whether you can set the border type in a JFrame - if you can I'm not sure how anyway. You could try putting a JPanel inside the JFrame, as its easy to set the border type in a JPanel :

Have a look at the javax.swing.border.* package, but as a guide :
SoftBevelBorder bevel = new SoftBevelBorder(SoftBevelBorder.RAISED);
JPanel panel = new JPanel();
panel.setBorder(bevel);
///other panel methods etc

Then to add your panel to your JFrame :
getContentPane().add(panel);

Hope this helps,

Ben
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top