Help 'error' Cannot find it.

J

jspence

Can't find error

C:\JAVA\WS_BuyerInterface\src\ws_buyerinterface\Main.java:29: illegal
start of expression
public class BuyerInterface implements ActionListener {

C:\JAVA\WS_BuyerInterface\src\ws_buyerinterface\Main.java:29: ';'
expected
public class BuyerInterface implements ActionListener {

I hope this is something trivial that I have overlooked. It has been a
while since I've done any programming(poor excuse eh).

I'm using netBeans 4.0.
Thanks Jeff.


/*
* Main.java
* Created on January 6, 2005, 1:42 PM
*/
package ws_buyerinterface;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
*
* @author jspence
*/
public class Main {
/** Creates a new instance of Main */
public Main() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
//public static void main(String[] args) {
// TODO code application logic here

public class BuyerInterface implements ActionListener { // line 29

JFrame buyerFrame;
JPanel buyerPanel;
JPanel userPanel;
JTextField fieldOne;
JTextField fieldTwo;
JLabel LabelOne;
JLabel LabelTwo;

public BuyerInterface(){
buyerFrame = new JFrame("Military Produce Group");
buyerFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
buyerFrame.setSize(new Dimension(100,20));


//Create and set up window
buyerPanel = new JPanel(new GridLayout(5,5,2,2));
buyerPanel.setBorder(BorderFactory.createLineBorder
(Color.black));

//userPanel = new JPanel(new GridLayout(5,5,2,2));
//userPanel.setBorder(BorderFactory.createLineBorder(Color.red));

addWidgets();

//Add panel to the window.
buyerFrame.getContentPane().add(buyerPanel,BorderLayout.NORTH);
//buyerFrame.getContentPane().add(userPanel,BorderLayout.SOUTH);

// Display the window.
buyerFrame.pack();
buyerFrame.setVisible(true);
}
private void addWidgets() {
// Create widgets
fieldOne = new JTextField("One",5);
fieldTwo = new JTextField("Two",5);

LabelOne = new JLabel("Label One", SwingConstants.CENTER);
LabelTwo = new JLabel("Label Two", SwingConstants.CENTER);

// Listen to events
fieldOne.addActionListener(this);

// Add widgets to the container
buyerPanel.add(fieldOne); buyerPanel.add(LabelOne);
//userPanel.add(fieldTwo); userPanel.add(LabelTwo);
}
public void actionPerformed(ActionEvent event) {
fieldOne.setText("Hello MPG");
}
private static void createAndShowGUI() {
JFrame.setDefaultLookAndFeelDecorated(true);
BuyerInterface buyerInterface = new BuyerInterface();
}

}
}
}
 
F

Fred L. Kleinschmidt

jspence said:
Can't find error

C:\JAVA\WS_BuyerInterface\src\ws_buyerinterface\Main.java:29: illegal
start of expression
public class BuyerInterface implements ActionListener {

C:\JAVA\WS_BuyerInterface\src\ws_buyerinterface\Main.java:29: ';'
expected
public class BuyerInterface implements ActionListener {

I hope this is something trivial that I have overlooked. It has been a
while since I've done any programming(poor excuse eh).

I'm using netBeans 4.0.
Thanks Jeff.

/*
* Main.java
* Created on January 6, 2005, 1:42 PM
*/
package ws_buyerinterface;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
*
* @author jspence
*/
public class Main {
/** Creates a new instance of Main */
public Main() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
//public static void main(String[] args) {
// TODO code application logic here

Where is the "}" that terminates "main" ?
 
O

Owen Jacobson

Can't find error

C:\JAVA\WS_BuyerInterface\src\ws_buyerinterface\Main.java:29: illegal
start of expression
public class BuyerInterface implements ActionListener {

C:\JAVA\WS_BuyerInterface\src\ws_buyerinterface\Main.java:29: ';' expected
public class BuyerInterface implements ActionListener {

I hope this is something trivial that I have overlooked. It has been a
while since I've done any programming(poor excuse eh).

I'm using netBeans 4.0.
Thanks Jeff.


/*
* Main.java
* Created on January 6, 2005, 1:42 PM */
package ws_buyerinterface;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
*
* @author jspence
*/
public class Main {
/** Creates a new instance of Main */ public Main() {
}
/**
* @param args the command line arguments */

Here, you begin the main method...
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
//public static void main(String[] args) {
// TODO code application logic here

Here, you go on with the rest of the class without ending the main
method's block.
public class BuyerInterface implements ActionListener { // line 29

JFrame buyerFrame;
JPanel buyerPanel;

....snip...

You might have better luck in the future in comp.lang.java.help, at least
until your grasp of the language itself is a bit more firm.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top