pogubiłem się poradźcie co dopisac do drugiego okna by przyciski były aktywne?
prawdopodobnie w metodzie init() ...
package experyment4;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
/////////Drugie okno
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.*;
import javax.swing.border.Border;
public class OKNO1
extends Applet implements ActionListener {
boolean isStandalone = false;
BorderLayout borderLayout1 = new BorderLayout();
/////////Deklaracja buttonow na 1 okno
Button button1, button2;
Label label, label2, label3, label4;
////////////////////////////////////////
////////deklaracja 2 okna
dialogframe f;
//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
//Construct the applet
public OKNO1() {
}
//Initialize the applet
public void init() {
///////////Do okna1 komponenty
button1 = new Button("przycisk");
add(button1);
button1.addActionListener(this);
button2 = new Button("Anuluj");
add(button2);
button2.addActionListener(this);
label = new Label(" Długi napis okno1 ");
add(label);
label2 = new Label(" ssssssssssssssssssss ");
add(label2);
label3 = new Label(" wykonał: fffffffffff ");
add(label3);
label4 = new Label(" ssssssssssssssssssssssss ");
add(label4);
label.setFont(new java.awt.Font("Bitstream Vera Serif", Font.PLAIN, 18));
label.setForeground(Color.red);
label2.setFont(new java.awt.Font("Bitstream Vera Serif", Font.PLAIN, 18));
label3.setFont(new java.awt.Font("Bitstream Vera Serif", Font.PLAIN, 18));
label2.setForeground(Color.red);
label3.setForeground(Color.blue);
label4.setFont(new java.awt.Font("Bitstream Vera Serif", Font.PLAIN, 18));
label4.setForeground(Color.blue);
/////////////////////////////
///Inicjujemy 2 okno
f = new dialogframe("Okno obsługi dfasidfaosidjfsoid");
f.setSize(450,450);
//
try {
jbInit();
}
catch (Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
}
public void actionPerformed(ActionEvent event)
{
if (event.getSource().equals(button1)){
f.setVisible(true);
}
if(event.getSource().equals(button2)){
System.exit(0);
}
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
public static void main(String[] args){}
}
////////////Drugie okno Frame dialogframe/////////////////////////////////////////
class dialogframe
extends Frame implements ActionListener, WindowListener{
//////deklaracje nowych buttonów
JLabel jLabel1, jLabel2, jLabel3, jLabel6, jLabel4;
JRadioButton jRadioButton1, jRadioButton2, jRadioButton3, jRadioButton4;
JButton jButton1, jButton2, jButton4, jButton3;
//////////////////
public dialogframe() {}
public void init() {
}
public static void main(String[] args) {}
public String[][] getParameterInfo() {
return null;
}
dialogframe(String title) {
super(title);
setLayout(new FlowLayout());
addWindowListener(this);
JLabel jLabel1 = new JLabel();
add(jLabel1);
jLabel1.setFont(new java.awt.Font("Georgia", Font.BOLD, 13));
jLabel1.setForeground(UIManager.getColor("textHighlight"));
jLabel1.setMaximumSize(new Dimension(440, 75));
jLabel1.setMinimumSize(new Dimension(440, 75));
jLabel1.setPreferredSize(new Dimension(440, 75));
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
jLabel1.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel1.setText(" fafgsjdfgskljfngjsfdngskdfnsfdlg ");
JButton jButton1 = new JButton("Wybierz cofdad");
add(jButton1);
jButton1.addActionListener(this);
JLabel jLabel3 = new JLabel();
add(jLabel3);
jLabel3.setMaximumSize(new Dimension(150, 150));
jLabel3.setMinimumSize(new Dimension(150, 150));
jLabel3.setPreferredSize(new Dimension(150, 150));
jLabel3.setHorizontalAlignment(SwingConstants.CENTER);
jLabel3.setText("");
JButton jButton2 = new JButton("Zastosuj dfjgnsdfjn");
add(jButton2);
jButton2.addActionListener(this);
JLabel jLabel2 = new JLabel();
add(jLabel2);
jLabel2.setSize(50, 15);
jLabel2.setText("");
JRadioButton jRadioButton1 = new JRadioButton();
add(jRadioButton1);
JRadioButton jRadioButton2 = new JRadioButton();
add(jRadioButton2);
JRadioButton jRadioButton3 = new JRadioButton();
add(jRadioButton3);
JRadioButton jRadioButton4 = new JRadioButton();
add(jRadioButton4);
JButton jButton3 = new JButton("Właściwości sdfgsdf");
add(jButton3);
jButton3.addActionListener(this);
JLabel jLabel6 = new JLabel();
JButton jButton4 = new JButton();
JLabel jLabel4 = new JLabel();
jButton1.setHorizontalTextPosition(SwingConstants.CENTER);
jRadioButton1.setText("sgjsdjklfgd");
jRadioButton2.setText("sdfgdjfgjkd");
jRadioButton3.setText("ertkrtjertr");
jRadioButton4.setText("dsfasdhudsh");
jLabel2.setFont(new java.awt.Font("Georgia", Font.BOLD, 13));
jLabel2.setForeground(UIManager.getColor("textHighlight"));
jLabel2.setToolTipText("");
jLabel2.setHorizontalAlignment(SwingConstants.CENTER);
jLabel2.setHorizontalTextPosition(SwingConstants.LEADING);
jLabel2.setText(" dfgsjdfjgnskdjfngskdfjgnskdfjngsdkfjnhgjfhghhhh ");
jLabel6.setMaximumSize(new Dimension(300, 15));
jLabel6.setMinimumSize(new Dimension(300, 15));
jLabel6.setPreferredSize(new Dimension(300, 15));
jLabel6.setText("");
jButton4.setText("Exit");
add(jButton4);
jButton4.addActionListener(this);
jLabel4.setMaximumSize(new Dimension(200, 15));
jLabel4.setMinimumSize(new Dimension(200, 15));
jLabel4.setPreferredSize(new Dimension(200, 15));
jLabel4.setText("");
}
public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(jButton1)) {
dispose();
}
if (e.getSource().equals(jButton2)) {
//Zastosuj --> dodaj kod
}
if (e.getSource().equals(jButton4)){
System.exit(0);
}
}
public void windowClosing(WindowEvent event) {
dispose();
}
public void windowClosed(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
}