aspose file tools*
The moose likes Java in General and the fly likes Eclipse and Netbeans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Eclipse and Netbeans" Watch "Eclipse and Netbeans" New topic
Author

Eclipse and Netbeans

chanakya nani
Greenhorn

Joined: Jan 11, 2011
Posts: 29
Guys,
I'm unable to Compile a program in Eclipse IDE,where the same code gets compiled in NetBeans
Why is that?
What to do to get it Compiled.?
I'm Asking Because Eclipse is handy than NetBEans(atleast i feel).

It is also getting it Compiled throuugh CMD.


the code is :



import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class TwoButtons{
JFrame frame;
JLabel label;
int i=0;
public static void main(String[] args){
TwoButtons twoB=new TwoButtons();
twoB.go();
}
public void go(){
frame =new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600,600);
frame.setVisible(true);

JButton labelbutt=new JButton("change Label");
labelbutt.addActionListener(new LabelListener());
JButton clickbutt=new JButton("change color");
clickbutt.addActionListener(new ClickListener());

label=new JLabel("i'm a label");


frame.getContentPane().add(BorderLayout.SOUTH,clickbutt);





frame.getContentPane().add(BorderLayout.EAST,labelbutt);
frame.getContentPane().add(BorderLayout.NORTH,label);

}

class LabelListener implements ActionListener{
public void actionPerformed(ActionEvent event){


if(i==0)

label.setText("ouch");
else

label.setText("lowde");

i++;



}
}

class ClickListener implements ActionListener{
public void actionPerformed(ActionEvent event){
frame.repaint();
}
}

}




Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 561
Please post your code inside code tags, and if you're getting an error, ALWAYS post the error, verbatim.


Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

Please UseCodeTags and TellTheDetails so that we can help you to solve the issue.


Mohamed Sanaulla | My Blog
chanakya nani
Greenhorn

Joined: Jan 11, 2011
Posts: 29
Mohamed Sanaulla wrote:Please UseCodeTags and TellTheDetails so that we can help you to solve the issue.



Thank You For Helping me....As you can see i am a new comer to the Java Ranch.
chanakya nani
Greenhorn

Joined: Jan 11, 2011
Posts: 29
Mohamed Sanaulla wrote:Please UseCodeTags and TellTheDetails so that we can help you to solve the issue.


I did what you have asked for...can you now please tell me where the error is.?
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

Did you try to compile the code in Eclipse? Or this is just the Error which is shown by the IDE? In any case this error should not be seen as JPanel IS-A JComponent
chanakya nani
Greenhorn

Joined: Jan 11, 2011
Posts: 29
Mohamed Sanaulla wrote:Did you try to compile the code in Eclipse? Or this is just the Error which is shown by the IDE? In any case this error should not be seen as JPanel IS-A JComponent


The Above Error is that of the IDE

I compiled it then i got the error as


Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method add(String, Component) in the type Container is not applicable for the arguments (String, MyDrawBoard)

at TwoButtons.go(TwoButtons.java:29)
at TwoButtons.main(TwoButtons.java:11)
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

Can you check if MyDrawBoard really extends JPanel?
chanakya nani
Greenhorn

Joined: Jan 11, 2011
Posts: 29
Mohamed Sanaulla wrote:Can you check if MyDrawBoard really extends JPanel?



I think it Extends it otherwise it maynot have compiled in CMD(through Notepad++)...am i right?
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

chanakya nani wrote:
Mohamed Sanaulla wrote:Can you check if MyDrawBoard really extends JPanel?



I think it Extends it otherwise it maynot have compiled in CMD(through Notepad++)...am i right?


How can you say you think?The code you have posted above does extend. There might be a chance that the source you are trying to compile in Eclipse doesn't extend.
chanakya nani
Greenhorn

Joined: Jan 11, 2011
Posts: 29
Mohamed Sanaulla wrote:
chanakya nani wrote:
Mohamed Sanaulla wrote:Can you check if MyDrawBoard really extends JPanel?



I think it Extends it otherwise it maynot have compiled in CMD(through Notepad++)...am i right?


How can you say you think?The code you have posted above does extend. There might be a chance that the source you are trying to compile in Eclipse doesn't extend.



Sorry but i didn't get you...what do you mean by the Source...how it differs from Eclipse IDE and that of from CMD one.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

chanakya nani wrote:Sorry but i didn't get you...what do you mean by the Source...how it differs from Eclipse IDE and that of from CMD one.

Ok. So can you post the code you are actually trying to compile in Eclipse?
chanakya nani
Greenhorn

Joined: Jan 11, 2011
Posts: 29
Mohamed Sanaulla wrote:
chanakya nani wrote:Sorry but i didn't get you...what do you mean by the Source...how it differs from Eclipse IDE and that of from CMD one.

Ok. So can you post the code you are actually trying to compile in Eclipse?


It's same as the above code.

Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

I just tried. Its compiling fine. See if there are no other errors being reported.
chanakya nani
Greenhorn

Joined: Jan 11, 2011
Posts: 29
Mohamed Sanaulla wrote:I just tried. Its compiling fine. See if there are no other errors being reported.


Okay Thank you very much..Maybe there is a problem with my eclipse..
Once again thank you very much for spending time for me..see you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Eclipse and Netbeans