Tentando denovo fazer o menu funcionar!

5 respostas
tRuNkSnEt

dAEW gALERA!!

Tipo to aqui na luta tentado fazer um menu rox (aprendendo esses eventos huhuh)....so que mais umas vez ta dando erro!!!!!!!!

Analise o codigo!!

Sair.addActionListener(new ActionListener() {
      public void actionPerformed( ActionEvent event ) {
      System.exit(0);
      } } );
Sobre.addActionListener(new ActionListener() {
       public void actionPerformed( ActionEvent event ){
             AjudaSobre dlg = new AjudaSobre(); <----Erro Nessa Linha!
             Dimension dlgSize = dlg.getPreferredSize();
             Dimension frmSize = getSize();
             Point loc = getLocation();
             dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
             dlg.setModal(true);
             dlg.pack();
             dlg.show();

            }});
}

Erro: Constructor AjudaSobre() not found in class trabalhoadm.AjudaSobre at line 120.
a AjudaSobre e uma classe que to tentando instancia-la dentro da classe menus!!!!!!!!
C alguem puder ajudar desde ja agradeço!!! Tks!!!

5 Respostas

caiofilipini

Posta o código da classe AjudaSobre pra gente poder ver… :wink:

Daniel_Quirino_Olive

Das assinaturas disponíveis para o construtor da classe AjudaSobre, nenhuma delas é

public AjudaSobre(){ 
   // alguma código...
}

:slight_smile:

tRuNkSnEt

Olha o codigo AjudaSobre!!!!!!!

public class AjudaSobre extends JDialog implements ActionListener {

  JPanel panel1 = new JPanel();
  JPanel panel2 = new JPanel();
  JPanel insetsPanel1 = new JPanel();
  JPanel insetsPanel2 = new JPanel();
  JPanel insetsPanel3 = new JPanel();
  JButton button1 = new JButton();
  JLabel imageLabel = new JLabel();
  JLabel label1 = new JLabel();
  JLabel label2 = new JLabel();
  JLabel label3 = new JLabel();
  JLabel label4 = new JLabel();
  ImageIcon image1 = new ImageIcon();
  BorderLayout borderLayout1 = new BorderLayout();
  BorderLayout borderLayout2 = new BorderLayout();
  FlowLayout flowLayout1 = new FlowLayout();
  GridLayout gridLayout1 = new GridLayout();
  String product = "";
  String version = "1.0";
  String copyright = "Copyright (c) 2003";
  String comments = "";

private AjudaSobre(Frame parent
               ) {
    super(parent);
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }

  //Component initialization
  private void jbInit() throws Exception  {
    imageLabel.setIcon(image1);
    this.setTitle("About");
    panel1.setLayout(borderLayout1);
    panel2.setLayout(borderLayout2);
    insetsPanel1.setLayout(flowLayout1);
    insetsPanel2.setLayout(flowLayout1);
    insetsPanel2.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    gridLayout1.setRows(4);
    gridLayout1.setColumns(1);
    label1.setText(product);
    label2.setText(version);
    label3.setText(copyright);
    label4.setText(comments);
    insetsPanel3.setLayout(gridLayout1);
    insetsPanel3.setBorder(BorderFactory.createEmptyBorder(10, 60, 10, 10));
    button1.setText("Ok");
    button1.addActionListener(new AjudaSobre_button1_actionAdapter(this));
    button1.addActionListener(this);
    insetsPanel2.add(imageLabel, null);
    panel2.add(insetsPanel2, BorderLayout.WEST);
    this.getContentPane().add(panel1, null);
    insetsPanel3.add(label1, null);
    insetsPanel3.add(label2, null);
    insetsPanel3.add(label3, null);
    insetsPanel3.add(label4, null);
    panel2.add(insetsPanel3, BorderLayout.CENTER);
    insetsPanel1.add(button1, null);
    panel1.add(insetsPanel1, BorderLayout.SOUTH);
    panel1.add(panel2, BorderLayout.NORTH);
    setResizable(true);
  }


  //Overridden so we can exit when window is closed
   public void processWindowEvent(WindowEvent e) {
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      cancel();
    }
    super.processWindowEvent(e);
  }


  //Close the dialog
  private void cancel() {
    dispose();
  }


  //Close the dialog on a button event
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == button1) {
      cancel();
    }
  }

 public void button1_actionPerformed(ActionEvent e) {

  }
}

 class AjudaSobre_button1_actionAdapter implements java.awt.event.ActionListener {
  AjudaSobre adaptee;

  AjudaSobre_button1_actionAdapter(AjudaSobre adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
    adaptee.button1_actionPerformed(e);
  }
}

Tipo eu to analisando esse codigo direito....ele tem muito lixo mas so quero saber como instanciar ele corretamente na minha classe de menus!!!!!! Vlw ai em galera!!!

ozielneto

SWING Tutor…

http://java.sun.com/docs/books/tutorial/uiswing/index.html

http://developer.java.sun.com/developer/onlineTraining/Programming/JDCBook/swing2.html

Good luck!

tRuNkSnEt

OPa BLz!!! 8)

Vc tem essas certificações ai tudo?? nusga rox!!!

Tipo eu realmente presciso saber mais sobre essa swing vc tem alguns tutor em portugues meu ingles e horrivel mas ja to providenciando melhoras nisso!!!

Brigado!!! :oops:

Criado 25 de setembro de 2003
Ultima resposta 26 de set. de 2003
Respostas 5
Participantes 4