Making a customable resizable JPanel, but it only works in certain L&F

Hi,
I have created the following resizable JPanel (so that I can set a minimum size it can be dragged to).
However, I need it to work under the system L&F, which is XP, but it wont work.
The code is below. if you run it the first time, and try to resize the dialog to a small value, you will see it shrinks in size, to a certain point.
then if you comment out the 2 lines i specified, and run it again, it wont. Anyone have any ideas? is this a known bug?
import javax.swing.*;
import java.awt.event.ComponentListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.*;
public class ResizeTest extends JDialog {
     public ResizeTest(JFrame owner) {
          super(owner);
          this.addComponentListener(resizeListener);
          /* comment out the following 2 lines */
          setUndecorated(true);                  
        getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
     private ComponentListener resizeListener = new ComponentListener() {
          public void componentHidden( ComponentEvent i_e ) { }
          public void componentMoved( ComponentEvent i_e ) { }
          public void componentResized( ComponentEvent i_e ) {
               int width = ResizeTest.this.getWidth();
               int height = ResizeTest.this.getHeight();   
              if( width < 50 ) { width = 50; }
               if( height < 50 ) { height = 50; }
               ResizeTest.this.setSize( width, height );
         public void componentShown( ComponentEvent i_e ) { }
     private static void test() {
          final JFrame frame = new JFrame();
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          JButton launchButton = new JButton("showDialog");
          frame.setContentPane(launchButton);
          final ResizeTest testDialog = new ResizeTest(frame);
          testDialog.setMinimumSize(new Dimension(300, 300));
          testDialog.setSize(500, 500);
          testDialog.setPreferredSize(new Dimension(500, 500));
          launchButton.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent e) {
                    testDialog.pack();
                    testDialog.setVisible(true);
          SwingUtilities.invokeLater(new Runnable() {
               public void run() {
                    frame.pack();
                    frame.setVisible(true);
     public static void main(String[] args) {
          test();
}

okay... I see what the problem is.
1) With those lines uncommented: The L&F is handling the window decorations. Because of this, it's basically a JWindow with custom painting and mouse handling. When you resize, it's constantly calling setSize, which constantly firing events, so your minimum sizing works as you expect.
2) With those lines commented: The OS is handling the window decorations. Because of this, there are 2 caveats:
a) There is a minimum width of the window of what looks like about 120-130 pixels. So you can't go any smaller then that for width. And for height, no smaller then the titlebar and lower border.
b) It only fires the component events when the mouse is released, cuz that's how the undelying native windows deal with it... or at least with Java.
For #1 above, there's still a minimum size for the L&F decorated windows. But this is related to what content is showing in the titlebar. Which in the case of the decorations showing, is smaller then what your were defining as a minimum.
So, basically, it's not a bug. It's just the way it is. It's always been like this.

Similar Messages

  • Safari and firefox stop working after a few minutes of browsing, regardless of what site I'm on. I have to restart my computer to get internet access again but it only works for a few more minutes, then I have to restart again. Please help!

    Safari and firefox stop working after a few minutes of browsing, regardless of what site I'm on. I have to restart my computer to get internet access again but it only works for a few more minutes, then I have to restart again. I don't get a spinning ball, it just stops working at whatever page it's on. I can close the program just fine but when I re-open it, either safari or firefox, it freezes trying to load the hompage. This started a few days ago after trying to stream a movie on my computer. I'm on a Mac Air OS X Version 10.6.8 and have downloaded all updates. When I go into finder, it says I have over 80 gigs available. Is there some other memory cache that I need to check? Thanks so much for your help.

    ejwoodall wrote:
    It's not a router problem as I explained in my post. If it was a router problem then I wouldn't have the problem everywhere I go. It is an issue with the software.
    Then I guess the millions of people running 10.5.7 with no issues are just hallucinating that their machines are working fine?
    I'm not trying to belittle your issues; you're certainly having them and I know first hand how annoying an intermittent AirPort issue can be. (In fact, mine was due to an AirPort driver bug that no one else seemed to suffer from.)
    The single best diagnostic you could do is take your system running 10.5.7 to an Apple Store, and try using their in-store network.
    If your machine performs flawlessly, it may be a router issue.
    If your machine has connectivity issues there, it may be a hardware problem with your machine.
    There have been numerous people in multiple threads over the years who swore that an update was buggy because things used to work, but returned later to sheepishly admit that they took their machine in, a problem was found and fixed, and now their Mac works flawlessly with the newer software.
    But simply reinstalling 10.5.5 in no way means the explanation of how firmware bugs may be at play here is incorrect.
    In the context of that explanation, all you've done is possibly reinstall software that asks to add "2 + 3."

  • How can I delete e-mails from one IPad without removing them from other IPads on same icloud? I'ved tried switching off mail sync on all devices but this only works when deleting on IPhone

    We have several portable devices and a mini mac on our system and have found that if we delete an email on one device it is removed from others.
    We don't want this, but at the same time we need to keep our devices clear of clutter.
    It was suggested that switch off the sync mail switch in settings - Icloud, but this only works on IPads & Ipods
    anybody got any better ideas ??

    We have several portable devices and a mini mac on our system and have found that if we delete an email on one device it is removed from others.
    We don't want this, but at the same time we need to keep our devices clear of clutter.
    It was suggested that switch off the sync mail switch in settings - Icloud, but this only works on IPads & Ipods
    anybody got any better ideas ??

  • HT4059 I got definition of a word by tapping twice on a word. But it only works for a few time. Ater i tap a word for speak, the feature for definition does appear anymore?

    I got definition of a word by tapping twice on a word. But it only works for a few times. Ater i tap a word for speak, the feature for definition does not appear anymore?

    I got definition of a word by tapping twice on a word. But it only works for a few times. Ater i tap a word for speak, the feature for definition does not appear anymore?

  • I have a touchscreen laptop running Windows 8.1. Is it possible to use the touchscreen with Firefox? I've installed Firefox but it only works with the mouse etc

    have a touchscreen laptop running Windows 8.1. Is it possible to use the touchscreen with Firefox? I've installed Firefox but it only works with the mouse etc

    Hello Sirving575, sorry but the metro version of firefox has been cancelled, see : https://blog.mozilla.org/futurereleases/2014/03/14/metro/
    thank you

  • My iMessage only works with one contact in my phone. I text several people that have the iphone 4s, theirs works with other people. But mine only works with one person. Why?

    My iMessage only works with one contact in my phone. I text several people that have the iphone 4s, theirs works with other people. But mine only works with one person. Why?

    about message http://support.apple.com/kb/HT3529
    troubleshooting message http://support.apple.com/kb/ts2755

  • I downloaded an app on my Mac but it only works on an IPad. Is there anyway to get a refund so I can get the right one?

    I downloaded an app on my Mac but it only works on an IPad. Is there anyway to get a refund so I can get the right one?

    When downloading apps from a Mac, any apps downloaded in iTunes are for iOS devices.
    For Mac Apps use the App Store app.
    You can connect iTunes Store Support but I doubt they will give you a refund.
    http://www.apple.com/support/itunes/contact/

  • I would like to run a stock analysis program called Toolkit 6 on my Macbook Pro, but it only works on the Windows platform.  Is there software that allows me to run Windows applications on the Mac?

    I would like to run a stock analysis program called Toolkit 6 on my Macbook Pro, but it only works on the Windows platform.  Is there software that allows me to run Windows applications on the Mac?

    Yes it's MS Windows! You will need a license of MS Windows (preferable Windows 7) and from there you can decide on the strategy for running Windows on your iMac. You can use Boot Camp (you already have this) or you use virtualization software such as Parallels or Fusion. For your situation I'd recommend virtualization software. However for only one program I'd do some due diligence to see if there is a OS X version. You can start with the App store or simply use Google to search.
    Kappy has provided a good article on running Windows on a Mac and the various options. Here is the link:
    Kappy's explanation
    Roger

  • Why does the sound only work for certain programs?

    The sound is only working for certain programs on my iPad. Does anyone know why? Any help is appreciated.

    It sounds like you have System Sounds muted. Either the switch on the side, or double tap the home button and swipe to the right, ICON will be on the far left. If the ICON is screen lock related, then it is the switch on the side.

  • My WiFi is down and says ´´No Hardware Installed´´ and I´m not sure how to fix it. I´ve tried shutting it down and pressing P, R, Command, Option, but it only works sometimes, and as a temporary fix. What do I do?

    My WiFi is down and the icon states ´´No Hardware Installed´´. Sometimes the WiFi will come back, but it will shut me out after an hour or two. I´ve tried shutting it down and pressing P, R, Option, Command while turning it on, but it only sometimes works and is a temporary fix. I´m studying abroad and there aren´t apple stores near me. I went in to one before I left, and thought the tech employee had fixed it, but I started to have the same problem here. How can I fix this?

    This worked and solved the problem.
    Reset PRAM.  http://support.apple.com/kb/PH4405
    Reset SMC.     http://support.apple.com/kb/HT3964
    Choose the method for:
    "Resetting SMC on portables with a battery you should not remove on your own".
    If this does not help, contact Apple.
    Best.

  • Help! My iMessage doesn't work on my new iPhone 5s, I've changed my sim twice, but iMessage only works with my Apple ID.

    Recently got a new iPhone 5s and the iMessage doesn't work. I tried the sim in another phone and it didn't work either so I put a completely new sim in my iPhone and iMessage doesn't work. It will only work when I use my Apple ID for received messages. I don't know what to do. I have reset everything and it still doesn't work. My software is up to date. Please help!

    ACTIVATING FACETIME AND IMESSAGES
    Activating Facetime and Imessages on your phone requires the ability to send SMS messages and depending upon where you are that might be an international SMS.  Check with your carrier to see if your plan supports sending of international SMS messages.  If you are having trouble activating Facetime or Imessages turn them both off on your device and reset the device (Hold down the Sleep/Wake button and the home button together until the apple logo appears (ignore the ON/OFF slider) then let both buttons go and wait for device to restart (no data will be lost)).  Wait for the device to restart and wait a minute and turn Facetime and imessage back on and wait for activation.  If that does not fix things read the following articles:
    http://support.apple.com/kb/TS4268
    http://support.apple.com/kb/ts3367

  • Blackberry Messenger only works at certain times of day.

    a few days ago my phone crashed, leaving my blackberry messanger not working, a few hours later it started up and everything was fine, however the next day my bbm only worked early in the morning and then started up again around 4, and its did it again this morning, i have restarted it many times, i have deleted it then reinstalled it, its just very annoying it doesnt work, and im not really sure what to do with  it
    any help would be much appreciated

    Ella, that's got to be some intermittent connect with your mobile provider.
    The next time your BBMessenger is NOT working, check On your Manage Connections screen, click on the Services Status. What is the status of the BlackBerry Internet Service at that time?
    ALSO:  You have your mobile phone number listed as your "My Mobile Provider" or carrier. Putting your phone number out on the internet on these public forums for the world to see, is not wise. To change that, at the top of this page click on My Settings > Personal Profile > Personal Information, and in the entry block for "Carrier" type the name of your mobile provider.
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Mag safe adapter only works with certain macbook pros

    My Adapter is only working with other macbooks and not its own, It sometimes flics on for a second and then No go..
    I can charge with others...
    Solutions?? HELP PLEASE!!!!
    thanks!
    Dee

    Try SMC Reset
    http://support.apple.com/kb/HT3964
    PRAM reset
    http://support.apple.com/kb/HT1379

  • I just got a MacBook Pro 10.8.2.  but facebook only works for about 3 minutes and then stops loading.

    My computer is completely new with nothing on it at all.  It was bought in the USA but i am living and using the computer in Israel, i dont know if that matters.  every other website that i have gone on works just fine, facebook is the only one that stops loading after a few minutes.  Please help.  I dont know computers well at all and dont know the "computer language"  so please if someone could help me and explain to me very simply what i need to do to fix the problem.
    THank you so much!

    Try going to Starbucks and connect thru their WiFi and see if you experience same issue. If not, it may be your wireless router not compatible to wireless-N built in the macbook pro. It could be your router cycling on and off its connection without even noticing it.  Do you have any other wifi at home that doesn't experience this issue?
    You need to do process of elimination. Keep us posted. Thanks!

  • Is there a cable I can use for iPad one to watch Netflix and play apps on my HDTV? I bought the hdmi connector but it only works on iPad 2.

    I bought the hdmi and didn't realize you can only use it for iPad 2. I want to be able to watch Netflix through my iPad 1. And also play my apps on my big screen is there any cable out that will let me do this on my iPad 1.

    Unfortunately, that's a limit with the original iPad.

Maybe you are looking for

  • Errors when installing Premiere Pro

    When I installed Premiere Pro all these error messages come up and it says installation failed. Adobe encoder will not open and Adobe Encore will not transcode. I am using a windows vista computer. Can Some one please help. thanks joey Adobe Device C

  • Exporting "Original" from iPhoto '09 v8.1.2(424) to External Hard Drive

    RMS3RD  Re: error writing to disk     Feb 6, 2014 8:40 AM    (in response to Terence Devlin)  Terence, not sure of the etiquette here but this is similar to what I am experiencing: CPE: MacBook Pro 5,5 Core2Duo running OSX 10.5.8 with EHD  Seagate Ba

  • Intensity Pro not recognized within CS5.0.3

    Had to format the drive. Adobe CS 5 Production Premium Windows 7 64bit Quad-core 12gb ram 2 raid 0 + system drive All adobe software is up to date. All physical connections checked and re-checked. Using composite from a VCR. Installed software for In

  • Superdrive not working? Maybe try this

    It appears that if you run the program PatchBurn, that may fix or help your Superdrive.

  • Transition and image duration times issue

    I'm trying to put together an image slide show w/music, etc. I have iM08 and can't set my transition time to 2 seconds and the image time to 4 seconds to save my life. The adjustments seem to have a mind of their own. Is this a solvable problem in '0