Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Application and Web Development > Java
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 07-22-2006, 06:26 PM   #1 (permalink)
benzspida
Registered User
 
Join Date: Jun 2006
Posts: 10
benzspida is on a distinguished road
java swing help

just stated learning Java. trying to create a java EmailFrame which will display a blank Submission Complete message.

but i keep getting error message when ever I try to compile the code.

error (Can not find symbol symbol method submit)

this is what my script looks like

Code:
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class EmailFrame extends JFrame { private InfoPanel infoPanel = new InfoPanel(); public EmailFrame() { super("Shared Listener Test"); setJMenuBar(createMenuBar()); getContentPane().add(infoPanel); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(190,150); setLocation(300,300); } private JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); JMenu menu; JMenuItem item; item = new JMenuItem("Exit"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.exit(0); } }); return menuBar; } public static void main(String[] args) { JFrame f = new EmailFrame(); f.setVisible(true); } } class InfoPanel extends JPanel { private JTextField firstname = new JTextField(10); private JTextField lastname = new JTextField(10); private JTextField email = new JTextField(15); private JButton button = new JButton("Submit"); public InfoPanel() { button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { submit(); } }); setLayout(new GridLayout(4,2)); add(new JLabel("Firstname")); add(firstname); add(new JLabel("Lastname")); add(lastname); add(new JLabel("Email")); add(email); add(button); } public void clear() { firstname.setText(""); lastname.setText(""); email.setText(""); } }
__________________
benzspida is offline   Reply With Quote
Old 07-23-2006, 02:21 AM   #2 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,114
Belisarius is on a distinguished road
You never defined the method "submit", but placed a call to it in public InfoPanel()
__________________
GitS
Belisarius is offline   Reply With Quote
Old 07-23-2006, 06:42 AM   #3 (permalink)
benzspida
Registered User
 
Join Date: Jun 2006
Posts: 10
benzspida is on a distinguished road
thanks for your help
__________________
benzspida is offline   Reply With Quote
Old 07-23-2006, 02:49 PM   #4 (permalink)
spidermo
Recruit
 
Join Date: Jun 2006
Posts: 14
spidermo is on a distinguished road
I believe this part:
Code:
private JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); JMenu menu; JMenuItem item; item = new JMenuItem("Exit"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.exit(0); } }); return menuBar; }
Should be like this:
Code:
private JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); JMenu menu; JMenuItem item; menu.add(item); menuBar.add(menu); item = new JMenuItem("Exit"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.exit(0); } }); return menuBar; }
__________________
spidermo is offline   Reply With Quote
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
Java Resources Belisarius Java 0 03-28-2005 02:03 PM
Java Swing - Multiple Perspectives unwiseone Java 1 05-18-2004 03:08 PM
IBM urges Sun to make Java open source redhead Code Newbie News 0 03-01-2004 10:39 PM
Java Class Basics: Static Methods bdl Java 0 02-29-2004 02:25 PM
What is OOP and Java? srt42 Java 0 04-07-2003 01:21 AM


All times are GMT -8. The time now is 12:35 AM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle