Questa è la classe main grafica ke richiama la classe....
package prova;
public class main extends javax.swing.JDialog {
public main(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
//jTextField1.setVisible(false);
}
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton1 = new javax.swing.JButton();
jTextField1 = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setAlwaysOnTop(true);
jButton1.setText("jButton1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jTextField1.setText("jTextField1");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(93, 93, 93)
.addComponent(jButton1)
.addGap(18, 18, 18)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(142, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(152, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(125, 125, 125))
);
pack();
}// </editor-fold>
public void attiva_bottone(java.awt.Frame o,boolean modal){
jTextField1.setVisible(false);
//xkè nn và??
System.out.println("main");
jTextField1.validate();
jTextField1.repaint();
jTextField1.show();
//super(parent, modal);
initComponents();
validate();
setVisible(false);
jTextField1.repaint();
//show();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new classe().prova();
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
main dialog = new main(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JTextField jTextField1;
// End of variables declaration
}
ora la classe ke dovrebbe attivarmi il bottone...
qui è semplificato,ma nel programma dovrebbe attivarlo a seconda della verifica di una condizione specifica.
package prova;
public class classe {
public classe(){}
public void prova(){
System.out.println("classe");
new main(null, true).attiva_bottone(null,true);
}
ho provato anke a rendere pubblico il bottone...ma nulla.!.