O
oxygnick
Guest
So I'm taking a Computer Programming class for College, and I have this packet due tomorrow. I am stuck on this one problem. I am unsure of how to add border colors around the window. Would anyone mind pointing me in the right direction? Here is my coding if it helps at all. Thanks
//references illustrates the List and TextArea
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import javax.swing.*;//for JFrame and JPanel
public class ListText extends Applet implements ActionListener, ItemListener
{
private List animals = new List(3,true);
private List things = new List(4);
private TextArea text = new TextArea(4,20);
private Button choose = new Button("Choose Animals");
public void init()
{
animals.add("cow");
animals.add("horse");
animals.add("pig");
animals.add("elephant");
animals.add("flea");
animals.add("duck");
animals.add("chicken");
animals.add("dog");
add(animals);
things.add("moon");
things.add("barn");
things.add("cliff");
things.add("brook");
things.add("pond");
things.add("coop");
things.add("yard");
add(things);
add(text);
add(choose);
choose.addActionListener(this);
things.addItemListener(this);
}
public String buildString(String[] animals, String thing)
{
StringBuffer message = new StringBuffer(50);
message.append("The ");
int length = animals.length;
switch(length)
{
case 0: message.append("??");
break;
case 1: message.append(animals[0]);
break;
case 2: message.append(animals[0]);
message.append(" and ");
message.append(animals[1]);
break;
default:
for(int i = 0; i < length-1; i++)
{
message.append(animals);
message.append(", ");
}
message.append("and ");
message.append(animals[length-1]);
}
message.append(" jumped\n over the ");
message.append(thing);
return message.toString();
}
public void actionPerformed(ActionEvent event)
{
Object source = event.getSource();
if (source==choose)
text.setText
(buildString(animals.getSelectedItems(), things.getSelectedItem()));
}
public void itemStateChanged(ItemEvent e)
{
Object source = e.getSource();
if (source==things)
text.setText("You selected " + things.getSelectedItem());
}
}
//references illustrates the List and TextArea
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import javax.swing.*;//for JFrame and JPanel
public class ListText extends Applet implements ActionListener, ItemListener
{
private List animals = new List(3,true);
private List things = new List(4);
private TextArea text = new TextArea(4,20);
private Button choose = new Button("Choose Animals");
public void init()
{
animals.add("cow");
animals.add("horse");
animals.add("pig");
animals.add("elephant");
animals.add("flea");
animals.add("duck");
animals.add("chicken");
animals.add("dog");
add(animals);
things.add("moon");
things.add("barn");
things.add("cliff");
things.add("brook");
things.add("pond");
things.add("coop");
things.add("yard");
add(things);
add(text);
add(choose);
choose.addActionListener(this);
things.addItemListener(this);
}
public String buildString(String[] animals, String thing)
{
StringBuffer message = new StringBuffer(50);
message.append("The ");
int length = animals.length;
switch(length)
{
case 0: message.append("??");
break;
case 1: message.append(animals[0]);
break;
case 2: message.append(animals[0]);
message.append(" and ");
message.append(animals[1]);
break;
default:
for(int i = 0; i < length-1; i++)
{
message.append(animals);
message.append(", ");
}
message.append("and ");
message.append(animals[length-1]);
}
message.append(" jumped\n over the ");
message.append(thing);
return message.toString();
}
public void actionPerformed(ActionEvent event)
{
Object source = event.getSource();
if (source==choose)
text.setText
(buildString(animals.getSelectedItems(), things.getSelectedItem()));
}
public void itemStateChanged(ItemEvent e)
{
Object source = e.getSource();
if (source==things)
text.setText("You selected " + things.getSelectedItem());
}
}

