?
Solved

Simple question revisited - classes and methods

Posted on 2011-09-07
16
Medium Priority
?
225 Views
Last Modified: 2012-05-12
I had thought that the earlier question was solved, but now I am getting another error.  This is I am going to send the code from each class file, so it is more clear.

The class below is the first class, from that class I need to call a method in the second class.
Here is the error I am getting,

The method ediBaseDialog() is undefined for the type ediBaseDialog

package com.ediua.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.ediua.dialogs.ediBaseDialog;
import java.awt.*;

public class ediDialogHandler extends AbstractHandler {
   
     
   public ediDialogHandler() {
      // TODO Auto-generated constructor stub
	   
   }
       
   @Override
   public Object execute(final ExecutionEvent event) throws ExecutionException {
	   ediBaseDialog.ediBaseDialog();  <=  Calling the method in question
	   return null;
   }
   
}

Open in new window



package com.ediua.dialogs;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import com.teamcenter.rac.aif.AbstractAIFDialog;

public class ediBaseDialog extends AbstractAIFDialog{
   private static final long serialVersionUID = 1L;
   private JPanel centerPanel = null; 
   
   public ediBaseDialog(Dialog parent){
      super(parent,"Lets Get Ready", true);
	  createDialog();
   } // end constructor
		    
   private void createDialog() {
	  //Component listPanel = EmailList();
   	  Component buttonPanel = OKCancelButtons();
   	  
	  centerPanel = new JPanel();
      centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.PAGE_AXIS));
      centerPanel.setPreferredSize(new Dimension(600, 200));
            
      centerPanel.add(Box.createRigidArea(new Dimension(5, 0)));
      //centerPanel.add(listPanel);
      centerPanel.add(Box.createHorizontalGlue());
      centerPanel.add(Box.createRigidArea(new Dimension(0, 2)));
      centerPanel.add(buttonPanel);
   
   }

//////////////////////////////////////////////////////////////////////////
//                                                                      //
//                        OKCancelButtons()                             //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

private JPanel OKCancelButtons() {
   JButton okButton = new JButton("OK");
   okButton.setEnabled(true);
   okButton.addActionListener(new ActionListener() {
   
      public void actionPerformed(ActionEvent e) {
         dispose();
      }
   });

   JButton cancelButton = new JButton("Cancel");
   cancelButton.setEnabled(true);
   cancelButton.addActionListener(new ActionListener() {
      
	   public void actionPerformed(ActionEvent e) {
          dispose();
       }
   });

   JPanel p = new JPanel();
   p.setBorder(BorderFactory.createLineBorder(Color.red));
   p.setLayout(new BoxLayout(p, BoxLayout.LINE_AXIS));
   p.add(Box.createHorizontalGlue());
   p.add(okButton);
   p.add(cancelButton);

return p;
}

}

Open in new window



Thanks for helping me out
0
Comment
Question by:jkteater
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 6
16 Comments
 
LVL 47

Expert Comment

by:for_yan
ID: 36499434

You cannot adfress constructor in this way:
 ediBaseDialog.ediBaseDialog();
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36499440
The name of the method ediBaseDialog();  in your second class is identical; with the
name of the lass - such method is called constructor and you can access
it only with the new


ediBaseDialog asdb = new ediBaseDialog(..)
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36499448


 ediBaseDialog.ediBaseDialog();  - this acnnot work

Constructor's role is to create inastance of the class and
simluultaneosu it can executs some lines inside constructor - but main thing
is to create instance of the class

Explain what you want tio accomplish

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 47

Expert Comment

by:for_yan
ID: 36499459
Maybe you bneed to declare createDialog as public static
and then you can call it from anothe class this way:

ediBaseDialog.createDialog()

this at least would work formally - do you want to create Dialog window in this
way - it is another story
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36499466

You can aslo do this way:

ediBaseDialog asdb = new ediBaseDialog(..)
asdb.createDialog(...)


In this acse your creatDialog should not be static, but it should be public (not private)
0
 

Author Comment

by:jkteater
ID: 36499510
ediBaseDialog asdb = new ediBaseDialog(..)

The constructor ediBaseDialog() is undefined

it is wanting something like

ediBaseDialog asdb = new ediBaseDialog(Dialog)
But i have tried to match the constructor from the second file.


0
 

Author Comment

by:jkteater
ID: 36499519
I was wrong about the Dialog -  I was trying to pass something that does not exist
0
 

Author Comment

by:jkteater
ID: 36499528
I may not even need the constructor in the second file
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36499532
You need to provide parameters of the required type

ediBaseDialog asdb = new ediBaseDialog(parent);


and parent shoudl be of type Dialog

then it would match
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36499536
Yes maybe you don't.
You just create your new window say Dialog in the createDialog method
0
 

Author Comment

by:jkteater
ID: 36499549
OK - let me try to explain what I am trying to do

I have a command on a menu.  when the user clicks the command - the first file is activated or executed.
The only reason for the first file is to execute the second file.  So the first file should execute the second file.  The second file is basically going to be my base dialog class.  I will be adding tables - list etc.... to it

All I am trying to do is when the user clicks the command a dialog box appears and they will work from there.

The files are in seperate directories and each file has its a differnt package.

Being the first file is only executing the second file - I am not sure I need a constructor in the second file.  If you can look at the 2 files and give me any help on how to do it - that would be great!!!!
0
 

Author Comment

by:jkteater
ID: 36499558
the first file is basically a handler
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36499591

You should just replace this line
ediBaseDialog.ediBaseDialog();  <=  Calling the method in question

with something like that:

Frame f = new Frame("tttle");
Dialog parent = new Dialog(f, false);
new ediBaseDialog(parent);

I cannot understand what is your Dialog paren

or indeed remnove that constructor from the clasee
and say

(new ediBaseDialog()).createDialog();


The problem that it extends



0
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 36499595


You should just replace this line
ediBaseDialog.ediBaseDialog();  <=  Calling the method in question

with something like that:

Frame f = new Frame("tttle");
Dialog parent = new Dialog(f, false);
new ediBaseDialog(parent);

I cannot understand what is your Dialog paren

or indeed remnove that constructor from the clasee
and say

(new ediBaseDialog()).createDialog();

0
 

Author Closing Comment

by:jkteater
ID: 36499636
Thanks for sticking with me on this one - I got rid of Dialog parent in the constructor and it worked fine.
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36499645

Great!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month8 days, 6 hours left to enroll

766 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question