Solved

Responding to Java JComponent extended classes's resize event

Posted on 2016-11-02
4
73 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

623 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