Sou iniciante.
Criei um Frame Tela1_JFrame e estou chamando um outro Frame(Tela2_Jframe) e recebo o erro assim :
Compiling 1 source file to C:\Documents and Settings\clientenove\Projeto1\build\classes
C:\Documents and Settings\clientenove\Projeto1\src\projeto1\Tela1_JFrame.java:9: ‘.’ expected
import Tela2_JFrame;
1 error
BUILD FAILED (total time: 0 seconds)
// Como eu chamo
package projeto1;
import Tela2_JFrame;
.
.
.
public class Tela1_JFrame extends javax.swing.JFrame {
/** Creates new form Tela1_JFrame */
public Tela1_JFrame() {
initComponents();
}
private void jButton1MousePressed(java.awt.event.MouseEvent evt) {
Tela2_JFrame.setVisible(true); // Chamo o segundo frame
}
Pedrosa
#2
Cara coloque seus códigos usando a tag [code], facilita para galera te ajudar, existe algum erro de compilação.
Ok, mas como eu coloco Tag code ?
Sou tão iniciante que não sei nem como colcar tag code.
Pedrosa
#5
Ao postar algum código aqui no forum existe um botão code, coloque antes do código e no final e tenha algo assim:
if(x.equals("asd")){
....
}
package projeto1;
import Tela2_JFrame;
public class Tela1_JFrame extends javax.swing.JFrame {
/** Creates new form Tela1_JFrame */
public Tela1_JFrame() {
initComponents();
}
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
jButton1 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
nome = new javax.swing.JTextField();
jButton2 = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
ender = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setText("Tela2");
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
jButton1MousePressed(evt);
}
});
jLabel1.setText("Nome :");
jButton2.setText("Fim");
jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
jButton2MousePressed(evt);
}
});
jLabel2.setText("Ender :");
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(30, 30, 30)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(jLabel2)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(ender, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 282, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(layout.createSequentialGroup()
.add(jButton1)
.add(15, 15, 15)
.add(jButton2))
.add(layout.createSequentialGroup()
.add(jLabel1)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(nome, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 232, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(49, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(nome, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(18, 18, 18)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel2)
.add(ender, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(25, 25, 25)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton1)
.add(jButton2))
.addContainerGap(185, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jButton1MousePressed(java.awt.event.MouseEvent evt) {
Tela2_JFrame.setVisible(true); // Chamo o outro frame }
private void jButton2MousePressed(java.awt.event.MouseEvent evt) {
System.exit(0); // TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Tela1_JFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JTextField ender;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JTextField nome;
// End of variables declaration
}
Tenta mudar de evento para ActionEvent e trocar o frame2 por JDialog
Na frame1
Frame2 dialog = new Frame2(Frame1, true, null);
Na frame2
setVisible(true);
Tenta ai!!!