Hello i have this code.This applet creates 2 list graphick items and when the selected index of one list changes it draws the background with a color or it paints a shape.I have a problem when i try to add a big string to one of my lists it hides the other list.Any suggestion?
Code:import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Choice;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JPanel;
public class Α2P4 extends Applet {
Choice c1,c2;
JPanel p1;
public void init()
{
this.setLayout(new BorderLayout());
c1=new Choice();
c1.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e)
{
int cm=c1.getSelectedIndex();
if (cm ==0)
setBackground(Color.red);
if (cm==1 )
setBackground(Color.blue);
if (cm ==2)
setBackground(Color.yellow);
if (cm ==3)
setBackground(Color.GREEN);
if (cm ==4)
setBackground(Color.black);
if (cm ==5)
setBackground(Color.gray);
if (cm ==6)
setBackground(Color.orange);
}
});
c1.add("Κόκκινο");
c1.add("Μπλε");
c1.add("Κιτρινο");
c1.add("Πράσσινο");
c1.add("Μαύρο");
c1.add("Γκρί");
c1.add("Πορτοκαλί");
c2=new Choice();
c2.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e)
{
repaint();
}
});
c2.add("Line");
c2.add("Rectangle");
c2.add("Oval");
c2.add("FillRect");
c2.add("FilledOval");
p1=new JPanel();
p1.setLayout(new FlowLayout());
p1.setSize(200,200);
p1.add(c2);
p1.add(c1);
this.add(p1,BorderLayout.PAGE_START);
}
public void paint(Graphics g){
super.paint(g);
g.setColor(Color.cyan);
int c3=c2.getSelectedIndex();
if(c3==0)
{
g.drawLine(0, 50, 50, 50);
}
if(c3==1)
{
g.drawRect(this.getWidth()/2, this.getHeight()/2, this.getWidth()/3, this.getHeight()/3);
}
if(c3==2)
{
g.drawOval(this.getWidth()/2, this.getHeight()/2, this.getWidth()/3,this.getHeight()/3);
}
if(c3==3)
{
g.fillRect(this.getWidth()/2, this.getHeight()/2, this.getWidth()/3, this.getHeight()/3);
}
if(c3==4)
{
g.fillOval(this.getWidth()/2, this.getHeight()/2, this.getWidth()/3, this.getHeight()/3);
}
}
}

