Solved

Responding to Java JComponent extended classes's resize event

Posted on 2016-11-02
4
22 Views
Last Modified: 2016-11-02
I created a component that extends JComponent. In the form designer, when it is resized, I need to perform some actions..in this case increasing the diameter of a meter I am drawing.  What do I do to respond to the resize event inside that component during design time and runtime?
0
Comment
Question by:SStory
  • 2
4 Comments
 
LVL 14

Expert Comment

by:CPColin
Comment Utility
Try overriding Component.validate(). It should be called every time the component is resized. Alternatively, you could always calculate the dimension of the meter based on the current size of the component. That way, you can be sure it's correct, every time the component is painted. (It's been a while since I've done stuff with Swing, though.)
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
Comment Utility
.in this case increasing the diameter of a meter I am drawing.
If you're drawing in the JComponent in question, how are you doing that? It should be in paintComponent, in which case, you would know when and how large you need to draw the meter
0
 
LVL 25

Author Closing Comment

by:SStory
Comment Utility
I had already been trying, but apparently had some bad code.  Also, had to close my the file and recompile..apparently.  It seems to be working now.
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
:)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction: When a connection to the internet is established, there always exists a modem between the connected device and the ISP (Internet Service Provider). The Operating System (OS) on your PC controls the modem which communicates with the …
More and more people are using the enhanced small form-factor pluggable (SFP+) tranceivers, and speed is of utmost importance. Testing of speeds are critical to ensure that the devices will meet the speed requirements. There are some testing challen…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now