Form criado com VEP (Visual Editor Plugin) não executa

6 respostas
T

Boa tarde!

Eu novamente... sabe como é, iniciantes... viciados em Delphi... ;-)

Agora estou com outro problema:
Eu desenvolvi o form através do Visual Editor Plugin (VEP) do Eclipse, mas quando compilo o .java ele não dá erros nem warnings, mas quando vou executar o prog java não acontece nada. Nem pelo Rum => Run do Eclipse nem via linha de comando: java Calc. Curioso é que o Visual Editor me mostra um preview do meu form, e parece estar tudo OK.

Espero logo estar podendo contribuir com o grupo também. Mas até lá conto com o apoio de todos vcs... ;-)

OBS.: Outros programas java são executados normalmente. E como esse é o promeiro em que usei o VEP...

Abaixo vai o código se for útil:
import javax.swing.JFrame;

/*
 * Created on 04/04/2004
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */

/**
 * @author root
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
public class Calc extends JFrame {

	private javax.swing.JDesktopPane jDesktopPane = null;
	private javax.swing.JPanel jPanel = null;
	private javax.swing.JPanel jPanel1 = null;
	private javax.swing.JPanel jPanel2 = null;
	private javax.swing.JButton jButton = null;
	private javax.swing.JButton jButton4 = null;
	private javax.swing.JButton jButton5 = null;
	private javax.swing.JButton jButton6 = null;
	private javax.swing.JButton jButton7 = null;
	private javax.swing.JButton jButton1 = null;
	private javax.swing.JButton jButton2 = null;
	private javax.swing.JButton jButton15 = null;
	private javax.swing.JButton jButton16 = null;
	private javax.swing.JButton jButton17 = null;
	private javax.swing.JButton jButton18 = null;
	private javax.swing.JButton jButton19 = null;
	private javax.swing.JButton jButton20 = null;
	private javax.swing.JButton jButton21 = null;
	private javax.swing.JButton jButton22 = null;
	private javax.swing.JButton jButton23 = null;
	private javax.swing.JButton jButton24 = null;
	private javax.swing.JTextPane jTextPane = null;
	private javax.swing.JLabel jLabel = null;
	private javax.swing.JPanel jPanel3 = null;
	private javax.swing.JButton jButton25 = null;
	private javax.swing.JButton jButton26 = null;
	private javax.swing.JButton jButton27 = null;
	private javax.swing.JButton jButton28 = null;
	private javax.swing.JButton jButton29 = null;
	private javax.swing.JButton jButton30 = null;
	private javax.swing.JButton jButton31 = null;
	private javax.swing.JButton jButton32 = null;
	public static void main(String[] args) {
	}
	/**
	 * This is the default constructor
	 */
	public Calc() {
		super();
		initialize();
	}
	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setContentPane(getJDesktopPane());
		this.setSize(564, 288);
		this.setTitle("Calculadora Decimal/Romana");
	}
	/**
	 * This method initializes jDesktopPane
	 * 
	 * @return javax.swing.JDesktopPane
	 */
	private javax.swing.JDesktopPane getJDesktopPane() {
		if(jDesktopPane == null) {
			jDesktopPane = new javax.swing.JDesktopPane();
			jDesktopPane.add(getJPanel(), null);
			jDesktopPane.add(getJPanel1(), null);
			jDesktopPane.add(getJPanel2(), null);
			jDesktopPane.add(getJPanel3(), null);
		}
		return jDesktopPane;
	}
	/**
	 * This method initializes jPanel
	 * 
	 * @return javax.swing.JPanel
	 */
	private javax.swing.JPanel getJPanel() {
		if(jPanel == null) {
			jPanel = new javax.swing.JPanel();
			jPanel.setLayout(null);
			jPanel.add(getJButton6(), null);
			jPanel.add(getJButton(), null);
			jPanel.add(getJButton1(), null);
			jPanel.add(getJButton2(), null);
			jPanel.add(getJButton4(), null);
			jPanel.add(getJButton7(), null);
			jPanel.add(getJButton5(), null);
			jPanel.setSize(102, 249);
			jPanel.setLocation(155, 5);
			jPanel.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.black,1));
		}
		return jPanel;
	}
	/**
	 * This method initializes jPanel1
	 * 
	 * @return javax.swing.JPanel
	 */
	private javax.swing.JPanel getJPanel1() {
		if(jPanel1 == null) {
			jPanel1 = new javax.swing.JPanel();
			jPanel1.setLayout(null);
			jPanel1.add(getJButton16(), null);
			jPanel1.add(getJButton17(), null);
			jPanel1.add(getJButton15(), null);
			jPanel1.add(getJButton18(), null);
			jPanel1.add(getJButton19(), null);
			jPanel1.add(getJButton20(), null);
			jPanel1.add(getJButton21(), null);
			jPanel1.add(getJButton22(), null);
			jPanel1.add(getJButton23(), null);
			jPanel1.add(getJButton24(), null);
			jPanel1.setSize(144, 249);
			jPanel1.setLocation(6, 5);
			jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.black,1));
		}
		return jPanel1;
	}
	/**
	 * This method initializes jPanel2
	 * 
	 * @return javax.swing.JPanel
	 */
	private javax.swing.JPanel getJPanel2() {
		if(jPanel2 == null) {
			jPanel2 = new javax.swing.JPanel();
			jPanel2.setLayout(null);
			jPanel2.add(getJTextPane(), null);
			jPanel2.add(getJLabel(), null);
			jPanel2.setSize(186, 248);
			jPanel2.setLocation(368, 6);
			jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.black,1));
		}
		return jPanel2;
	}
	/**
	 * This method initializes jButton
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton() {
		if(jButton == null) {
			jButton = new javax.swing.JButton();
			jButton.setSize(45, 45);
			jButton.setPreferredSize(new java.awt.Dimension(25,25));
			jButton.setName("jbtn_V");
			jButton.setLocation(53, 5);
			jButton.setText("V");
		}
		return jButton;
	}
	/**
	 * This method initializes jButton4
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton4() {
		if(jButton4 == null) {
			jButton4 = new javax.swing.JButton();
			jButton4.setSize(45, 45);
			jButton4.setPreferredSize(new java.awt.Dimension(25,25));
			jButton4.setName("jbtn_C");
			jButton4.setLocation(5, 101);
			jButton4.setText("C");
		}
		return jButton4;
	}
	/**
	 * This method initializes jButton5
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton5() {
		if(jButton5 == null) {
			jButton5 = new javax.swing.JButton();
			jButton5.setSize(45, 45);
			jButton5.setPreferredSize(new java.awt.Dimension(25,25));
			jButton5.setName("jbtn_M");
			jButton5.setLocation(5, 150);
			jButton5.setText("M");
		}
		return jButton5;
	}
	/**
	 * This method initializes jButton6
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton6() {
		if(jButton6 == null) {
			jButton6 = new javax.swing.JButton();
			jButton6.setSize(45, 45);
			jButton6.setPreferredSize(new java.awt.Dimension(25,25));
			jButton6.setName("jbtn_X");
			jButton6.setLocation(5, 53);
			jButton6.setText("X");
		}
		return jButton6;
	}
	/**
	 * This method initializes jButton7
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton7() {
		if(jButton7 == null) {
			jButton7 = new javax.swing.JButton();
			jButton7.setSize(45, 45);
			jButton7.setPreferredSize(new java.awt.Dimension(43,43));
			jButton7.setName("jbtn_D");
			jButton7.setLocation(53, 101);
			jButton7.setText("D");
		}
		return jButton7;
	}
	/**
	 * This method initializes jButton1
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton1() {
		if(jButton1 == null) {
			jButton1 = new javax.swing.JButton();
			jButton1.setSize(45, 45);
			jButton1.setPreferredSize(new java.awt.Dimension(25,25));
			jButton1.setName("jbtn_L");
			jButton1.setLocation(53, 53);
			jButton1.setText("L");
		}
		return jButton1;
	}
	/**
	 * This method initializes jButton2
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton2() {
		if(jButton2 == null) {
			jButton2 = new javax.swing.JButton();
			jButton2.setSize(45, 45);
			jButton2.setPreferredSize(new java.awt.Dimension(25,25));
			jButton2.setName("jbtn_I");
			jButton2.setLocation(5, 5);
			jButton2.setText("I");
		}
		return jButton2;
	}
	/**
	 * This method initializes jButton15
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton15() {
		if(jButton15 == null) {
			jButton15 = new javax.swing.JButton();
			jButton15.setSize(42, 42);
			jButton15.setLocation(5, 51);
			jButton15.setName("jbtn_3");
			jButton15.setText("3");
		}
		return jButton15;
	}
	/**
	 * This method initializes jButton16
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton16() {
		if(jButton16 == null) {
			jButton16 = new javax.swing.JButton();
			jButton16.setSize(42, 42);
			jButton16.setLocation(5, 143);
			jButton16.setName("jbtn_9");
			jButton16.setText("9");
		}
		return jButton16;
	}
	/**
	 * This method initializes jButton17
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton17() {
		if(jButton17 == null) {
			jButton17 = new javax.swing.JButton();
			jButton17.setSize(42, 42);
			jButton17.setLocation(51, 5);
			jButton17.setName("jbtn_1");
			jButton17.setText("1");
		}
		return jButton17;
	}
	/**
	 * This method initializes jButton18
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton18() {
		if(jButton18 == null) {
			jButton18 = new javax.swing.JButton();
			jButton18.setSize(42, 42);
			jButton18.setLocation(97, 51);
			jButton18.setName("jbtn_5");
			jButton18.setText("5");
		}
		return jButton18;
	}
	/**
	 * This method initializes jButton19
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton19() {
		if(jButton19 == null) {
			jButton19 = new javax.swing.JButton();
			jButton19.setSize(42, 42);
			jButton19.setLocation(5, 5);
			jButton19.setName("jbtn_0");
			jButton19.setText("0");			
			jButton19.addMouseListener(new java.awt.event.MouseAdapter() { 
				public void mouseClicked(java.awt.event.MouseEvent e) {
					jTextPane.setText(jTextPane.getText()+"0"); //equivalente Java ao jmm_Saida.Text := jmm_Saida.Text + '0' do Delphi;   
					//System.out.println("mouseClicked()"); // TODO Auto-generated Event stub mouseClicked()
				}
			});
		}
		return jButton19;
	}
	/**
	 * This method initializes jButton20
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton20() {
		if(jButton20 == null) {
			jButton20 = new javax.swing.JButton();
			jButton20.setSize(42, 42);
			jButton20.setLocation(51, 97);
			jButton20.setName("jbtn_7");
			jButton20.setText("7");
		}
		return jButton20;
	}
	/**
	 * This method initializes jButton21
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton21() {
		if(jButton21 == null) {
			jButton21 = new javax.swing.JButton();
			jButton21.setSize(42, 42);
			jButton21.setLocation(51, 51);
			jButton21.setName("jbtn_4");
			jButton21.setText("4");
		}
		return jButton21;
	}
	/**
	 * This method initializes jButton22
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton22() {
		if(jButton22 == null) {
			jButton22 = new javax.swing.JButton();
			jButton22.setSize(42, 42);
			jButton22.setLocation(97, 5);
			jButton22.setName("jbtn_2");
			jButton22.setText("2");
		}
		return jButton22;
	}
	/**
	 * This method initializes jButton23
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton23() {
		if(jButton23 == null) {
			jButton23 = new javax.swing.JButton();
			jButton23.setSize(42, 42);
			jButton23.setLocation(97, 97);
			jButton23.setName("jbtn_8");
			jButton23.setText("8");
		}
		return jButton23;
	}
	/**
	 * This method initializes jButton24
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton24() {
		if(jButton24 == null) {
			jButton24 = new javax.swing.JButton();
			jButton24.setSize(42, 42);
			jButton24.setLocation(5, 97);
			jButton24.setName("jbtn_6");
			jButton24.setText("6");
		}
		return jButton24;
	}
	/**
	 * This method initializes jTextPane
	 * 
	 * @return javax.swing.JTextPane
	 */
	private javax.swing.JTextPane getJTextPane() {
		if(jTextPane == null) {
			jTextPane = new javax.swing.JTextPane();
			jTextPane.setSize(176, 208);
			jTextPane.setLocation(5, 34);
			jTextPane.setName("jmm_Saida");
		}
		return jTextPane;
	}
	/**
	 * This method initializes jLabel
	 * 
	 * @return javax.swing.JLabel
	 */
	private javax.swing.JLabel getJLabel() {
		if(jLabel == null) {
			jLabel = new javax.swing.JLabel();
			jLabel.setSize(176, 25);
			jLabel.setText("Saída:");
			jLabel.setLocation(5, 6);
		}
		return jLabel;
	}
	/**
	 * This method initializes jPanel3
	 * 
	 * @return javax.swing.JPanel
	 */
	private javax.swing.JPanel getJPanel3() {
		if(jPanel3 == null) {
			jPanel3 = new javax.swing.JPanel();
			jPanel3.setLayout(null);
			jPanel3.add(getJButton27(), null);
			jPanel3.add(getJButton28(), null);
			jPanel3.add(getJButton26(), null);
			jPanel3.add(getJButton29(), null);
			jPanel3.add(getJButton31(), null);
			jPanel3.add(getJButton30(), null);
			jPanel3.add(getJButton32(), null);
			jPanel3.add(getJButton25(), null);
			jPanel3.setSize(102, 249);
			jPanel3.setLocation(262, 5);
			jPanel3.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.black,1));
		}
		return jPanel3;
	}
	/**
	 * This method initializes jButton25
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton25() {
		if(jButton25 == null) {
			jButton25 = new javax.swing.JButton();
			jButton25.setSize(45, 45);
			jButton25.setPreferredSize(new java.awt.Dimension(45,45));
			jButton25.setLocation(53, 149);
			jButton25.setName("jbtn_%");
			jButton25.setText("%");
		}
		return jButton25;
	}
	/**
	 * This method initializes jButton26
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton26() {
		if(jButton26 == null) {
			jButton26 = new javax.swing.JButton();
			jButton26.setSize(45, 45);
			jButton26.setLocation(5, 101);
			jButton26.setName("jbtn_*");
			jButton26.setText("*");
		}
		return jButton26;
	}
	/**
	 * This method initializes jButton27
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton27() {
		if(jButton27 == null) {
			jButton27 = new javax.swing.JButton();
			jButton27.setSize(45, 45);
			jButton27.setLocation(5, 53);
			jButton27.setName("jbtn_+");
			jButton27.setText("+");
		}
		return jButton27;
	}
	/**
	 * This method initializes jButton28
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton28() {
		if(jButton28 == null) {
			jButton28 = new javax.swing.JButton();
			jButton28.setSize(45, 45);
			jButton28.setLocation(53, 53);
			jButton28.setName("jbtn_-");
			jButton28.setText("-");
		}
		return jButton28;
	}
	/**
	 * This method initializes jButton29
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton29() {
		if(jButton29 == null) {
			jButton29 = new javax.swing.JButton();
			jButton29.setSize(92, 45);
			jButton29.setLocation(5, 5);
			jButton29.setName("btn_Limpar");
			jButton29.setText("Limpar");
		}
		return jButton29;
	}
	/**
	 * This method initializes jButton30
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton30() {
		if(jButton30 == null) {
			jButton30 = new javax.swing.JButton();
			jButton30.setSize(92, 45);
			jButton30.setLocation(5, 199);
			jButton30.setName("btn_=");
			jButton30.setText("=");
		}
		return jButton30;
	}
	/**
	 * This method initializes jButton31
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton31() {
		if(jButton31 == null) {
			jButton31 = new javax.swing.JButton();
			jButton31.setSize(45, 45);
			jButton31.setLocation(53, 101);
			jButton31.setName("jbtn_/");
			jButton31.setText("/");
		}
		return jButton31;
	}
	/**
	 * This method initializes jButton32
	 * 
	 * @return javax.swing.JButton
	 */
	private javax.swing.JButton getJButton32() {
		if(jButton32 == null) {
			jButton32 = new javax.swing.JButton();
			jButton32.setSize(45, 45);
			jButton32.setLocation(5, 149);
			jButton32.setName("jbtn_@");
			jButton32.setText("@");
		}
		return jButton32;
	}
}  //  @jve:visual-info  decl-index=0 visual-constraint="10,10"
[/code][/quote]

6 Respostas

Jair_Rillo_Junior

dentro do método

public static void main(String args[])

coloque a linha

new Calc();

ae sim irá funcionar :wink:

T

“ManchesteR”:
dentro do método

public static void main(String args[])

coloque a linha

new Calc();

ae sim irá funcionar :wink:

Acabei de testar… não deu certo :frowning:

leonardom

Acrescente: this.setVisible(true); no seu método initialize

private void initialize() {
      this.setContentPane(getJDesktopPane());
      this.setSize(564, 288);
      this.setTitle("Calculadora Decimal/Romana");
      this.setVisible(true);
   }
passos

Quando você executa uma classe ele procura pelo metodo public static void main(String[] args) e o executa. Como o seu está vazio ele não está fazendo nada. Dentro deste você deverá construir uma instancia da sua classe.

public static void main(String[] args) { // Cria uma instancia da sua classe Calc c = new Calc // Mostra a mesma na tela c.setVisible(true); }

T

Obrigado a todos pelas dicas. Vou testá-las em meu programa hoje à noite, caso surgirem novas dúvidas volto a postar nesse tópico.

T

Mais uma vez obrigado a todos. Problema resolvido. Fiz conforme a última mensagem , e deu tudo certo. Aos poucos vou desvendando o “caminho das pedras”… :wink:

Abraço,
Tiago.

Criado 4 de maio de 2004
Ultima resposta 5 de mai. de 2004
Respostas 6
Participantes 4