Io ho fatto così:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class FrameLeague extends JFrame implements ActionListener, MouseListener {
private static final long serialVersionUID = 1L;
private DesktopFrame dframe;
private static final String file="img/sfondo.jpg";
public FrameLeague() {
super("Prova");
//Make the big window be indented 50 pixels from each edge
//of the screen.
int inset = 0;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds(inset, inset, screenSize.width , screenSize.height );
setContentPane(dframe);
setJMenuBar(createMenuBar());
//Make dragging a little faster but perhaps uglier.
dframe.getDesktop().setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
}
protected JMenuBar createMenuBar() {
JMenuBar menuBar = new JMenuBar();
//Set up the lone menu.
JMenu menu1 = new JMenu("Partite");
menu1.setMnemonic(KeyEvent.VK_P);
menuBar.add(menu1);
JMenuItem menuItemA = new JMenuItem("Giornata");
//nuItem.setMnemonic(KeyEvent.VK_N);
menuItemA.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_A, ActionEvent.ALT_MASK));
menuItemA.setActionCommand("PAA");
menuItemA.addActionListener(this);
menu1.add(menuItemA);
return menuBar;
}
//React to menu selections.
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().startsWith("PA")) { //new
createFrame(e.getActionCommand());
}
else { //quit
quit();
}
}
//Create a new internal frame.
protected void createFrame(String tipo) {
MyInternalFrame frame = new MyInternalFrame(tipo,this, dframe);
if(tipo.startsWith("CC") || tipo.startsWith("EX"))
frame.setVisible(false);
else
frame.setVisible(true); //necessary as of 1.3
dframe.getDesktop().add(frame);
try {
frame.setSelected(true);
} catch (java.beans.PropertyVetoException e) {}
}
//Quit the application.
protected void quit() {
System.exit(0);
}
}
----------------------------------------------------
import javax.swing.*;
import java.awt.*;
public class DesktopFrame extends JDesktopPane {
private static final long serialVersionUID = 1L;
private Image backImage=null;
public DesktopFrame() {
super();
backImage = new ImageIcon(new java.io.File("img/Serie_A.jpg").getAbsolutePath()).getImage();
}
protected JDesktopPane getDesktop(){
return this;
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(backImage, 0, 0, getWidth(), getHeight(), null);
}
}
---------------------------------------------------------
/* Used by InternalFrameDemo.java. */
public class MyInternalFrame extends JInternalFrame implements InternalFrameListener {
/**
*
*/
private static final long serialVersionUID = 1L;
static int MAX_DAY=38;
public MyInternalFrame(String tipogirone, FrameLeague gui, DesktopFrame superFrame) {
super("Serie A ",
false, //resizable
true, //closable
false, //maximizable
true);//iconifiable
sf=superFrame;
//Ti chiami il/i metodo/i per esporre ciò che vuoi nella JInternalFrame
//...Then set the window size or call pack...
setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
pack();
}
}
e nel main ti richiami l'oggetto FrameLeague
Ciao