[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.4

Syntax error on token "(", ; expected Java Eclipse

Asked by clivecrawdevil in New to Java Programming, Java Editors & IDEs, Java Programming Language

Tags: token, error, syntax, expected, java

Hi Experts

Using Eclipse and getting this error Syntax error on token "(", ; expected on line 59 it's the one with the main method on it.

It is saying something about the brackets not being right, i have tried commenting out lines and retyping the main method cannot seem to find whats wrong?

Any help will be greatly appriciated.

Code follows

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;




public class PanelTest {
      
      static Unit[] lengthArr = new Unit[11];
      lengthArr[0] = new Unit("Centimeter", 100.0);            
      lengthArr[1] = new Unit("Feet", 3.280839895);            
      lengthArr[2] = new Unit("Inch", 39.37007874);
      lengthArr[3] = new Unit("Kilometer", 0.001);
      lengthArr[4] = new Unit("League", 0.000207123);
      lengthArr[5] = new Unit("League(Nautical)", 1.0);
      lengthArr[6] = new Unit("Meter", 1.0);
      lengthArr[7] = new Unit("Microinch", 39370078.740157485);
      lengthArr[8] = new Unit("Mile", 0.000621371);
      lengthArr[9] = new Unit("Millimeter", 1000.0);
      lengthArr[10] = new Unit("Yard", 1.093613298);
      
      static JFrame myFrame = new JFrame("Test");                                    
      static JPanel container = new JPanel();                        
      static JPanel LengthPane = new JPanel(new GridBagLayout());                                    
      static JPanel LiquidPane = new JPanel(new GridBagLayout());                                    
      static JPanel MassPane = new JPanel(new GridBagLayout());                                          
      static JPanel TempPane = new JPanel(new GridBagLayout());                                          
      static JButton convert = new JButton("Convert");                        
      static JMenuBar menu1 = new JMenuBar();                                          
      static JMenu file = new JMenu("File");                                          
      static JMenu conversion = new JMenu("Conversion");                        
      static JMenuItem exit = new JMenuItem("Exit");
      static JMenuItem length = new JMenuItem("Length");
      static JMenuItem liquid = new JMenuItem("Liquid");
      static JMenuItem mass = new JMenuItem("Mass");
      static JMenuItem temp = new JMenuItem("Temperature");
      static JComboBox fromBox = new JComboBox(lengthArr);
      static JComboBox toBox = new JComboBox(lengthArr);
      static JTextField value = new JTextField(10);
      
      public static void main(String[] args) {
            // TODO Auto-generated method stub
            
            ActionListener buttonListener = new MyListener(){
            public void actionPerformed(ActionEvent e){
            }
            };
            ActionListener menuListener = new MyListener(){
                  public void actionPerformed(ActionEvent e){
                  if(e.getActionCommand().equals("Length")){
                        container.removeAll();
                        container.add(LengthPane);
                        container.revalidate();
                  }
                  else if(e.getActionCommand().equals("Liquid")){
                        container.removeAll();
                        container.add(LiquidPane);
                        container.revalidate();
                  }
                  else if(e.getActionCommand().equals("Mass")){
                        container.removeAll();
                        container.add(MassPane);
                        container.revalidate();
                  }
                  else if(e.getActionCommand().equals("Temperature")){
                        container.removeAll();
                        container.add(TempPane);
                        container.revalidate();
                  }
                  }
                  };
            //Menu bar ActionListeners      
            liquid.addActionListener(menuListener);
            exit.addActionListener(menuListener);
            length.addActionListener(menuListener);
            mass.addActionListener(menuListener);
            temp.addActionListener(menuListener);
            
            //Length panel build
            MyGrid.addItem(LengthPane, value,0,10,1,1,GridBagConstraints.WEST);
            MyGrid.addItem(LengthPane, fromBox,0,12,1,1,GridBagConstraints.WEST);
            MyGrid.addItem(LengthPane, toBox,0,14,1,1,GridBagConstraints.WEST);
            
            container.add(LengthPane);
            
            menu1.add(file);
            menu1.add(conversion);
            file.add(exit);
            conversion.add(length);
            conversion.add(liquid);
            conversion.add(mass);
            conversion.add(temp);
            
            myFrame.setJMenuBar(menu1);
            myFrame.setContentPane(container);
            myFrame.setSize(300,400);
            myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            myFrame.pack();
            myFrame.setVisible(true);
            
            }
}
}

Thanks
[+][-]02/07/07 01:50 PM, ID: 18489007Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: New to Java Programming, Java Editors & IDEs, Java Programming Language
Tags: token, error, syntax, expected, java
Sign Up Now!
Solution Provided By: objects
Participating Experts: 2
Solution Grade: A
 
[+][-]02/07/07 01:47 PM, ID: 18488984Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/07/07 02:37 PM, ID: 18489398Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/07/07 02:42 PM, ID: 18489436Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/18/07 02:06 AM, ID: 18558043Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92