A QUestion using JTabbedPanes

Hi there. I a a new student to the Java Language (I am actually taking a Java programming class this summer) anyways I have to design a program using a JTabbedPane providing one tab to input user data such as the name and address of a person and another tab to input information about a pizza order.The teacher would like us to be somewhat creative and be able to change the naem and address once it is able to be viewed to different colors and such The program just has to echo the data submitted. Here is the code that I have been able to come up with so far:

import javax.swing.*;

import javax.swing.event.*;

import java.awt.*;

import java.awt.event.*;

public class Tabs extends JFrame {

public Tabs(String title) {

super(title);

JTabbedPane tabPane = new JTabbedPane();

Container c = getContentPane();

c.add(tabPane, "Center");

SelectName name = new SelectName();

tabPane.addTab("Name",name);

SelectOrder order = new SelectOrder();

tabPane.addTab("Order",order);

tabPane.setSelectedIndex(0);

addWindowListener(new CloseWindow());

}

public static void main(String [] args) {

Tabs t = new Tabs("Tab display");

t.pack();

t.show();

}

class CloseWindow extends WindowAdapter {

public void windowClosing(WindowEvent event) {

System.exit(0);

}

}

class Name extends JPanel {

private DrawOn canvas = new DrawOn();

private JComboBox color = new JComboBox();

private Color [] theColor = {Color.red,Color.green,Color.blue};

private String [] colorName = {"Red","Green","Blue"};

public SelectName() {

setLayout(new FlowLayout());

add(color);

add(canvas);

for (int i=0; i color.addItem(colorName);

canvas.setPreferredSize(new Dimension(150,150));

color.addItemListener(canvas);

}

class DrawOn extends JPanel implements ItemListener {

public void itemStateChanged(ItemEvent event) {

Object source = event.getItem();

repaint();

}

public void paintComponent(Graphics g) {

super.paintComponent(g);

g.setColor(theColor[color.getSelectedIndex()]);

}

}

}

class SelectOrder extends JPanel {

private DrawOn canvas = new DrawOn();

private String [] colorName = {"Black","Blue","Cyan","Dark Gray","Gray",

"Green","Light Gray","Magenta","Orange","Pink","Red","White","Yellow"};

private JList names = new JList(colorName);

private JScrollPane color = new JScrollPane(names);

private JCheckBox italic = new JCheckBox("Italic");

private JCheckBox bold = new JCheckBox("Bold");

private Color [] theColor = {Color.black,Color.blue,Color.cyan,Color.darkGray,

Color.gray,Color.green,Color.lightGray,Color.magenta,Color.orange,

Color.pink,Color.red,Color.white,Color.yellow};

private String message = "Hi there";

public SelectOrder() {

setLayout(new FlowLayout());

add(color);

add(italic);

add(bold);

add(canvas);

names.setSelectedIndex(0);

names.addListSelectionListener(canvas);

canvas.setPreferredSize(new Dimension(150,150));

italic.addItemListener(canvas);

bold.addItemListener(canvas);

}

class DrawOn extends JPanel implements

ItemListener, ListSelectionListener {

int style = Font.PLAIN;

public void itemStateChanged(ItemEvent event) {

Object source = event.getItem();

int change = event.getStateChange();

if (source == italic)

if (change == ItemEvent.SELECTED)

style += Font.ITALIC;

else

style -= Font.ITALIC;

if (source == bold)

if (change == ItemEvent.SELECTED)

style += Font.BOLD;

else

style -= Font.BOLD;

repaint();

}

public void valueChanged(ListSelectionEvent e) {

if (e.getValueIsAdjusting() == false)

repaint();

}

public void paintComponent(Graphics g) {

super.paintComponent(g);

g.setFont(new Font("Serif",style,24));

g.setColor(theColor[names.getSelectedIndex()]);

g.drawString(message, 50,50);

}

}

}

}

When I compile this code I come up with the 3 error messages:

C:\$jg105\Tabs.java:38: Invalid method declaration; return type required.

public SelectName() {

^

C:\$jg105\Tabs.java:15: Class SelectName not found.

SelectName name = new SelectName();

^

C:\$jg105\Tabs.java:15: Class SelectName not found.

SelectName name = new SelectName();

^

3 errors

Finished

Can anyone tell me what am I doing wrong here. IT is probably a simple mistake but still one that I have yet to figure out where it is. Also how will I go about taking in the users input for their name and address for the first tab and the pizza order info for the second tab? I am still puzzeled on how to appraoch that part. Any help is much appreaicated. Thanks alot

[5084 byte] By [CharneyJ] at [2007-9-26 1:34:34]
# 1

As the message says, your SelectName() method needs to have a return type. It looks like a constructor to me, but your class isn't called SelectName(). Oh wait a minute, it looks like you have a whole bunch of classes jammed together in one file. Put each class in its own source file and compile them separately.

DrClap at 2007-6-29 2:17:53 > top of Java-index,Archived Forums,Java Programming...