| | |
Adding components to JApplet
![]() |
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
One more thing, use this instead of the usual constructor:
also, you don't need a main method, as you will be calling it from an html file.
Java Syntax (Toggle Plain Text)
public void init() { }
also, you don't need a main method, as you will be calling it from an html file.
here is a really simple example, i hope this helps
Java Syntax (Toggle Plain Text)
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class GUIOneB extends JApplet implements ActionListener { JButton jOptionConfirm, jOptionInput, jOptionMessage; Container c; public void init() { c = getContentPane(); c.setBackground(Color.yellow); c.setLayout(new FlowLayout()); jOptionConfirm = new JButton("showConfirmDialog"); jOptionInput = new JButton("showOptionInputDialog"); jOptionMessage = new JButton("showOptionMessageDialog"); jOptionConfirm.addActionListener(this); jOptionInput.addActionListener(this); jOptionMessage.addActionListener(this); c.add(jOptionConfirm); c.add(jOptionInput); c.add(jOptionMessage); } public void actionPerformed(ActionEvent e) { String returnValue; if(e.getSource() == jOptionConfirm) JOptionPane.showConfirmDialog(this, "Confirm Something"); else if(e.getSource() == jOptionInput) returnValue = JOptionPane.showInputDialog("Enter Something."); else if(e.getSource() == jOptionMessage) JOptionPane.showMessageDialog(this, "Hi from a message dialog."); } }
![]() |
Similar Threads
- Adding .COM Components to Visual Web Developer 2008 (ASP.NET)
- Deleting components in D2007 (Pascal and Delphi)
- Adding components at runtime ontop of a scrollable table (Java)
- Java GUI JOptionPane.showMessageDialog (Java)
- Subpanel problem (Java)
- How to position buttons/boxes in a JTabbed Pane? (Java)
Other Threads in the Java Forum
- Previous Thread: Constructor
- Next Thread: Number Rounding
| Thread Tools | Search this Thread |
addball android applet application apps array automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) button card class classes client code collision columns component constructor crashcourse css database designadrawingapplicationusingjavajslider draw eclipse ee error eventlistener exception expand fractal free game givemetehcodez graphics gui guidancer html ide image integration intellij j2me java javaarraylist javadoc javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia jvm linux loan loop method migrate mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle phone physics plazmic print problem program programming project radio scanner server service set sharepoint smart sms smsspam software sql subclass support swing textfield threads tree trolltech unlimited utility windows






