Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Responding to Java JComponent extended classes's resize event

Posted on 2016-11-02
4
Medium Priority
?
80 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 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
On Beyond Tools A conversation I recently had with the DevOps manager of a major online retailer really made me think about DevOps monitoring tools (https://www.onpage.com/devops-incident-management-tool/). The manager and I discussed how sever…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

721 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