Vise nyt panel
Man må vel hellere lige smidde lidt point i puljen :)Kan nogen få det her eksempel til at virke, uden man skal trække i vinduet?? Så den altså viser panel3, bare ved at man trykker på knappen?
package untitled18;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
import java.net.*;
import java.io.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
public class Applet1 extends Applet
{
XYLayout xYLayout1 = new XYLayout();
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
JButton jButton1 = new JButton();
JToggleButton jToggleButton1 = new JToggleButton();
JToggleButton jToggleButton2 = new JToggleButton();
JLabel jLabel1 = new JLabel();
JTextArea jTextArea1 = new JTextArea();
//Construct the applet
public Applet1()
{
}
//Initialize the applet
public void init()
{
try
{
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception
{
this.setLayout(xYLayout1);
jPanel1.setBackground(Color.black);
jPanel2.setBackground(UIManager.getColor("ProgressBar.foreground"));
jButton1.setText("jButton1");
jButton1.addMouseListener(new Applet1_jButton1_mouseAdapter(this));
jToggleButton1.setText("jToggleButton1");
jToggleButton2.setText("jToggleButton2");
jLabel1.setText("jLabel1");
jTextArea1.setText("jTextArea1");
jPanel1.add(jButton1, null);
this.add(jPanel1, new XYConstraints(22, 95, 270, 189));
jPanel2.add(jToggleButton1, null);
jPanel2.add(jToggleButton2, null);
jPanel2.add(jLabel1, null);
jPanel2.add(jTextArea1, null);
}
//Get Applet information
public String getAppletInfo()
{
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo()
{
return null;
}
void jButton1_mouseClicked(MouseEvent e)
{
this.add(jPanel2, new XYConstraints(119, 11, 262, 132));
paintComponents(getGraphics());
}
}
class Applet1_jButton1_mouseAdapter extends java.awt.event.MouseAdapter
{
Applet1 adaptee;
Applet1_jButton1_mouseAdapter(Applet1 adaptee)
{
this.adaptee = adaptee;
}
public void mouseClicked(MouseEvent e)
{
adaptee.jButton1_mouseClicked(e);
}
}