Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-08-2008, 06:23 PM
Member
 
Join Date: Jan 2008
Posts: 1
tomitzel is on a distinguished road
actionPerformed problem
Hi, I'm receiveing the folowing error message:Exception in thread "main"
Quote:
java.lang.Error: Unresolved compilation problems:
void is an invalid type for the variable actionPerformed
Syntax error on token "(", ; expected
Syntax error on token ")", ; expected
The java file is this:
Code:
/** * */ package pachet; import java.awt.TextArea; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.*; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; /** * @author Militaru Tomita * */ public class LibrarySystem { Library tomex = new Library("books.txt", "members.txt"); public static void main(String[] args) { @SuppressWarnings("unused") LibrarySystem s = new LibrarySystem(); @SuppressWarnings("deprecation") JFrame fereastra = new JFrame("Tomex v1.0"); fereastra.show(); fereastra.setSize(500, 300); JMenuBar meniu = new JMenuBar(); JMenu menu1 = new JMenu("Carti"); meniu.add(menu1); JMenuItem item1 = new JMenuItem("Adauga o carte"); item1.addActionListener((ActionListener) fereastra); menu1.add(item1); JMenuItem item2 = new JMenuItem("Afiseaza toate cartile"); item2.addActionListener((ActionListener) fereastra); menu1.add(item2); JMenuItem item3 = new JMenuItem("Afiseaza toate cartile disponibile"); item3.addActionListener((ActionListener) fereastra); menu1.add(item3); JMenuItem item4 = new JMenuItem("Afiseaza toate cartile imprumutate"); item4.addActionListener((ActionListener) fereastra); menu1.add(item4); JMenu menu2 = new JMenu("Membri"); meniu.add(menu2); JMenuItem item5 = new JMenuItem("Adauga membru nou"); item5.addActionListener((ActionListener) fereastra); menu2.add(item5); JMenuItem item6 = new JMenuItem("Sterge un membru"); item6.addActionListener((ActionListener) fereastra); menu2.add(item6); JMenuItem item7 = new JMenuItem("Afiseaza toti membrii"); item7.addActionListener((ActionListener) fereastra); menu2.add(item7); JMenu menu3 = new JMenu("Imprumuta"); meniu.add(menu3); JMenuItem item8 = new JMenuItem("Imprumuta o carte"); item8.addActionListener((ActionListener) fereastra); menu3.add(item8); JMenuItem item9 = new JMenuItem("Returneaza o carte"); item9.addActionListener((ActionListener) fereastra); menu3.add(item9); fereastra.setJMenuBar(meniu); TextArea t = new TextArea("Hello", 5, 40); fereastra.add(t); public void actionPerformed(ActionEvent e){ } } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-08-2008, 07:10 PM
tim's Avatar
tim tim is offline
Senior Member
 
Join Date: Dec 2007
Location: South Africa
Posts: 334
tim is on a distinguished road
Method definition
Hello tomitzel

You cannot create a new method definition inside the declaration of a method using modifiers. Also, fereastra does not implement the ActionListener interface, fereastra is only a JFrame. Try extending LibrarySystem form JFrame and let it implement ActionListener.
__________________
If your ship has not come in yet then build a lighthouse.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue with Buttons and ActionPerformed Deathmonger Advanced Java 1 04-17-2008 09:47 AM
Help with actionPerformed Statements wco5002 New To Java 8 03-26-2008 05:02 AM
Problems with jButton ActionPerformed susan AWT / Swing 3 08-07-2007 05:19 AM
method not abstract, does not override actionperformed method. Theman New To Java 1 05-08-2007 07:13 AM


All times are GMT +3. The time now is 11:46 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org