Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Swing / AWT / SWT
JFrame
P. Sagdeo
Ranch Hand
Posts: 67
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi all,
How can I launch a cutom JFrame from an
applet
?
Thanks,
Parth
Craig Wood
Ranch Hand
Posts: 1535
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class LaunchingAJFrame extends JApplet { public void init() { JButton launch = new JButton("launch frame"); launch.addActionListener(new ActionListener() { int frameCount = 0, dx = 75, dy = 75; public void actionPerformed(ActionEvent e) { final JFrame f = new JFrame("frame " + ++frameCount); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { f.dispose(); } }); f.setSize(200,100); f.setLocation(400 + frameCount*dx, 200 + frameCount*dy); f.setVisible(true); } }); getContentPane().add(launch); } public static void main(String[] args) { JApplet applet = new LaunchingAJFrame(); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(applet); f.setSize(300,300); f.setLocation(200,200); applet.init(); applet.start(); f.setVisible(true); } }
P. Sagdeo
Ranch Hand
Posts: 67
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks, your help was much appriciated, but now the question arises:
How can one paint to the JFrame? (Like paintcomponent for japplets)
Thanks!
P. Sagdeo
Ranch Hand
Posts: 67
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Sorry, I didn't realize then that a JFrame was merely a container, not an actual component
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
NetBeans IDE 5.5
how to invoke FileDialog from a dialog?
How to display JFrame with orientation Right_To_Left in Windows 7 64bit..?
painting problems
why no default close button in JDialog
More...