codice:
public class MainX extends JFrame {
	private static JPanel areasgraph = new JPanel();
	private static JPanel zonesgraph = new JPanel();
	/* ... */
	
	public MainX() {
		final JPanel sx = new JPanel();
		sx.setLayout(new GridLayout(2,1));
		/* ... */
		areasgraph.setBorder(new TitledBorder(new LineBorder(Color.BLACK), "Areas graph", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.TOP, new Font("Verdana", Font.PLAIN, 12)));
		areasgraph.setPreferredSize(new Dimension(700,348));
		areasgraph.setLayout(new BorderLayout());
		sx.add(areasgraph);
		/* ... */
		JPanel buttonspanel = new JPanel();
		buttonspanel.setLayout(new GridLayout(2,2));
		final JButton startb = new JButton("Start");
		final JButton stopb = new JButton("Stop");
		stopb.setEnabled(false);
		/* ... */
		class ButtonListeners implements ActionListener {
			public void actionPerformed(ActionEvent e) {
				if((JButton)e.getSource() == startb) {
					startb.setEnabled(false);
					stopb.setEnabled(true);

					w = new World(areasN, maxzones, maxpeople);

					AreaGrapher a = new AreaGrapher(w);
					areasgraph.add(a); // <-- questo non sembra avvenire!!
					/* ... */
			}
		}
		
		ActionListener buttonslistener = new ButtonListeners();
		/* ... */
		startb.addActionListener(buttonslistener);
		/* ... */
		add(sx);
		/* ... */
		setVisible(true);
	}
}
codice:
public class AreaGrapher extends JPanel implements Runnable {
	private Thread t;
	private World localw;
	private int areasN, areasPeopleN[];
	private AreaGraphBars[] bars;
	private Random rand = new Random();
	
	public AreaGrapher(World w) {
		int i;
		localw = w;
		
		areasN = localw.getAreasN();
		bars = new AreaGraphBars[areasN];
		areasPeopleN = localw.getAreasPeopleN();
		setLayout(new GridLayout(areasN,1));
		
		for(i=0; i<areasN; i++) {
			bars[i] = new AreaGraphBars(new Color(rand.nextInt(0xFFFFFF)), 0, "A"+i);
			add(bars[i]);
		}
		
		t = new Thread(this);
		t.setName("AreaGrapher-Thread");
		t.start();
	}
	
	public void run() {
		int i, maxwidth=0;
		try {
			while(!Thread.interrupted()) {
				areasPeopleN = localw.getAreasPeopleN();

				for(i=0; i<areasN; i++) {
					if(areasPeopleN[i] > maxwidth) {
						maxwidth = areasPeopleN[i];
					}
				}

				for(i=0; i<areasN; i++) {
					bars[i].setAttr((int)((580*areasPeopleN[i])/maxwidth)-8, areasPeopleN[i]);
					bars[i].repaint();
				}

				TimeUnit.SECONDS.sleep(1);
			}
		} catch(InterruptedException e) { return; }
	}
}
Succede che quando premo Start, il JPanel a non viene aggiunto ad areasgraph, però facendo un po di debug, il thread viene creato e sembra fare tutto quello che deve fare..
Idee sul perche' non riesce a vedere il JPanel threadato dentro al JPanel "principale" ?