?
Solved

Simple question revisited - classes and methods

Posted on 2011-09-07
16
Medium Priority
?
235 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
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

755 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