Pessoal estava precisando de colocar uma
imagem de fundo no Meu JDesktopPanel
intão fiz o seguinte:
1º criei uma classe aonde tem um painel
que tem a imagem
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Background extends JPanel {
private ImageIcon image;
public Background() {
image = new ImageIcon("background_programa.jpg");
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
image.paintIcon(this, g, 0, 0);
}
public Dimension getPreferredSize() {
return new Dimension (image.getIconWidth(),
image.getIconHeight() );
}
}
e agora chamo ela no JDekstopPanel assim :
theDesktop = new JDesktopPane();
Background back = new Background();
getContentPane().add(theDesktop);
getContentPane().add(back);
setSize(800,600);
theDesktop.setPreferredSize(new Dimension(800,600));
setVisible(true);
Mais está ocorrendo o seguinte
problema:
ele carrega o programa normal
so que na hora que o usuario clicka no JMenuItem
para abrir a JInternalFrame a JInternalFrame
não abre
o codigo para abrir a JInternalFrame
é a seguinte :
FrameMotorista fm = new FrameMotorista();
fm.framemotorista.pack();
fm.framemotorista.setSize(700,440);
fm.framemotorista.setLocation(50,50);
fm.framemotorista.setVisible(true);
container = fm.framemotorista.getContentPane();
container.add(fm.pbotao, BorderLayout.NORTH);
container.add(fm.pcentro, BorderLayout.CENTER);
container.add(fm.pcnh, BorderLayout.SOUTH);
theDesktop.add(fm.framemotorista);