Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / January 2006

Tip: Looking for answers? Try searching our database.

Probs compiling - instanceOf statement and close brackets

Thread view: 
PaulSchrum - 30 Dec 2005 22:34 GMT
I am a swing newbie and kind of inexperienced in java.  I am using
NetBeans (I don't think that comes in to play, though).

I am implementing my own layout manager, and I am getting compile
errors in which I do not understand what it wants me to do differently.
In my code listing I have put the compile error messages in comments
on the line in which they happen.  Can someone help me understand what
the compiler wants?

Thanks for your help

- Paul Schrum

  public void layoutContainer(Container target)  {
     synchronized(target.getTreeLock())  {
        Dimension dim;
        Insets insets = target.getInsets();
        int maxwidth = target.getWidth() - (insets.left +
insets.right);
        int nmembers = target.getComponentCount();
        int x = 0, y = insets.top;
        int rowh = 0, start = 0;
        for (int i = 0 ; i < nmembers ; i++)  {
              Component m = target.getComponent(i);
              if(m instanceOf JFrame) {     //  '/' expected
                 layoutContainer(m);
                 dim = m.getSize();
              }
              else if(m instanceOf(JTextField)) {
                 i = i + 0;
              }
        }                //   illegal start of expression
     }
  }
IchBin - 30 Dec 2005 23:04 GMT
> I am a swing newbie and kind of inexperienced in java.  I am using
> NetBeans (I don't think that comes in to play, though).
[quoted text clipped - 30 lines]
>       }
>    }

Think you want to use 'instanceof'  not 'instanceOf'.

Signature

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)

PaulSchrum - 30 Dec 2005 23:05 GMT
That solved my problem.  Thanks.
Mark Thomas - 31 Dec 2005 18:54 GMT
> I am a swing newbie and kind of inexperienced in java.  I am using
> NetBeans (I don't think that comes in to play, though).
>
> I am implementing my own layout manager, ....

As a swing newbie, why on earth would you try to implement your own
layout manager?  I've been working with Java for years and I've never
needed to to that.

Mark
IchBin - 31 Dec 2005 23:27 GMT
>> I am a swing newbie and kind of inexperienced in java.  I am using
>> NetBeans (I don't think that comes in to play, though).
[quoted text clipped - 6 lines]
>
> Mark

I guess just for pure academic curiosity and a lot of time on his hands.

Signature

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)

Roedy Green - 03 Jan 2006 00:46 GMT
>> As a swing newbie, why on earth would you try to implement your own
>> layout manager?  I've been working with Java for years and I've never
[quoted text clipped - 3 lines]
>
>I guess just for pure academic curiosity and a lot of time on his hands.

Not at all.  There are two valid reasons to write a layout manager.

1. to deeply understand them. You then have a better crack and making
other ones sit up and beg.

2. to avoid writing absolute positioning code that muddles app and
layout.  You extract the layout stuff into a custom layout manager.
e.g. see StarLayout. http://mindprod.com/jgloss/layout.html

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

PaulSchrum - 03 Jan 2006 22:05 GMT
Mark, IchBin, and Roedy,

Roedy wins the prize with his answer number 2.

(Sorry I did not respond sooner, but I have been out of reach of the
internet for a few days.)

I am working on an application to lay out text according to linguistic
relationships.  The layout method has already been set by professors at
my seminary.  (So the specs have been done for me.)  One of the things
this layout does is set text at certain page columns according to
whether the text is Conjunction, Subject, Verb, or Direct Object.
There are other requirements that I will not bore people with.

Anyway, as Roedy anticipated, I was faced with extensive absolute
positioning code.  Actually, in the my custom layout manager, I do
absolute positioning based on the users' linguistic markup anyway, but
it seemed to me that that was was Layout Managers were intended to do,
so that is the way I went.  Also, I am implenting the text on the
screen as a subclass of JTextField.  There's a lot of useful functions
there that I do not have to rewrite.

I don't know if my approach is going to be easier or harder, but it is
the route I am choosing for now.

- Paul
Roedy Green - 03 Jan 2006 22:19 GMT
> Actually, in the my custom layout manager, I do
>absolute positioning based on the users' linguistic markup anyway, but
>it seemed to me that that was was Layout Managers were intended to do,

Exactly. The job of a layout manager is to decide the absolute
positioning of everything in order to keep that level of detail from
muddling the application code and making it a nightmare to maintain.

In the layout manager you compute the positions of everything by some
clever logic.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.