Results 1 to 3 of 3
Thread: Help With Code
- 05-17-2011, 11:22 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 93
- Rep Power
- 0
Help With Code
Hello. I'm trying to write this bit of code I got out of a book about java. I believe I have copied the code correctly, yet when I compile it, I get an error message: invalid method declaration; return type required; public FeedInfo() {
Can anyone show me my error? Thanks in advance.
Java Code:import java.awt.GridLayout; import java.awt.event.*; import javax.swing.*; public class FeedInfor extends JFrame { private JLabel nameLabel = new JLabel("Name: ", SwingConstants.RIGHT); private JTextField name; private JLabel urlLabel = new JLabel("URL: ", SwingConstants.RIGHT); privateJTextField url; private JLabel typeLabel = new JLabel("Type: ", SwingConstants.RIGHT); privateJTextField type; public FeedInfo() { super("Feed Information"); setSize(400, 105); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLookAndFeel(); String response1 = JOptionPane.showInputDialog (null, "Enter the site name: "); name = newJTextField(response1, 20); String response2 = JOptionPane.showInputDialog (null, "Enter the site address: "); url = new JTextField(response2, 20); String[] choices = { "Personal", "Commercial", "Unknown" }; int response3 = JOptionPane.showOptionDialog (null, "What type of site is it?", "Site Type", 0, JOptionPane.QUESTION_MESSAGE, null, choices, choices[0]); type = new JTextField(choices[response3], 20); setLayout(new GridLayout(3, 2)); add(nameLabel); add(name); add(urlLabel); add(url); add(typeLabel); add(type); setLookAndFeel(); setVisible(true); } private void setLookAndFeel() { try { UIManager.setLookAndFee( UIManager.getSystemLookAndFeelClassName ()); SwingUtilities.updateComponentTreeUI(this); } catch (Exception e) { System.err.println("Couldn't use the system " + "look and feel: " + e); } } public static void main(String[] arguments) { FeedInfo frame = new FeedInfo(); } }
- 05-17-2011, 11:36 PM #2
Member
- Join Date
- Mar 2011
- Posts
- 64
- Rep Power
- 0
You have a typo in your ClassName....
change it to
Java Code:public class FeedInfo extends JFrame {
Java Code:public FeedInfo() {
Last edited by cultclassic; 05-17-2011 at 11:40 PM.
- 05-18-2011, 01:17 AM #3
Member
- Join Date
- Mar 2011
- Posts
- 93
- Rep Power
- 0
Similar Threads
-
C server code - Java CLient Code _ TCP Connection Problem
By rmd22 in forum NetworkingReplies: 0Last Post: 02-21-2011, 12:50 PM -
can any one pls send me a sample code for calling a jsp code in swings
By sniffer139 in forum AWT / SwingReplies: 1Last Post: 03-04-2010, 12:19 PM -
Convert java code to midlet code
By coldvoice05 in forum New To JavaReplies: 1Last Post: 08-12-2009, 12:14 PM -
Convert java code to midlet code
By coldvoice05 in forum Advanced JavaReplies: 1Last Post: 08-09-2009, 02:21 PM -
Generating Code Automatically Using Custom code Template In Eclipse
By JavaForums in forum EclipseReplies: 1Last Post: 04-26-2007, 04:52 PM
Bookmarks