PrisonGUI.java:112: 'class' or 'interface' expected
public static void main (String args[])
^
PrisonGUI.java:116: 'class' or 'interface' expected
}
^
PrisonGUI.java:118: 'class' or 'interface' expected
^
3 errors
i know that these errors are usually caused because of to many {} however i have checked my program and it looks ok to me. i am new to the GUI side of java so any help would be much appreciated. if any of the other classes that this part of the program links to are needed to be able to understand the code then please ask.
thanks for any help **Luke**
import java.awt.*;
import javax.swing.*;
public class PrisonGUI extends JFrame implements ActionListener
{
private PrisonCanvas canvas;
private JButton addPrisoner;
private JButton addhsPrisoner;
private JButton addWarden;
private JButton viewPrisoners;
private JButton viewhsPrisoners;
private JButton viewWardens;
private JTextArea displayArea;
private Prison CarltonHouse;
public PrisonGUI()
{
setLooknFeel();
setTitle("Carlton House Prison");
setBounds(0, 0, 500,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Add some sample data
Prisoners Dave = new Prisoners("Dave","Taylor",24, 501);
Prisoners Matt = new Prisoners("Matt","Smith",35, 502);
Prisoners Adam = new Prisoners("Adam","Jones",19, 503);
Prison CarltonHouse = new Prison("Carlton House",30, 30, 30);
CarltonHouse.addPrisoner(Dave);
CarltonHouse.addPrisoner(Matt);
CarltonHouse.addPrisoner(Adam);
canvas = new PrisonCanvas();
getContentPane().add("Center", canvas);
addPrisoner = new JButton("Add Prisoner");
addhsPrisoner = new JButton("Add HS Prisoner");
addWarden = new JButton("Add Warden");
viewPrisoners = new JButton("View HS Prisoners");
viewhsPrisoners = new JButton("View Prisoners");
viewWardens = new JButton("View Wardens");
JPanel buttonPanel = new JPanel(new GridLayout(2, 3, 3, 3));
getContentPane().add("South", buttonPanel);
buttonPanel.add(addPrisoner);
buttonPanel.add(addhsPrisoner);
buttonPanel.add(addWarden);
buttonPanel.add(viewPrisoners);
buttonPanel.add(viewhsPrisoners);
buttonPanel.add(viewWardens);
//*********Display Area********//
JPanel northPanel = new JPanel();
northPanel.setSize(1000,800);
displayArea = new JTextArea("This is the display area" + "\nDetails of Prisoners will be displayed here " +
"\nPlease make your choice\n\n\n\n\n\n" );
JScrollPane scrollPane;
scrollPane = new JScrollPane(displayArea);
//scrollPane.setSize(300,300);
northPanel.add(scrollPane);
getContentPane().add("Center", northPanel);
setVisible(true);
}
private void setLooknFeel()
{
String lookAndFeel = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
try
{
UIManager.setLookAndFeel(lookAndFeel);
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == displayPrisoners)
{
// display all Prisoners
/*
displayArea.setText("Display of all Prisoners - next Prisoner");
for (int i = 1; i < 8; ++i)
displayArea.append("\na Prisoner");
*/
CarltonHouse.outputPrisonDetailsFOR(displayArea);
}
/* else if (e.getSource() == displayPrisonerDetails)
{
// display details of specific Prisoner
displayArea.setText("Display Prisonerwith ID :");
*/ }
}
public static void main (String args[])
{
new PrisonGUI();
}
}

New Topic/Question
Reply




MultiQuote



|