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 / GUI / December 2003

Tip: Looking for answers? Try searching our database.

labels on panels disappear

Thread view: 
Robert - 02 Dec 2003 12:00 GMT
Hi everyone,

I am pretty new to Java and I am writing a simple chess applet. My
chessboard is a gridlayout with panels. On those panels there are
labels which symbolize the chess pieces. When I click on a piece I can
then click on a second field of the chessboard and the piece (the
label) moves to it. For some reason it does not show up there though.
When I run the applet using Eclipse I can make the piece show up when
I resize the applet with my mouse. When I load the applet with a
browser this does not work either. It is strange to me that everyting
works fine when I move a piece to a field where there had been another
piece before. Not so, when I move the piece to a field, where there
has not been another piece before. I have tried several repaint
methods on it but it still has not worked. Please help me out on this.
You can try my applet at

http://mycgiserver.com/~schachserver/Schach/schachclient.html

Note that the labels are in German but this does not matter. Hit the
"Ziehen" button and you can then move the pieces. Click on a piece and
it will be highlighted. Then click on second field (no matter where as
long as there is no piece on it) and it will move there.

You can see what I mean if you move the piece in the upper left corner
to some field with no piece on it. It will not show up there. If you
then move the piece next to it (second colum, upper row) to the upper
left corner. This will show up there for some reason.

Please help.
Andrew Thompson - 02 Dec 2003 12:47 GMT
....
> I am pretty new to Java and I am writing a simple chess applet.

Simple _and_ applet in the same sentence?

Applets are never simple, and not an ideal task for
someone 'pretty new to java'.  They have complications
that go beyond anything you will experience with an
application.

e.g.  Your Applet appears in Mozilla 1.3a, does not appear
in IE 6 (with Java 1.4.1 plug-in installed) and NN 4.78
asks for the 1.4 plug-in to be installed (as it should).

All tested under XP.

> My
> chessboard is a gridlayout with panels. On those panels there are
> labels which symbolize the chess pieces. When I click on a piece I can
> then click on a second field of the chessboard and the piece (the
> label) moves to it. For some reason it does not show up there though.

Yes, quite.  Even the Mozilla rendering was having
great difficulty.  After a lot of clicking around, I _think_
I got one of the labels to (re)appear briefly.

> When I run the applet using Eclipse I can make the piece show up when
> I resize the applet with my mouse.

Ughhh... and learning Java using an advanced IDE.

Drop it and learn how to compile and run your
programs from the command line.  You will need
the knowledge.  Trust me.

> When I load the applet with a
> browser this does not work either.
<snip rest>

Somebody may already know (or guess) your
error, if they jump in, all well, but I think we
need to see your code.

I recommend you strip your code down
to the absolute minimum that displays the problem,
and post that here.  It is also important to make
the code compileable and self contained.

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site
Robert - 04 Dec 2003 21:14 GMT
I still don't think I should drop it. I belive the chess applet is a
very good task to acomplish when new to Java.
Andrew Thompson - 05 Dec 2003 04:38 GMT
> I still don't think I should drop it. I belive the chess applet is a
> very good task to acomplish when new to Java.

I assume you are referring to my comment that
Applets were not good for starters.

Let me clarify what I mean.

If I were developing this project, I would ensure
that the 'chessboard' was in a Panel that could be
dropped into either an Applet or Frame, but I would
_develop_ it as an application, and _only_ make it an
applet after I had the application version working.

Aplications are easier to debug and refresh than
Applets.

Please note, that even this 'seasoned hack'* in Java
would not approach the Applet _first_.

* Then there are the 'Gurus' - of which, I'm definitely
_not_ one.

So - I am not suggesting you drop the chess project,
but develop it as an application (or - best of all, a non-GUI
app) then, _then_ convert it to an applet.

Make sense?

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site


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.