View Single Post
Old 23-03-2009, 18:37   #2
PGI-Bis
Senior Member
 
L'Avatar di PGI-Bis
 
Iscritto dal: Nov 2004
Cittā: Tra Verona e Mantova
Messaggi: 4553
A meno che non mi sfugga una linea direi: non č che sbagli nel comunicare, č che proprio non comunichi .

Devi fare al JFrame quello che fai all'applet, non far diventare l'applet classe interna del tuo jframe.

Esempio:

Codice:
import java.awt.*;
import javax.swing.*;

public class Main {
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			@Override public void run() {
				new MainFrame().edtShow();
			}
		});
	}
}

class MainFrame {
	
	public void edtShow() {
		JFrame frame = new JFrame("Titolo del frame");
		frame.setContentPane(new MainContentPane().createPanel());
		frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}
}

class MainContentPane {
	public JPanel createPanel() {
		JButton play = new JButton("Play");
		JButton stop = new JButton("Stop");
		JButton loop = new JButton("Loop");
		
		JLabel title = new JLabel("Titolo canzone");
		title.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
		
		JPanel buttons = new JPanel(new FlowLayout());
		buttons.add(play);
		buttons.add(stop);
		buttons.add(loop);
		
		JPanel panel = new JPanel(new BorderLayout());
		panel.add(title, BorderLayout.NORTH);
		panel.add(buttons, BorderLayout.SOUTH);
		
		return panel;
	}
}
__________________
Uilliam Scecspir ti fa un baffo? Gioffri Cioser era uno straccione? E allora blogga anche tu, in inglese come me!
PGI-Bis č offline   Rispondi citando il messaggio o parte di esso