Good Day!
My professor in object oriented programming wants us to collect a JFrame form to a class.... he told us the code but it did not work...Hope you may help me...and thanks in advance
import javax.swing.JOptionPane;
public class Firm
{
//----------------------------------------------------------
// Creates a staff of employees for a firm and pays them.
//----------------------------------------------------------
public static void main (String[] args)
{
JOptionPane.showMessageDialog(null,"**=======TUP-Manila IT Corporation=======**");
Staff personnel = new Staff();
personnel.payday();
}
}
And this is my JFrame
public class MyForm extends javax.swing.JFrame {
/** Creates new form MyForm */
public MyForm() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setText("jButton1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
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(154, 154, 154)
.addComponent(jButton1)
.addContainerGap(173, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(209, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(68, 68, 68))
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
MyForm Firm =new MyForm();
Firm.setVisible(true);
//This is what our professor told us to do but it did not work
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MyForm().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
// End of variables declaration
}