Solved

Panels are added, but they do not appear on the applet!!

Posted on 2004-09-12
6
181 Views
Last Modified: 2010-03-31
Hey experts!

What I want from anyone of you is just to download the following Java files from this website:

http://students.aub.edu.lb/~mte01/lcfilemain.zip

These files belong to 2 programs (a server and a client); the server is run from the main function in the "TalkServer" class, and the client is run from the "Applet5" class (you can also use the html file "Applet5"); note the two programs share common files.

Run the server, and then the applet,then click on "Ind. Mat. Par Cables" in the list that shows on the left, then 4 text boxes would show; type in them "DNYA" & "1" respectively in the top two, and then again "DNYA" & "1" again in the bottom two (ignore the double quotations), then press OK, you should see an empty panel under the label "LibanCables". Go the function "drawreport2" in the Applet5 class , and see (particularly at the end of the function) how everything is added to the viewport of jScrollPane2, but amazingly nothing would appear on the screen when the applet is run!
0
Comment
Question by:mte01
  • 3
  • 2
6 Comments
 
LVL 92

Expert Comment

by:objects
ID: 12040294
try calling revalidate() after you have changed the layout.
0
 
LVL 3

Author Comment

by:mte01
ID: 12040340
It didn't solve the problem :(.... I read the documentation about revalidate, and remembered that I had such problems before, and used to solve them with setSize (which sutomatically calls revalidate), but now it seems that nothing is working.
0
 
LVL 16

Accepted Solution

by:
gnoon earned 300 total points
ID: 12040849
>and see (particularly at the end of the function) how everything is added to the viewport of jScrollPane2, but amazingly nothing would appear on the screen when the applet is run!

I think that the problem, you added everything to the viewport but only the last added component will be shown (it replaces all other components).

From the code you posted, I see you've added the scrollpane to jPanel6, so try to call jPanel6.revalidate().
(Components --> jScrollPane2 --> jPanel6 --> jSplitPane1 --> JApplet)

For another thing, you've used a lot of null layouts inside drawreport2 function, that may cause components invisible.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 3

Author Comment

by:mte01
ID: 12040883
Trying to validate jPanel6 didn't work either. As for removing the null layouts, I'll try that in the morning and inform you of the results because it's now 5:45 AM Beirut time, and I need to get some sleep :)

P.S.: This was CEHJ's idea to use null Layout managers instead of XYLayout managers (for controlling the coordinates of the component in a JPanel): http://www.expertsexchange.com/Programming/Programming_Languages/Java/Q_21123550.html
0
 
LVL 92

Assisted Solution

by:objects
objects earned 200 total points
ID: 12040891
Using a null layout manager is not a good idea.
And if you are forget about using revalidate() as you are totally responsible for laying out the panels in that case.
If using a null layout you need to ensure you set both the position *and* size of every component added.

I'd suggest instead using a layout manager, it'll save you lots of grief in the long run.
0
 
LVL 3

Author Comment

by:mte01
ID: 12042009
Finally!!! Problem is solved using the XYLayout layout managers instead of null ones.....thanks guys
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
iterator/ListIterator approach 17 39
String array comparison 4 38
Java: The Public Class Main 4 30
Running JavaFX on the Raspberry Pi 27 39
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question