J
Jenny
Hi,
Could you try the code? It does not work.
Could you try the code? It does not work.
ApplicationHi,
Is that possible to convert a Java Applet Code to a JavaCode
without doing big modification to my existing Java applet code? Please give
me some guides...
Thank you!
No problem. Just add the following code (with your class name
modifications) to your class that extends Applet:
public static void main(String args[])
{
YourAppletClassName applet = new YourAppletClassName();
Frame frame = new Frame("Needs a Title");
frame.addWindowListener(new windowListener());
// set the layout and add the applet
frame.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints
();
constraints.gridx = 0;
constraints.gridy = 0;
constraints.weightx = 100;
constraints.weighty = 100;
constraints.anchor = GridBagConstraints.CENTER;
constraints.fill = GridBagConstraints.BOTH;
frame.add(applet, constraints);
frame.pack();
frame.setSize(850, 575);
frame.validate();
// Center the window
Dimension screenSize = Toolkit.getDefaultToolkit
().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height)
{
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width)
{
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width -
frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
frame.setVisible(true);
}
Sent via Deja.com http://www.deja.com/
Before you buy.