Skip to content

Instantly share code, notes, and snippets.

@kana-ph
Created September 28, 2016 02:19
Show Gist options
  • Save kana-ph/29a4e59e668c1ab9c5330857cb8221b1 to your computer and use it in GitHub Desktop.
Save kana-ph/29a4e59e668c1ab9c5330857cb8221b1 to your computer and use it in GitHub Desktop.
Sample Applet (yuck)
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ApplePen extends JApplet {
public void init() {
this.setLayout(new GridLayout(3, 1));
this.add(new JLabel("I have a pen."));
this.add(new JLabel("I have an apple."));
JButton button = new JButton("Ugh!");
this.add(button);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null, "Apple Pen!");
}
});
}
}
<html>
<head>
<title>Applet</title>
</head>
<body>
<applet code="ApplePen.class" width="100" height="100" />
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment