Question:

I am having problems with getting my panels to work using Java?

by  |  earlier

0 LIKES UnLike

Code:

class bVendorListener implements ActionListener

{

public void actionPerformed(ActionEvent e) //when the vendor button is clicked

{

JPanel vendorPanel = JPanel();

vendorPanel.setLayout(new BoxLayout(vendorPanel, BoxLayout.PAGE_AXIS));

}

private vendorPanel()

{

Label vendorNameLabel = new Label("Vendor Name");

TextField vNameField = new TextField();

Label vendorAddLabel = new Label("Vendor Address");

TextField vAddField = new TextField();

Label vendorCityLabel = new Label("Vendor City");

TextField vCityField = new TextField();

Label vendorStateLabel = new Label("Vendor State");

TextField vStateField = new TextField();

Label vendorZipLabel = new Label("Vendor Zip");

TextField vZipField = new TextField();

Label vendorPhoneLabel = new Label("Vendor Phone");

TextField vPhoneField = new TextField();

Label vendorContactLabel = new Label("Vendor Contact");

TextField vContactField = new TextField();

Label vendorProductLabel = new Label("Vendor Product");

TextField vProductField = new TextField();

}

}

Error:

Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem:

The method JPanel() is undefined for the type PoolDesign.bVendorListener

at fp.PoolDesign$bVendorListener.actionPerf...

at javax.swing.AbstractButton.fireActionPer... Source)

at javax.swing.AbstractButton$Handler.actio... Source)

at javax.swing.DefaultButtonModel.fireActio... Source)

at javax.swing.DefaultButtonModel.setPresse... Source)

at javax.swing.plaf.basic.BasicButtonListen... Source)

at java.awt.AWTEventMulticaster.mouseReleas... Source)

at java.awt.Component.processMouseEvent(Unk... Source)

at javax.swing.JComponent.processMouseEvent... Source)

at java.awt.Component.processEvent(Unknown Source)

at java.awt.Container.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unk... Source)

at java.awt.Container.dispatchEventImpl(Unk... Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.LightweightDispatcher.retargetM... Source)

at java.awt.LightweightDispatcher.processMo... Source)

at java.awt.LightweightDispatcher.dispatchE... Source)

at java.awt.Container.dispatchEventImpl(Unk... Source)

at java.awt.Window.dispatchEventImpl(Unknow... Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknow... Source)

at java.awt.EventDispatchThread.pumpOneEven... Source)

at java.awt.EventDispatchThread.pumpEventsF... Source)

at java.awt.EventDispatchThread.pumpEventsF... Source)

at java.awt.EventDispatchThread.pumpEvents(... Source)

at java.awt.EventDispatchThread.pumpEvents(... Source)

at java.awt.EventDispatchThread.run(Unknown Source)

 Tags:

   Report

1 ANSWERS




  1. u have write first line like following in actionPerformed function

    JPanel vendorPanel = JPanel();

    write it  as following

    JPanel vendorPanel = new JPanel();

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.