staroski valeu pela resposta.
eu não tinha postado o código inteiro pois ele tá completo com toadas as JINternalFrames, Achei que ia ficar confuso.
Mas taí o código no netbeans: em seguida o do eclipse
package br.com.infox.telas;
import br.com.infox.dal.Appcon;
import br.com.infox.dal.ModuloConexao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.DateFormat;
import java.time.LocalTime;
import java.util.Date;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
/**
*
* @author mdemo
*/
public class TelaPrincipal extends javax.swing.JFrame {
Connection conexao = null;
PreparedStatement pst = null;
ResultSet rs = null;
public static String exemplo;
Appcon appcon = new Appcon();
/**
* Creates new form TelaPrincipal
*/
public TelaPrincipal() {
initComponents();
conexao = appcon.connect();
}
/**
* 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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
desktop = new javax.swing.JDesktopPane();
jLabel3 = new javax.swing.JLabel();
lblUsuario = new javax.swing.JLabel();
lblData = new javax.swing.JLabel();
Menu = new javax.swing.JMenuBar();
MenCad = new javax.swing.JMenu();
MenCadCli = new javax.swing.JMenuItem();
MenCadOS = new javax.swing.JMenuItem();
MenCadUsu = new javax.swing.JMenuItem();
MenRel = new javax.swing.JMenu();
MenRelServ = new javax.swing.JMenuItem();
MenAju = new javax.swing.JMenu();
MenAjuSob = new javax.swing.JMenuItem();
MenOpc = new javax.swing.JMenu();
MenOpcSai = new javax.swing.JMenuItem();
jLabel1.setText("jLabel1");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("X - Sistema para controle de OS");
setResizable(false);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowActivated(java.awt.event.WindowEvent evt) {
formWindowActivated(evt);
}
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});
javax.swing.GroupLayout desktopLayout = new javax.swing.GroupLayout(desktop);
desktop.setLayout(desktopLayout);
desktopLayout.setHorizontalGroup(
desktopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 630, Short.MAX_VALUE)
);
desktopLayout.setVerticalGroup(
desktopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 480, Short.MAX_VALUE)
);
jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/infox/icones/X1.png"))); // NOI18N
lblUsuario.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
lblUsuario.setText("Usuário");
lblData.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
lblData.setText("Data");
MenCad.setText("Cadastro");
MenCadCli.setText("Clientes");
MenCadCli.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MenCadCliActionPerformed(evt);
}
});
MenCad.add(MenCadCli);
MenCadOS.setText("OS");
MenCadOS.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MenCadOSActionPerformed(evt);
}
});
MenCad.add(MenCadOS);
MenCadUsu.setText("Usuários");
MenCadUsu.setEnabled(false);
MenCadUsu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MenCadUsuActionPerformed(evt);
}
});
MenCad.add(MenCadUsu);
Menu.add(MenCad);
MenRel.setText("Relatório");
MenRel.setEnabled(false);
MenRelServ.setText("Serviços");
MenRel.add(MenRelServ);
Menu.add(MenRel);
MenAju.setText("Ajuda");
MenAju.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MenAjuActionPerformed(evt);
}
});
MenAjuSob.setText("Sobre");
MenAjuSob.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MenAjuSobActionPerformed(evt);
}
});
MenAju.add(MenAjuSob);
Menu.add(MenAju);
MenOpc.setText("Opções");
MenOpcSai.setText("Sair");
MenOpcSai.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MenOpcSaiActionPerformed(evt);
}
});
MenOpc.add(MenOpcSai);
Menu.add(MenOpc);
setJMenuBar(Menu);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(desktop, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(53, 53, 53)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblUsuario)
.addComponent(lblData)))
.addGroup(layout.createSequentialGroup()
.addGap(28, 28, 28)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(42, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(desktop, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(48, 48, 48)
.addComponent(lblUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(lblData)
.addGap(67, 67, 67)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
setSize(new java.awt.Dimension(875, 556));
setLocationRelativeTo(null);
}// </editor-fold>
private void formWindowActivated(java.awt.event.WindowEvent evt) {
Date data = new Date();
DateFormat formatador = DateFormat.getDateInstance(DateFormat.SHORT);
lblData.setText(formatador.format(data));
}
private void MenOpcSaiActionPerformed(java.awt.event.ActionEvent evt) {
int sair = JOptionPane.showConfirmDialog(null,"Tem certeza que deseja sair?", "Atenção",JOptionPane.YES_NO_OPTION);
if (sair == JOptionPane.YES_OPTION){
System.exit(0);
}
}
private void MenAjuActionPerformed(java.awt.event.ActionEvent evt) {
}
private void MenAjuSobActionPerformed(java.awt.event.ActionEvent evt) {
TelaSobre sobre = new TelaSobre();
sobre.setVisible(true);
}
private void MenCadUsuActionPerformed(java.awt.event.ActionEvent evt) {
TelaUsuario usuario = new TelaUsuario();
desktop.add(usuario); **// aqui desktop é reconhecido normal**
usuario.setVisible(true);
}
private void MenCadCliActionPerformed(java.awt.event.ActionEvent evt) {
TelaClientes cliente = new TelaClientes();
cliente.setVisible(true);
desktop.add(cliente);
}
private void MenCadOSActionPerformed(java.awt.event.ActionEvent evt) {
//chama a tela OS
TelaOS os = new TelaOS();
os.setVisible(true);
desktop.add(os);
}
private void formWindowOpened(java.awt.event.WindowEvent evt) {
String sql ="insert into fpTime (vendedor) values (?)";
try {
pst=conexao.prepareStatement(sql);
pst.setString(1, exemplo);
pst.executeUpdate();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(TelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(TelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(TelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(TelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new TelaPrincipal().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JMenu MenAju;
private javax.swing.JMenuItem MenAjuSob;
private javax.swing.JMenu MenCad;
private javax.swing.JMenuItem MenCadCli;
private javax.swing.JMenuItem MenCadOS;
public static javax.swing.JMenuItem MenCadUsu;
private javax.swing.JMenu MenOpc;
private javax.swing.JMenuItem MenOpcSai;
public static javax.swing.JMenu MenRel;
private javax.swing.JMenuItem MenRelServ;
private javax.swing.JMenuBar Menu;
private javax.swing.JDesktopPane desktop;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel lblData;
public static javax.swing.JLabel lblUsuario;
// End of variables declaration
}
agora o código do eclipse:
package br.com.infox.telas;
import java.awt.BorderLayout;
import java.util.Date;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import br.com.infox.dal.Appconn;
import javax.swing.JMenuBar;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.SwingConstants;
import javax.swing.JDesktopPane;
import java.awt.Font;
import javax.swing.ImageIcon;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.DateFormat;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class TelaPrincipal extends JFrame {
private JPanel Menu;
Connection conexao = null;
PreparedStatement pst = null;
ResultSet rs = null;
Appconn appconn = new Appconn();
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
TelaPrincipal frame = new TelaPrincipal();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public void getDesktop() {
return desktop;
}
public TelaPrincipal() {
JMenuItem mntSair = new JMenuItem("Sair");
mntSair.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int sair = JOptionPane.showConfirmDialog(null, "Tem certeza que deseja sair?", "Atenção",JOptionPane.YES_NO_OPTION);
if(sair == JOptionPane.YES_OPTION) {
System.exit(0);
}
}
});
addWindowListener(new WindowAdapter() {
public void windowActivated(WindowEvent e) {
Date data = new Date();
DateFormat formatador = DateFormat.getDateInstance(DateFormat.SHORT);
lblData.setText(formatador.format(data)); //lblData também sublinhado em vermelho não reconhece
}
});
setResizable(false);
setTitle("X - Sistema para controle de OS");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 880, 558);
JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar);
JMenu mnCadastro = new JMenu("Cadastro");
menuBar.add(mnCadastro);
JMenuItem mntClientes = new JMenuItem("Clientes");
mnCadastro.add(mntClientes);
JMenuItem mntOS = new JMenuItem("OS");
mnCadastro.add(mntOS);
JMenuItem mntUsuario = new JMenuItem("Usuario");
mntUsuario.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
TelaUsuario usuario = new TelaUsuario();
desktop.add(usuario); // fica em sublinhado em vermelho desktop não reconhece
usuario.setClosable(true);
usuario.setIconifiable(true);
usuario.setMaximizable(true);
usuario.setVisible(true);
}
});
mnCadastro.add(mntUsuario);
JMenu mnRelatorio = new JMenu("Relatorio");
menuBar.add(mnRelatorio);
JMenuItem mntServicos = new JMenuItem("Servicos");
mnRelatorio.add(mntServicos);
JMenu mnAjuda = new JMenu("Ajuda");
menuBar.add(mnAjuda);
JMenuItem mntSobre = new JMenuItem("Sobre");
mnAjuda.add(mntSobre);
JMenu mnOpcoes = new JMenu("Opcoes");
menuBar.add(mnOpcoes);
mnOpcoes.add(mntSair);
Menu = new JPanel();
Menu.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(Menu);
Menu.setLayout(null);
JLabel lblUsuario = new JLabel("Usuario");
lblUsuario.setFont(new Font("Tahoma", Font.PLAIN, 26));
lblUsuario.setBounds(722, 54, 107, 49);
Menu.add(lblUsuario);
JLabel lblNewLabel = new JLabel("");
lblNewLabel.setIcon(new ImageIcon(TelaPrincipal.class.getResource("/br/com/infox/icones/x1.png")));
lblNewLabel.setBounds(708, 209, 127, 136);
Menu.add(lblNewLabel);
final JDesktopPane desktop = new JDesktopPane();
desktop.setBounds(20, 23, 661, 463);
Menu.add(desktop);
final JLabel lblData = new JLabel("Data");
lblData.setFont(new Font("Dialog", Font.PLAIN, 20));
lblData.setBounds(708, 131, 120, 26);
Menu.add(lblData);
}
}