hello friends,
i've 2 forms 1) Home1 and 2)NewAccountForm


in Home1 when a button clicked i perform

NewAccountForm newAcc= new NewAccountForm ();
newAcc.setVisible(true);
this.setVisible(false);

i.e. make invisible current(Home1) form and visible NewAccountForm , no problem here.

BUT

in NewAccountForm after a button clicked when i try to make invisible current(NewAccountForm)form and visible Home1 form by;

Home1 home1 = new Home1();
home1.setVisible(true);
this.setVisible(false);

error comes is


Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not yet implemented
at Home1.<init>(Home1.java:32)
at NewAccountForm.button2ActionPerformed(NewAccountForm.java:419)
at NewAccountForm.access$800(NewAccountForm.java:23)
at NewAccountForm$9.actionPerformed(NewAccountForm.java:156)
at java.awt.Button.processActionEvent(Button.java:392)
at java.awt.Button.processEvent(Button.java:360)
at java.awt.Component.dispatchEventImpl(Component.java:4410)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)


what is the reason? can anybody explain the reason and give solution?

Recommended Answers

All 10 Replies

take a look at this, but I would say the name of the Exception class that is thrown explains a lot on its own as well

Check me

The exception message includes the exact line where it was thrown, ie
Home1.<init>(Home1.java:32)
what is the code at that line?

throw new UnsupportedOperationException("Not yet implemented");
this is it james, so wht shud i supposed to do here?

throw new UnsupportedOperationException("Not yet implemented");
this is it james, so wht shud i supposed to do here?

I sincerely doubt you've hardcoded this line in your java code, at line 32 in your Home1.java file.

thát is the code JamesCherril was asking about. The stacktrace we could find in your first post, but we're interested in the code that caused the exception, which is:

Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not yet implemented
at Home1.<init>(Home1.java:32)

line 32 of the code in your Home1.java file.

Bit of a puzzle this one.
We don't have enough info; the important code hasn't been posted, but it looks like the OP's code does actually throw that exception (?). If that's the case it will be immediately preceded by some kind of if test that checks for the condition that causes the exception OR it will be the body of a method (a constructor in this case) that has not been written yet. Either way, someone has to look at that code.

Sounds like the OP got a skeleton program with lots of "to do later" methods
that have: throw new UnsupportedOperationException("Not yet implemented");
in them in case those methods were forgotten to be filled in.

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;






/**
 *
 * @author Dhanesh
 */
public class Home1 extends javax.swing.JDialog implements ActionListener {
   

    /** Creates new form Home1 */
    public Home1(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    Home1() {
        throw new UnsupportedOperationException("Not yet implemented");

    }
  

    /** 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() {

        jPanel1 = new javax.swing.JPanel();
        button1 = new java.awt.Button();
        button2 = new java.awt.Button();
        button3 = new java.awt.Button();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("HOME"); // NOI18N
        setBackground(new java.awt.Color(51, 255, 153));
        setFont(new java.awt.Font("Copperplate Gothic Bold", 0, 14)); // NOI18N
        getContentPane().setLayout(new java.awt.GridBagLayout());

        jPanel1.setBackground(new java.awt.Color(225, 244, 249));
        jPanel1.setName("jPanel1"); // NOI18N

        button1.setLabel("Create new Account");
        button1.setName("button1"); // NOI18N
        button1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button1ActionPerformed(evt);
            }
        });

        button2.setLabel("Search for Client");
        button2.setName("button2"); // NOI18N

        button3.setLabel("Clients liable for Fine");
        button3.setName("button3"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(376, Short.MAX_VALUE)
                .addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(58, 58, 58))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(284, Short.MAX_VALUE)
                .addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(161, 161, 161))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(210, 210, 210)
                .addComponent(button3, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(230, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(43, 43, 43)
                .addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(55, 55, 55)
                .addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(60, 60, 60)
                .addComponent(button3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(83, Short.MAX_VALUE))
        );

        getContentPane().add(jPanel1, new java.awt.GridBagConstraints());

        pack();
    }// </editor-fold>

    private void button1ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        if(evt.getSource()==button1)
        {    // JOptionPane.showMessageDialog(null, "tested.");
        NewAccountForm newAcc= new NewAccountForm ();
        newAcc.setVisible(true);
        this.setVisible(false);
        
         
        }
    }
  /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Home1 dialog = new Home1(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    private java.awt.Button button1;
    private java.awt.Button button2;
    private java.awt.Button button3;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration

    public void actionPerformed(ActionEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    

}

hi friends, sorry for inconvenience, here above is code of Home1.java , the error is at the constructor which is highlighted with red color and it was generated when i created object of this class in NewAccountForm's ActionPerformed method which is given below ...

finally{
Home1 home1 = new Home1();
home1.setVisible(true);
this.setVisible(false);
}

i am putting only the code snippet that causing problem from NewAccountForm.java because the file is big one.

i tried to get the cause of the exception but it's returning null that means the cause is nonexistent or unknown.
i just wanted to open NewAccountForm.java from Home1.java, which is done, no problem but when i click submit or cancel button in NewAccountForm.java, i want it to be invisible (which is doing) and want to reopen or make visible Home1.java again, but i m getting problem here...
how can i do that?

are you serious????

Home1() {
        throw new UnsupportedOperationException("Not yet implemented");

    }

what exactly do you think this does when you call this method?
My guess is ... it will cause an UnsupportedOperationException with the message " Not yet implemented " to be thrown, but I could be wrong off course.

you are calling

Home home1 = new Home();

which obviously goes to the default constructor I've just copy-pasted here. either you link it to the constructor which does take arguments, or you fill in the code you need there.

but, and here's the stinger: you allready have an instance of Home, which was created here:

public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Home1 dialog = new Home1(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

don't create a new instance of Home, just set the visible flag on that one to true, and return to this instance.

hey, m sorry for late reply, i got away with that problem, i needed to define appropriate constructor in called frame....
thank you. :-)

commented: how to solved your problem please ,because I have same the problem +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.