Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Responding to Java JComponent extended classes's resize event

Posted on 2016-11-02
4
Medium Priority
?
87 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
ID: 41870429
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 2000 total points
ID: 41870480
.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
ID: 41870682
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
ID: 41870724
:)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Or at least that’s the word according to a new blog from Tech Target on AWS’s new Managed Services (MS) offering. According to the blog, AWS is launching their AWS MS program to expedite the adoption of cloud by Fortune 1000 and Global 2000 companie…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

877 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