Eu queria saber se tem como eu colocar componentes do swing no Desktop? Eu estou querendo colocar os botões no fundo do Desktop e chamar o internalFrame quando o usuario clicar nele ( simular tipo a area de trabalho do windows, linux, etc);
Se tiver como posta um exemplinho aqui para nós.
Eu nao quero fazer uma barra de ferramentas no meu sistema. Eu queria tipo colocar uns JButtons (como se fossem icones) num JPanel e colocar-lo tipo imagem de fundo no JDesktop, para ficar uma cara parecica como o Desktop do windows, linux, etc. Isso é para que quando clicar nesses JButtons (icones) abrissem o JInternalFrame.
Massa de mais esse exemplo em Riberto!!! ax acho que esse vai te servir!!!
mais nao sei nao!! Tipo eu tava fazendo uns testes sobre aquele seu outro topico “ax”, e o problema era o seguinte!! ate dava pra colocar um JPanel em JDesktop com botoes e etc. mas quando eu abria o JInternalFrame e depois minimizava o mesmo, ele sumia, ficava atraz do JPanel!! mas ve ai o codigo deste exemplo ai em cima, eu nao olhei apenas rodei!!!
agora to sem o codigo, mas nao tem nada de mais nao é um simples “add” mesmo!! o detalhe esta em definir um Layout para JDeskTop, BorderLayout se nao me engano e colocar o panel e internalframe’s no CENTER!!
Mas num momento de imensa curiosidade eu peguei tentei fazer isso usando o netbeans e não é que deu certo!!!
Tá ae o código que o netbeans gerou para mim:
import javax.swing.*;
/**
*
* @author HALISSON
*/
public class TesteDesktop extends javax.swing.JFrame {
/** Creates new form TesteDesktop */
public TesteDesktop() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {
jDesktopPane1 = new javax.swing.JDesktopPane();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
jButton1.setText("jButton1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton1.setBounds(60, 60, 79, 25);
jDesktopPane1.add(jButton1, javax.swing.JLayeredPane.DEFAULT_LAYER);
jButton2.setText("jButton2");
jButton2.setBounds(60, 110, 79, 25);
jDesktopPane1.add(jButton2, javax.swing.JLayeredPane.DEFAULT_LAYER);
getContentPane().add(jDesktopPane1, java.awt.BorderLayout.CENTER);
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setBounds((screenSize.width-400)/2, (screenSize.height-300)/2, 400, 300);
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
JInternalFrame list1=new JInternalFrame("Listagem de ",true,true,true,true);
list1.setSize(490,410);
list1.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);
jDesktopPane1.add(list1, javax.swing.JLayeredPane.DEFAULT_LAYER);
list1.setVisible(true);
list1.show();
}
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {
System.exit(0);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
new TesteDesktop().show();
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JDesktopPane jDesktopPane1;
// End of variables declaration
}
Tão simples, que eu não tou acreditando que tou penando a mais de um mês para fazer isso!!!