Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie help needed with JPanel

Status
Not open for further replies.

Aleena

Programmer
Oct 3, 1999
27
US
I am having some difficulties in my program and I am hoping (make that praying) that someone on this board can offer some advice. I am not completely new to java but this is my first experience really using the Swing class. I am making a GUI interface that has a user input panel which I call UserInput. My UserInput class extends JPanel. This is all fine and the panel gets set up, etc. But when I want to send the UserInput panel to another class's constructor that takes a JPanel as an argument I get the following error:<br>C:\jdk1.2.2\bin\Lab7\UserInput.java:39: Incompatible type for constructor. Can't convert UserInput.1 to javax.swing.JPanel.<br>DataNode newDataNode = new DataNode(enterTextField.getText(), this);<br><br>I am making the call to create the new data node from my UserInput class so I assumed that using the &quot;this&quot; would send the UserInput object.<br><br>How can it not convert the UserInput to a JPanel when the user input is a JPanel...<br><br>ARGH !!!! I am sure I am making some newbie assumptions in my code somewhere. Any advice that anyone could offer would be greatly appreciated. If you need any other information about my program, just let me know :)<br><br>Thanks !!<br>Aleena<br><br>
 
<br><br>Try <br>DataNode newDataNode = new DataNode(enterTextField.getText(), (JPanel)this);<br>
 
I have already tried that with no luck :(<br>Then it just tells me it is an invalid cast.&nbsp;&nbsp;I have even tried changing constructor on the other side to take in a object of type UserInput.&nbsp;&nbsp;It tells me that it can not convert type UserInput to type UserInput.<br><br>I think I may have to kill my computer soon...<br><br>Thanks for trying though&nbsp;&nbsp;:)<br><br>Aleena
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top