aspose file tools*
The moose likes Applets and the fly likes Trouble with revalidate() and repaint() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Trouble with revalidate() and repaint()" Watch "Trouble with revalidate() and repaint()" New topic
Author

Trouble with revalidate() and repaint()

Nate Rogers
Greenhorn

Joined: Mar 20, 2013
Posts: 3
I've been working on an applet the past couple of days that basically acts as a very specialized calculator. I've written other applets that use the same method that I'm using here, but for some reason I can't seem to get a couple of the panels to revalidate() and repaint(). Here is the section of code I'm working on:



I have all of those println() as I'm trying to debug. I've checked the TestSim objects and they're being stored in the ArrayList active properly. Additionally, I can retrieve all of the information properly. I've identified the updatePlot() method as the problem:



I've used this method many times before and was able to add and repaint the plot just fine. However, it doesn't seem to be working this time. I've been at it all day, and I'm hoping some fresh eyes may catch something simple that I've missed.

Also, in case you're unfamiliar with jmathplot, here is the project site: https://code.google.com/p/jmathplot/
It has all of the source code and documentation. It's a really nice little package, and if I wasn't so busy with my current work, I would join to add a few features.

Thanks for taking a look!
Nate Rogers
Greenhorn

Joined: Mar 20, 2013
Posts: 3
I've been working on it a bit more. Here's the console output if I click on the "Generate" button.

generate
Axial Test
Axial-1
active.size() = 1
TestSim@8c0d58
Axial-1
1: Axial-1
2: java.awt.Color[r=0,g=0,b=255]
3: 0.001
4: 0.0053
0
Setting Axis Labels...
org.math.plot.Plot2DPanel[,0,0,0x0,invalid,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]
org.math.plot.Plot2DPanel[,0,0,0x0,invalid,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]
org.math.plot.Plot2DPanel[,0,0,0x0,invalid,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]
org.math.plot.Plot2DPanel[,0,0,0x0,invalid,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]
org.math.plot.Plot2DPanel[,0,0,0x0,invalid,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]


Note how the Plot2DPanel remains invalid even after I call revalidate(). To save you some time going through the documentation, this toString() method is inherited from JPanel. Thoughts?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

Welcome to the Ranch.
To help us help you, please provide your SSCCE (<= click link to find out what it really means) code.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Nate Rogers
Greenhorn

Joined: Mar 20, 2013
Posts: 3
Nevermind. I was able to figure it out. Today, as I was combing through my code trying to figure out what I could take out to make it easier to read (for all of you), I noticed that on line 311:



I add the plot panel instead of its container (plotContainer). Changing this solved my problem. However, I did notice that the string output hasn't changed at all. It's not important, but food for thought.

Thanks anyway!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Trouble with revalidate() and repaint()