Not sure how to write this, but I might need parent class instance
publicclass SimpleBrowserextends BrowserBean{// BrowserBean extends JFrame
class LayoutManager{
/**
* Handle {@link #urlLabelText} to change color if {@link java.net.URL} displayed is not {@link #homeURL}
*/
privatevoid handleURLLabelText(){
l =new JLabel(urlLabelText);
if (getURL() !=null && getHomeURL() !=null && !getURL().equals(getHomeURL())){
l.setForeground(Color.RED);
JOptionPane.showConfirmDialog(this.getClass().getSuperclass(),
"Do you wish to set \"" + getURLPath() +"\" as your default homepage?",
"Set as new homepage",
JOptionPane.OK_CANCEL_OPTION);
}
}
}
}
I am trying to correctly use JOptionPane.showConfirmDialog() in order to set up an confirm option pane embedded internally into the instance of the class SimpleBrowser. However, upon doing so I get the following compiler error:
[quote]
Cannot find symbol
symbol: method showConfirmDialog(java.lang.Class< capture of ? super capture of ? extends com.ppowell.tools.ObjectTools.SimpleBrowser.LayoutManager >,java.lang.String,java.lang.String,int)
location: class javax.swing.JOptionPane
[/quote]
Not sure exactly what I need to put into showConfirmDialog() to make it work, based on the architecture above, what do you recommend?
Thanks
Phil
> Not sure exactly what I need to put into showConfirmDialog() to make it work,
> based on the architecture above, what do you recommend?
Reading the documentation... I see that showConfirmDialog() takes a Component as its first parameter. So I don't understand why you are trying to pass it a Class object. That business about "parent class instance" (whatever that is supposed to mean) is really irrelevant. If your class is a Component then most likely you want to pass this as the first parameter.
Edit: Oh, I see that code is inside an inner class. Sorry, I missed that. Perhaps you were trying to find out what the instance of the containing class was. That would be SimpleBrowser.this.
That's just it.. I have to pass a component
LayoutManager extends SimpleBrowser which extends SimpleBean which extends JFrame, so I don't understand, so I have to pass an actual component as in only those that directly extend Component, or why can't I get away with passing LayoutManager or SimpleBrowser?
Phil
JOptionPane.showConfirmDialog(this, ...
ejpa at 2007-7-9 20:55:53 >

ejp can i get a good discount on your Java networking book? Please....
and take the money out of the mouths of my starving children?please ...Save up. It will save you more than it costs you by several orders of magnitude.
ejpa at 2007-7-9 20:55:53 >

oh whatever dude you are the author of that book and i saw your website, i am sure $20 will not hurt you. dont worry i will give lots of blessing to you and your children :)
Well I don't actually have any starving children yet, or even any children, but if I start giving away discounts like that who knows what could happen?
Not that the discounts are mine to give, they are the publisher's.
Anyway I'm sure $69.95 won't hurt you ;-) It's about an hour's work: you'll probably save it on the first day.
ejpa at 2007-7-9 20:55:53 >

> Well I don't actually have any starving children yet,
> or even any children, but if I start giving away
> discounts like that who knows what could happen?
True.
> Not that the discounts are mine to give, they are the
> publisher's.
You got a valid point here. appologies i did'nt knew about all that stuff.
> Anyway I'm sure $69.95 won't hurt you ;-) It's about
> an hour's work: you'll probably save it on the first
> day.
hmm ok. let me save some money. i prefer this book because i can catch the author easily on the forums if i have any problems and i have heard alot of good stuff about this book but cotton.m prfers to go to Java tutorial on networking first and then buy this book. O well thanks anyways. definitely looking forward for this book.
That's it. Save, prioritize, economize, make a household budget, cut down, refinance, sell the wife, ... Whatever it takes. Remember me and the starving kids ...
ejpa at 2007-7-9 20:55:53 >

> That's just it.. I have to pass a component
>
> LayoutManager extends SimpleBrowser which extends
> SimpleBean which extends JFrame
...which extends Frame which extends Window which extends Container which extends Component.
> so I don't understand, so I have to pass an actual component as
> in only those that directly extend Component, or why
> can't I get away with passing LayoutManager or
> SimpleBrowser?
So SimpleBrowser IS a Component. Use that.
> > JOptionPane.showConfirmDialog(this, ...> Produces the exact same "Cannot find symbol" compiler error, sorry.
> > That's just it.. I have to pass a component
> >
> > LayoutManager extends SimpleBrowser which extends
> > SimpleBean which extends JFrame
LayoutManager does not extend SimpleBrowser.
LayoutManager is an inner class of SimpleBrowser (more a house-mates(or package/class) relationship than a parent/child relationship).
mlka at 2007-7-9 20:55:54 >

> > > That's just it.. I have to pass a component
> > >
> > > LayoutManager extends SimpleBrowser which
> extends
> > > SimpleBean which extends JFrame
>
> LayoutManager does not extend SimpleBrowser.
> LayoutManager is an inner class of SimpleBrowser
> (more a house-mates(or package/class) relationship
> than a parent/child relationship).
Then I want SimpleBrowser, how do I get that, or do I get that?
> Then I want SimpleBrowser, how do I get that, or do I
> get that?
To quote reply one:
Edit: Oh, I see that code is inside an inner class. Sorry, I
missed that. Perhaps you were trying to find out what the
instance of the containing class was. That would be
SimpleBrowser.this.
mlka at 2007-7-9 20:55:54 >

> > Then I want SimpleBrowser, how do I get that, or do
> I
> > get that?
>
> To quote reply one:
>
> Edit: Oh, I see that code is inside an inner class.
> Sorry, I
> missed that. Perhaps you were trying to find out what
> the
> instance of the containing class was. That would be
> SimpleBrowser.this.
Ok, that works, thanx, but why? That syntax makes no sense to me.
> Ok, that works, thanx, but why? That syntax makes no> sense to me.[url= http://java.sun.com/docs/books/tutorial/java/javaOO/nested.html]Nested Classes[/url]
mlka at 2007-7-9 20:55:56 >

> > Ok, that works, thanx, but why? That syntax makes
> no
> > sense to me.
>
> [url=http://java.sun.com/docs/books/tutorial/java/java
> OO/nested.html]Nested Classes[/url]
Sorry does not answer my question and I read the full tutorial. What's the deal with SimpleBrowser.this?
> Anyway I'm sure $69.95 won't hurt you ;-) It's about> an hour's work: you'll probably save it on the first> day.ISBN?
> > > Ok, that works, thanx, but why? That syntax
> makes
> > no
> > > sense to me.
> >
> >
> [url=http://java.sun.com/docs/books/tutorial/java/java
>
> > OO/nested.html]Nested Classes[/url]
>
> Sorry does not answer my question and I read the full
> tutorial. What's the deal with SimpleBrowser.this?
See the two circles on the first page. The big circle is an
instance of SimpleBrowser. The small circle is an instance of
LayoutManager.
To access SimpleBrowsers methods in LayoutManager, you
don't need to do anything special. But to access the
SimpleBrowsers object itself you can not simply use "this", you
have to differentiate between the LayoutManager and the
SimpleBrowsers "this".
mlka at 2007-7-9 20:55:56 >

> > > > Ok, that works, thanx, but why? That syntax
> > makes
> > > no
> > > > sense to me.
> > >
> > >
> >
> [url=http://java.sun.com/docs/books/tutorial/java/java
>
> >
> > > OO/nested.html]Nested Classes[/url]
> >
> > Sorry does not answer my question and I read the
> full
> > tutorial. What's the deal with
> SimpleBrowser.this?
>
> See the two circles on the first page. The big circle
> is an
> instance of SimpleBrowser. The small circle is an
> instance of
> LayoutManager.
> To access SimpleBrowsers methods in LayoutManager,
> you
> don't need to do anything special. But to access the
>
> SimpleBrowsers object itself you can not simply use
> "this", you
> have to differentiate between the LayoutManager and
> the
> SimpleBrowsers "this".
But that indicates that I'm using a static reference, and that's what is throwing me completely here because it's not being referenced anywhere statically except as "SimpleBrowser.this". Why would that work as opposed to (SimpleBrowser)this.getClass().getSuperclass() which ensures I am not calling the outer class statically?
> But that indicates that I'm using a static reference,
Not in this case. This is a special case. As LayoutManager is a nestled class of SimpleBrowser it magically has a reference to the outter SimpleBrowser.
Personally I'm not a fan of the OutterClass.this, and think maybe a new keyword such as "outter" would have been better.
> except as "SimpleBrowser.this". Why would that work
> as opposed to
> (SimpleBrowser)this.getClass().getSuperclass() which
> ensures I am not calling the outer class statically?
You are also still confused about parent child vs nestled classes. And the difference between an instance of Class and an instance of a class by the looks of things.
SimpleBrowser is NOT the super class of LayoutManager. An instance of SimpleBrowser is the more like a package for instances of LayoutManager.
getSuperclass returns a Class object. This is metadata about a class. Not an instance of the class.
mlka at 2007-7-9 20:55:56 >

> > Anyway I'm sure $69.95 won't hurt you ;-) It's
> about
> > an hour's work: you'll probably save it on the
> first
> > day.
>
> ISBN?
Found it, and ordered it together with Mastering Regular expressions. Two books that might be interesting.
> > But that indicates that I'm using a static
> reference,
>
> Not in this case. This is a special case. As
> LayoutManager is a nestled class of SimpleBrowser it
> magically has a reference to the outter
> SimpleBrowser.
> Personally I'm not a fan of the OutterClass.this, and
> think maybe a new keyword such as "outter" would have
> been better.
> > except as "SimpleBrowser.this". Why would that
> work
> > as opposed to
> > (SimpleBrowser)this.getClass().getSuperclass()
> which
> > ensures I am not calling the outer class
> statically?
>
> You are also still confused about parent child vs
> nestled classes. And the difference between an
> instance of Class and an instance of a class by the
> looks of things.
>
> SimpleBrowser is NOT the super class of
> LayoutManager. An instance of SimpleBrowser is the
> more like a package for instances of
> LayoutManager.
>
> getSuperclass returns a Class object. This is
> metadata about a class. Not an instance of the class.
I can only say "OK" to that. Even after reading the tutorials online and various threads, it isn't clicking, probably will another time.
I guess for now I'll just have to blindly accept Outerclass.this and just move on.
