JFrame: How to detect a change in size?

Hello everyone,
I have a question related to the size of a JFrame or JPanel. I add a few JPanels to a JFrame and I wanted to detect when the size of the JFrame window or the JPanel itself had changed (if the user pressed the "Maximize icon" or simply dragged the window size from the one of the corner of the window). I am not sure if I need a listener added to the Frame, and what kind of listener that would be (if any exists, I am not sure).
I have another question regarding the class Dimension. I add JPanel's to my JFrame and I use the class Dimension to get the size of the panel with the getSize() method. I wanted to know when is the sooner that I could call this method to get the right size. For example, I use it in a few methods like the paintComponent, the mouseReleased and mouseDragged method, but I wished to get the correct size as soon as possible and only compute it once (or update it if the JPanel sized change). I am wondering why the size is 0 while I call this method inside the constructor and if there is any method where I can call it before actually doing anything to the JFrame please.
I hope my questions are somewhat clear.
Thanks for all your help, it is very much appreciated.

I am having one more issue.
I have implemented the ComponentListener for each of my JPanel and used the componentResized and componentShown to calculate the size of my panel.
This works great when I resize the JFrame using one of the corners, but not when the "maximize button" (in the title bar next to the corss) is pressed.
Is there any way please to fix this? Thank you.

Similar Messages

  • How to detect dataprovider change in spark List ?

    The problem is : when the dataprovider changes, the List unselects its items. I want the selected item of the List to stay selected, even if the dataprovider has a new item, for example.
    So I try to detect a change in the dataprovider, to be able to re-select the item that was selected before the change.
    I tried to listen several events but it didn't work :
    - change is dispatched by user, not by code.
    - updatecompleted is dispatched when the dataprovider changes but it is triggered also when the list is resized, and I don't want that.
    - collectionChange is not dispatched
    I don't understand why valueCommit is not dispatched when the dataprovider changes.
    Can you help me ???

    There is a dataProviderChange event fired whenever dataProvider is set,
    but it may not be listed in the metadata so you may not be able to access
    from MXML.
    Flex harUI,
    Why isn't this event exposed publicly through the metadata of the class?
    The easy fix I can come up with is to extend the List, by simply exposing the event, like:
              [Event(name="dataProviderChange", type="flash.events.Event")]
              public class ExtendedList extends List
    But I don't know if it's good practice...

  • How to detect value change of item?

    Hi all,
    We want to list all goods that customer chooses, so TileList is used to display all goods information and a custom component MyItem is used as ItemRenderer. Meanwhile a Label is used to display the sum of all the goods. The hierarchy is simply like this:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"  layout="absolute" >
    <mx:TileList id="tl" dataProvider="{acGoods}" ItemRenderer="MyItem"/>
    <mx:Label id="labelSum"/>
    </mx:Application>
    Here, acGoods is an ArrayCollection which I believe is bindable.
    User may change price inside MyItem directly, so the text of the Label need to update as well. I find that acGoods contains latest price. Now the problem is Label text stays the same. I have tried to call calculating function in set acGoods() but it doesn't work.
    Please don't sugguest dispatch event because this is only a simplified scenario. If anybody tell me how to implement this by binding mechaism, that'll be very helpful.
    Best wishes,

    protected function get totalLabelText():string {
        // for each var i:* in acGoods and so on
        return 'Calculated label here';
    <mx:Label id="labelSum" text="{totalLabelText}"/>
    Inside MyItem:
    once you changed something invoke:
    Application.application.executeBindings(true);
    Hope this will work for you

  • JColorChooser: how to detect color change?

    Hi all,
    I Know how to create a JColorChooser dialog (JColorChooser.createDialog()) to which I can add actionlistener to detect a new color has been selected.
    I want know if there is a way to detect events if I integrate the JColorChooser in a Panel, for example in this way:
    JPanel panel = new Janel();
    JColorChooser colorChooser = new JColorChooser();
    panel.add(colorChooser )Thx a lot!

    Ok, a I found a way:
    JColorChooser fontColorChooser = new JColorChooser();
         fontColorChooser.getSelectionModel().addChangeListener(new ChangeListener(){
                   public void stateChanged(ChangeEvent e){
                       System.out.println(fontColorChooser.getColor().toString());
               );

  • BART. How to ignore all changes but size (decrease)

    Hi,
    I was checking BART and looks nice, I read some of the rules and policies, bu tnothing that came close to this:
    How do I have BART just report if a file has decreased in size?. Say I have a .txt 5kb, I want BART to just tell me if the size is now 4KB.
    Thanks

    Hello Rodica,
    You can also try checking report S_AR_87013558
    Once you execute this report, you will see Budget amount shown for specific Project / WBS.
    Click on this Budget amount and go to menu Goto-Line items.
    You will get to see Display Budget Line items for projects showing text, history of Budget amount datewise.
    Check this and see if it helps you.
    Regards
    Tushar

  • How to detect any changes of a StepType-field by the sequence ?

    Hi all,
    suppose I've got this: a simple StepType 'TEST' with one added custom field 'Source' of the type String.
    When using this StepType in a Sequence and editing the 'Source' value (from the Variables panel),
    the Sequence name is immediately marked with an '*'. Which is wat we want :-)
    But, if I change the 'Source' value from code (C#), I see that my 'Source' value is changed (in the Variables panel), but not that the Sequence has detected this.
    Maybe it's StepType-flag that I have to set or from code, executing a trigger or so ?
    Thanks in advance ?
    Franky
    Solved!
    Go to Solution.

    I'm talking to myself, but FYI:
    because I'm updating my sequence from code (C#), I've the current Step as an object and
    therefore I knows if any fields are changed.
    Using this snippet will mark my sequencefile as 'changed' : 
    step.Sequence.SequenceFile.AsPropertyObjectFile().IncChangeCount();

  • How much can I change the size of this image?

    I want to print an image using an online sevice and the attached image shows the dimensions. I'm VERY new to Photoshop and want to know if I can just enter a larger size into the fields to print it at say, 8.5 x 11 and, if so, do I need to do anything else to prepare the image for this?
    Thanks!

    Ditto what Noel mentions, but your quality of enlargement will depend as well on the native format of the image. For example, you would get a better enlargement result if your original file as a TIFF and not so good if you are working on a JPEG due to the lossy compression.
    While getting to Letter size might be a challenge you might get a good print by resampling at between 150ppi and 200ppi but you would need to make some test prints to see what would be an acceptable image. At 150ppi you would get an image around 10"x6" and at 200ppi the image would be around 7.7" x4.6"
    Hope this helps
    Mike

  • JFrame content displayed only after changing frame size

    Hello everybody,
    could someone explain to me why the content in this frame:
    public class PHPTableReport extends JFrame {
         public PHPTableReport() {
              getContentPane().setLayout(null);
              final JLabel newAppletLabel = new JLabel();
              newFrameLabel.setBorder(new BevelBorder(BevelBorder.LOWERED));
              newFrameLabel.setBackground(Color.BLUE);
              newFrameLabel.setText("New Frame");
              newFrameLabel.setBounds(10, 10, 50, 58);
              getContentPane().add(newAppletLabel);
         }when invoked like this (in a JApplet):
    PHPTableReport pHPTFrame =  new PHPTableReport();
    pHPTFrame.setVisible (true);
    pHPTFrame.setBounds(300, 300, 800, 600);only displays after dragging the window/frame bigger or smaller?
    Thanks in advance again
    Jan

    Change this :
    pHPTFrame.setVisible (true);
    pHPTFrame.setBounds(300, 300, 800, 600);To:
    pHPTFrame.setBounds(300, 300, 800, 600);
    pHPTFrame.setVisible (true);

  • Changing font size of the button

    Hi,
    how can it be changed font size of the button (other than standard and small)?
    Thanks.

    Hello,
    You can create a separate Theme to change or modify the properties of UI elements and can use it in your application. You should have System Admin role assigned in the portal.
    Goto System Admin-> POrtal Display -> Theme Editor select any of the standard theme and change it to as per your requirement and save your theme with different name.
    In webdynpro you can not change the font size of button. Hope this helps
    Abhinav

  • How do you change the size of a JFrame?

    I have some code using a jframe for an application creating buttons, but i want to also have some graphics in there, and I was wondering if there was a way to change the size of the jframe.

    Use JFrame.setSize().
    Check the JavaDocs for the method signatures.
    Dave

  • How to change window size?

    My top level ancestor is a JFrame and I want to change my application window size. I found that there is a ComponentEvent.COMPONENT_RESIZED event but how I can fire this event?
    thanks

    JFrame f = (JFrame)this.getTopLevelAncestor();
    f.setSize(newX, newY);Of course, if the resize is according to a child component resizing..
    f.pack();..should do the trick.

  • How to change font size in iCal

    How do I change the font size in iCal?  When I go to print the monthly calendar, it is so small I can't read it.  But for the life of me I can't find where to change the size!

    earlnkids,
    The text size selection should be available in the first page of the iCal print options:

  • How do I change text size in auto-page tabs

    Now I'm trying to make the page tabs fit across my page. I've got several pages and will probably have more. I don't want all of them on the bar as they'll be linked in my text. I would also like to make the text smaller and maybe reformat to another font or style.
    I don't find anything on this but maybe I'm not searching the right terminology.

    You're referring to the navbar.  You can remove any page from the navbar by going to the Inspector/Page/Page pane while viewing the page and unchecking the box to include that page in the navbar:
    To change the font size of the navbar text see this post by Cyclosaurus: How do you change the size and font of...: Apple Support Communities.
    Wyodor also posted a way to change the font size: Darkroom Navigation Font Size: Apple Support Communities.
    If you only have a couple of pages you can create your own text based navbar and complete control over the font, size, rollover color, etc. This demo page has an example: Text Based Navbar. Be sure to use Web Safe Fonts. 
    OT

  • How do I change the size of a windows partition on my MacBook?

    How do I change the size of a windows partition on my MacBook?

    CampTune $19 from Paragon-Software is your best bet.
    http://www.paragon-software.com/mac/

  • How to change font size on screen

    how to change font size on screen

    I'm not certain what font sizes you wish to change, when on a page you can use command and the += button to zoom in and make the fonts larger. On the finder desktop you can make what ever is on the desktop larger or smaller from the finder menu click view, custom view options, and adjust the icon size with the slider on the top, and the text using the text size box to select the size that your comfortable with.
    Forgot to add these.
    http://support.apple.com/kb/PH10876
    http://support.apple.com/kb/PH10877
    Hope this helps.

Maybe you are looking for

  • Wbs modeler won't load visio 2013 pro/office 365

    Hi, I've installed WBS Modeler add-in onto my Win 7/Visio 2013 Pro/Office 365 laptop, but the Modeler won't load.  When I start Visio and check the addins, the WBS Modeler shows up as an Inactive Application Add-In.  When I check the COM add-ins, the

  • Hack the OS to completely remove non-txt information from the Clipboard ?

    Hi, I wonder if I can hack the OS somehow to completely disable text formats in the Clipboard. I don't need this feature at all; on the contrary. It's annoying to remove this superfluous information from text clips that I copy from Web pages, RTF / W

  • Create a New Order for Images - Then Rename

    Hello, I have PSE 5.0.2 I use Windows XP. I have a series of jpg's that I would like to put in a different order by drag-n-drop into a different arrangement - then batch rename them with a sequential naming convention. Can I re-arrange images in PSE

  • Asynchronous web services

    If I set up an asynchronous web service using JMS transport, would I be able to receive the callbacks in the business service that invokes the ws? Is this the only approach to callbacks that I can use?

  • How to improve R12 apps performecne

    Guys How can we improve r12 application performce , Which areas we can improve, Thanks