JTextArea not appearing. URGENT HELP REQUIRED !

Hi.

I am a novice at Swing. I have written the following rough code. But for some reason the JTextArea and the radio buttons do not show up. Could someone please guide me in this regard.

It is a little urgent ! Thanks !

import javax.swing.*;

import java.awt.event.*;

import java.awt.*;

import javax.swing.JButton;

class PizzaOrderGUI

{

private JFrame frame;

private JLabel titleMenu, titleToppings, titleName, titleAddress;

private JComboBox menuToppings;

private JButton addOrder, clearMenu, submitMenu;

private JTextField customerName, customerAddress;

private JList toppingSelected;

private JRadioButton large, medium, small;

private JCheckBox deliveryStatus;

private ButtonGroup pizzaSize;

public final String toppingNames[] = {"", "Cheese", "Pepperoni", "Mushrooms", "Green Peppers Onions", "Jalapenos", "Hamburger", "Olives"};

JTextArea textArea;

public int temp;

public PizzaOrderGUI()

{

frame = new JFrame("Pizza Order Form");

frame.setSize(500,500);

frame.setLayout(null);

titleMenu = new JLabel("PIZZARIA", JLabel.CENTER);

titleMenu.setBounds(200,50,200,50);

titleMenu.setFont(new Font("Arial", Font.BOLD, 16));

titleToppings = new JLabel("Toppings");

titleToppings.setBounds(100,100,100,30);

titleToppings.setFont(new Font("Arial", Font.BOLD, 16));

menuToppings = new JComboBox(toppingNames);

menuToppings.setMaximumRowCount(3);

menuToppings.setBounds(100,120,100,30);

menuToppings.addItemListener(

new ItemListener()

{

public void itemStateChanged(ItemEvent event)

{

if(event.getStateChange() == ItemEvent.SELECTED)

temp = menuToppings.getSelectedIndex();

}

});

textArea = new JTextArea(10,400);

textArea.setEditable(false);

JScrollPane scroll = new JScrollPane(textArea);

int vpolicy = scroll.getVerticalScrollBarPolicy();

addOrder = new JButton("Add To Order");

addOrder.setBounds(300,120,100,30);

addOrder.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent ae)

{

textArea.append(toppingNames[temp]+"\n");

}

});

large = new JRadioButton("Large", false);

medium = new JRadioButton("Medium", false);

small = new JRadioButton("Small", false);

pizzaSize = new ButtonGroup();

pizzaSize.add(large);

pizzaSize.add(medium);

pizzaSize.add(small);

titleName = new JLabel("Name");

titleName.setBounds(150,320,100,20);

titleAddress = new JLabel("Address");

titleAddress.setBounds(150,340,100,20);

customerName = new JTextField(150);

customerName.setBounds(300,320,250,30);

customerAddress = new JTextField(150);

customerAddress.setBounds(300,360,250,30);

frame.add(titleMenu);

frame.add(titleToppings);

frame.add(menuToppings);

frame.add(addOrder);

frame.add(large);

frame.add(medium);

frame.add(small);

frame.add(titleName);

frame.add(titleAddress);

frame.add(customerName);

frame.add(customerAddress);

frame.add(textArea);

frame.add(scroll);

frame.setVisible(true);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

public static void main(String[] args)

{

new PizzaOrderGUI();

}

}

[3566 byte] By [Shakir1984a] at [2007-11-27 8:36:34]
# 1

Since you are using a null layout (why not use a layout manager?) the components you mentioned don't show up since you haven't set their bounds.

Edit:

Oh and by the way since you're adding the text area to a scroll pane you should set the scroll pane's bounds and only add that to the frame (i.e., not the text area).

dwga at 2007-7-12 20:33:33 > top of Java-index,Desktop,Core GUI APIs...
# 2
Thanx for the reply ! could you please elaborate on how i am to set the bounds of the components i want to appear.....
Shakir1984a at 2007-7-12 20:33:33 > top of Java-index,Desktop,Core GUI APIs...
# 3
Attempting to set bounds for the text area results in an error,
Shakir1984a at 2007-7-12 20:33:33 > top of Java-index,Desktop,Core GUI APIs...
# 4
You should be setting the bounds of the scroll pane only not the text area.
dwga at 2007-7-12 20:33:33 > top of Java-index,Desktop,Core GUI APIs...