Codice PHP:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class gui extends JApplet implements ActionListener {
Font ftFont = new Font("Verdana", Font.PLAIN, 10);
JLabel lblTitle;
JComboBox cbList;
JButton bReset;
JTextField txtAnswer;
JButton bSend;
JTextArea txtDescription;
JScrollPane sp_txtDescription;
JTextArea txtQuestion;
JScrollPane sp_txtQuestion;
JLabel lblQuestion;
JButton bNext;
JButton bBack;
JButton bHint;
JComboBox cbGradeList;
JButton bCheck;
JTextArea txtReport;
JScrollPane sp_txtReport;
JLabel lblFile;
JLabel lblLevel;
JButton bRestart;
boolean secureMode=true;
public void init() {
String parametro = getParameter("file");
guiLayout customLayout = new guiLayout();
setFont(ftFont);
setLayout(customLayout);
lblTitle = new JLabel("Title:");
add(lblTitle);
cbList = new JComboBox();
cbList.addItem("item1");
cbList.addItem("item2");
cbList.addActionListener(this);
add(cbList);
bReset = new JButton("Reset");
bReset.addActionListener(this);
add(bReset);
txtAnswer = new JTextField("");
add(txtAnswer);
bSend = new JButton("Send");
bSend.addActionListener(this);
add(bSend);
txtDescription = new JTextArea("description");
sp_txtDescription = new JScrollPane(txtDescription);
add(sp_txtDescription);
txtQuestion = new JTextArea("");
sp_txtQuestion = new JScrollPane(txtQuestion);
add(sp_txtQuestion);
lblQuestion = new JLabel("Question");
add(lblQuestion);
bNext = new JButton("Next >>");
bNext.addActionListener(this);
add(bNext);
bBack = new JButton("<< Back");
bBack.addActionListener(this);
add(bBack);
bHint = new JButton("Hint");
bHint.addActionListener(this);
add(bHint);
cbGradeList = new JComboBox();
cbGradeList.addItem("item1");
cbGradeList.addItem("item2");
cbGradeList.addActionListener(this);
add(cbGradeList);
bCheck = new JButton("Check Answers");
bCheck.addActionListener(this);
add(bCheck);
txtReport = new JTextArea("report");
sp_txtReport = new JScrollPane(txtReport);
txtReport.setEnabled(true);
add(sp_txtReport);
lblFile = new JLabel("File:");
add(lblFile);
lblLevel = new JLabel("Level:");
add(lblLevel);
bRestart = new JButton("Re-Start");
bRestart.addActionListener(this);
add(bRestart);
setSize(getPreferredSize());
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource()==bSend)
{
boolean ok=true;
if (secureMode)
{
MsgBox message = new MsgBox(new JFrame("") , "Alert", "Confirm?", true);
requestFocus();
if (!message.id) ok=false;
message.dispose();
}
if (ok)
{/*next question*/}
}
}
/**
* Called by the browser or applet viewer to inform this JApplet that it
* should start its execution. It is called after the init method and
* each time the JApplet is revisited in a Web page.
*/
public void start()
{
// provide any code requred to run each time
// web page is visited
}
/**
* Called by the browser or applet viewer to inform this JApplet that
* it should stop its execution. It is called when the Web page that
* contains this JApplet has been replaced by another page, and also
* just before the JApplet is to be destroyed.
*/
public void stop()
{
// provide any code that needs to be run when page
// is replaced by another page or before JApplet is destroyed
}
}
class guiLayout implements LayoutManager {
public guiLayout() {
}
public void addLayoutComponent(String name, Component comp) {
}
public void removeLayoutComponent(Component comp) {
}
public Dimension preferredLayoutSize(Container parent) {
Dimension dim = new Dimension(0, 0);
Insets insets = parent.getInsets();
dim.width = 615 + insets.left + insets.right;
dim.height = 256 + insets.top + insets.bottom;
return dim;
}
public Dimension minimumLayoutSize(Container parent) {
Dimension dim = new Dimension(0, 0);
return dim;
}
public void layoutContainer(Container parent) {
Font ftFont = new Font("Verdana", Font.PLAIN, 10);
Insets insets = parent.getInsets();
Component c;
c = parent.getComponent(0);
if (c.isVisible()) {c.setBounds(insets.left+280,insets.top+16,328,24);}
c = parent.getComponent(1);
if (c.isVisible()) {c.setBounds(insets.left+96,insets.top+16,160,24);}
c = parent.getComponent(2);
if (c.isVisible()) {c.setBounds(insets.left+280,insets.top+224,104,24);}
c = parent.getComponent(3);
if (c.isVisible()) {c.setBounds(insets.left+376,insets.top+200,144,24);}
c = parent.getComponent(4);
if (c.isVisible()) {c.setBounds(insets.left+512,insets.top+224,96,24);}
c = parent.getComponent(5);
if (c.isVisible()) {c.setBounds(insets.left+280,insets.top+40,328,40);}
c = parent.getComponent(6);
if (c.isVisible()) {c.setBounds(insets.left+280,insets.top+104,328,96);}
c = parent.getComponent(7);
if (c.isVisible()) {c.setBounds(insets.left+280,insets.top+80,328,24);}
c = parent.getComponent(8);
if (c.isVisible()) {c.setBounds(insets.left+528,insets.top+200,80,24);}
c = parent.getComponent(9);
if (c.isVisible()) {c.setBounds(insets.left+280,insets.top+200,88,24);}
c = parent.getComponent(10);
if (c.isVisible()) {c.setBounds(insets.left+392,insets.top+224,112,24);}
c = parent.getComponent(11);
if (c.isVisible()) {c.setBounds(insets.left+96,insets.top+40,160,24);}
c = parent.getComponent(12);
if (c.isVisible()) {c.setBounds(insets.left+136,insets.top+72,120,24);}
c = parent.getComponent(13);
if (c.isVisible()) {c.setBounds(insets.left+16,insets.top+96,240,152);}
c = parent.getComponent(14);
if (c.isVisible()) {c.setBounds(insets.left+16,insets.top+16,120,24);}
c = parent.getComponent(15);
if (c.isVisible()) {c.setBounds(insets.left+16,insets.top+40,120,24);}
c = parent.getComponent(16);
if (c.isVisible()) {c.setBounds(insets.left+16,insets.top+72,112,24);}
for (int i=0; i<=16; i++)
parent.getComponent(i).setFont(ftFont);
}
}