Illegal start of expression for static classes?
I'm new to Java. I want to display a Jframe with two buttons in it. Upon
clicking each button a different JOptionPane message should show. However
I'm getting the error Illegal start of expression on both the static class
declarations.
can anyone explain why? I've tried moving the static classes but still the
same error.
Here is my code...
import javax.swing.JOptionPane;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
public class main {
public main() {
}
public static void main(String[] args) {
String name = JOptionPane.showInputDialog(null,
"What's your name?", "Enter your name",
JOptionPane.PLAIN_MESSAGE);
System.out.println("\nWelcome, "+ name + ".");
System.out.print(terms);
JOptionPane.showMessageDialog(null, "Welcome to
SkyWhale, " + name + ".\n" + deets + "\n" + terms ,
"Welcome, " + name + ".", JOptionPane.PLAIN_MESSAGE);
JFrame control = new JFrame("SkyWhale");
control.setVisible(true);
control.setSize(500,200);
control.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
JButton chatbtn = new JButton("Live Chat");
JButton editorbtn = new JButton("Editor");
control.add(panel);
panel.add(chatbtn);
panel.add(editorbtn);
chatbtn.addActionListener(goToChat());
editorbtn.addActionListener(goToEdit());
static class goToEdit implements ActionListener {
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(null, "Code goes
here...", "Editor",
JOptionPane.PLAIN_MESSAGE);
}
}
static class goToChat implements ActionListener {
public void actionPerformed (ActionEvent e)
{
JOptionPane.showMessageDialog(null,
"Conversation...", "Live Chat",
JOptionPane.PLAIN_MESSAGE);
}
}
}
}
}
No comments:
Post a Comment