Switch JFrame setUndecorated On and Off, help

i need to make a frame so that if the user hits f4 the frame decorations
disappear.
If i open the frame with setundecorated(true) the frame works fine.
The same with the default setUndec(false).
However it is unable to switch from one to the other.
A jframe can only be undecorated when it is undispalayble.
How do i make it undisplayable but displayed?
If i call removeNotify() (the only way i know to make the frame
undisplayable - otherwise setundec throws an error) the frame closes.
Anyone have any suggestions? this is really important! thanks alot!

Here's a slight modification. Notice I had to re-map action and keyStroke.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class UndecoratedFrameTest extends JFrame {
    private boolean unDecorated = false;
    private DecorateAction action;
    private JPanel mainPanel;
    public UndecoratedFrameTest() {
        action = new DecorateAction("Toggle");
        buildGUI();
    private void buildGUI() {
        mainPanel = (JPanel) getContentPane();
        mainPanel.setLayout(new BorderLayout());
        JPanel centerPanel = new JPanel();
        centerPanel.add(new JLabel("Center"));
        mainPanel.add(centerPanel, BorderLayout.CENTER);
        setUndecorated(unDecorated);
        JButton decButton = new JButton(action);
        mainPanel.add(decButton, BorderLayout.SOUTH);
        mainPanel.getActionMap().put("toggle", action);
        mainPanel.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0), "toggle");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        pack();
        setLocationRelativeTo(null);
    private void toggleDecoration() {
        dispose();
        setUndecorated(!unDecorated);
        mainPanel.getActionMap().put("toggle", action);
        mainPanel.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0), "toggle");
        setVisible(true);
        unDecorated = !unDecorated;
    public static void main(String[] args) {
        Runnable runnable = new Runnable() {
            public void run() {
                UndecoratedFrameTest undecoratedFrameTest = new UndecoratedFrameTest();
                undecoratedFrameTest.setVisible(true);
        SwingUtilities.invokeLater(runnable);
    private class DecorateAction extends AbstractAction {
        public DecorateAction(String name) {
            super(name);
        public void actionPerformed(ActionEvent e) {
            toggleDecoration();
}Cheers
DB

Similar Messages

  • I'm using windows 7, trying to download pictures from my canon 5d mark 2, but when I click import, the camera does not appear. I've tried changing USB ports, switching the camera on and off, trying a different USB cord, tried a different camera, but nothi

    I'm using windows 7, trying to download pictures from my canon 5d mark 2, but when I click import, the camera does not appear. I've tried changing USB ports, switching the camera on and off, trying a different USB cord, tried a different camera, but nothing. Please help! This problem only started a few days ago on lightroom 3.6, upgraded to 5.5, but still not working. Thanks.

    Can you see the Canon EOS camera and image files using Windows Explorer? If not disconnect the camera, close all applications' shutdown Windows, and TURN OFF the power to your system and ALL connected devices. Disconnect all phones, iPads, and any other USB devices and restart your system.
    Retry Windows Explorer and see if your camera is showing. If so try LR import again.

  • Recently bought 4S, it keeps searching for network, reads invalid SIM, keeps searching for network, have switched the handset on and off several times, have tried 2 new micro chips, re set the network too ! nothing seems to be working !!! Iam in Delhi

    recently bought 4S, it keeps searching for network, reads invalid SIM, keeps searching for network, have switched the handset on and off several times, have tried 2 new micro chips, re set the network too ! nothing seems to be working !!! Iam in Delhi

    Obvious question... where did you buy your 4S and is factory unlocked?

  • MacBooKPro, I can switch the power on and off, but booting takes for ever

    I am a new Mac user and have had this machine for a couple of months and in the learning stage. Yesterday I had downloaded some mp3 songs and were trying to play them with itunes, individually they would open but i couldnt import them to the music library. I noticed the machine slowly and by this morning, it has crawled to a stop. I can switch it on and off, but when i switch it on, it takes a long while for the apple logo to come on and then it takes ages for the screen to appear and when i click on something it takes many more minutes for it to open. So in fact I am frozen out, since i cannot open anything...but the machine can be powered on and off.
    do you think that there is a relationship between this freezing and the mp3 downloading and trying to play it with itunes?
    what might this be? Can any one help me with some advice. The apple support is closed for the night so i cant even call them. Thank you so very much...

    Hiya Ibncochini,
    welcome to Apple discusions, if you can power your book on, can you open "Activity monitor"? (found in applications/utlities).
    What may have happened, is that itunes is still trying to import the files. Now, also, whilst the threat of viruses is not as bad as on Windows PC's, I always scan my "new arrivals" (i.e. all files, even music files purchased from the apple store) with clamxav , which is a basic, but free;
    But for the moment, I would not suspect anything harmful, other than that an application is trying to run something. (your logs should reveal, found in console )
    Hopefully, your activity monitor reveals the offending application that e.g. takes all the processor power and you can click on it and "force quit" (from the Activity monitor menu).
    It might also be a good idea to look at +verbose mode+ which will tell you what is happening during the booting up.
    Any of the above any good?

  • My iPhone just started switching its self on and off went to a green screen then off then on any ideas only have the phone 3 months

    My phone just started switching on and off the screen went green then went off then came back on any help please only have the phone 3 months

    If the Slide to Power Off option is coming up, that suggests your power button isn't working correctly and is sticking.
    Best thing to do is bring the phone to an Apple store (make an appointment first) and have a Genius take a look at it.
    ~Lyssa

  • My ipod is turning on and off and i cant do anything with it i've tried reseting syncing and all the stuff i found here yet it still turns on and off help ASAP please

    What do i do to fix my ipod??? it just keeps turning on and off. i cant even do anything on it literally except for reseting it... holding the top button wont do nothing cuz it takes too long for the turn off slider to pop up. please help ASAP

    Try:
    - iOS: Not responding or does not turn on
    - If not successful and you can't fully turn the iPod fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - If still not successful that indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.

  • Just Switched To  Mac's and Need Help With A Few Issues!

    Hi All,
    I finally did it and switched to a Mac!! Never thought it would happen as I always felt guilty about the cost but after 5 laptops crashing on me - well, I just could not take it anymore! I managed to get a fairly good deal on a 15" Macbook Pro - 2.2/120GB version. I still don't know much about the mac way but am trying to learn so any help would be appreciated!
    1). Is there any kind of video tutorial (preferably free!) that I can use that will help me learn the Ma OS X? I have Tiger 10.4.11 on my MBP (Did you hear that - MY MBP!!!)
    2). AOL Assured me that they fully support Mac before I purchased (only 5 times!) but after I had bought it - they then told me that they do not! I got the AOL disk for Mac but it kind of ***** - features are missing etc. Does anyone in the UK run their Mac's with AOL and does it run as per normal? Any advice with AOL & Mac?
    3). AOL also told me - hey, no probs - of course you can transfer all your old emails, favourites folders, personal filing cabinet from a PC to a Mac - but then, after I bought it - the so called dedicated Mac Experts at AOL tell me that simply is not possible - What advice can anyone give me who has switched from PC to Mac with AOL and who needed to transfer all their stuff over? AOL tells you totally different things depending on who you talk to and even from what their web page state! I am really fed up with them!
    4). If I am ever successful in getting all my many years worth of data from AOL on a PC to a Mac, I am really intent of changing ISP's - what are the best ones for Mac that offer good Mac support, good deals and no charges for telephone support?
    5). I was initially happy with Tiger as again, AOL assured me they supported it but not Leopard (even their website says so) and as I stupidly thought that it must be true (we are talking AOL here!). Now I know that they don't support anything Mac, I am contemplating moving to Leopard - I am a little cautious as I heard there were/are many bugs and unhappy leopard experiences - have the majority of these been solved yet and is it advisable to change to Leopard or should I wait until an updated version comes out?
    6). My MBP was originally bought in the US but is registered to my name in the UK. it has 6 months Apple warranty left and I wish to buy Applecare. Apple says it 'recommends' buying Applecare in the country at which the item is registered (not bought, as I understand it). Does that mean, if I buy Applecare in the USA, Apple UK will still accept it and service my MBP as they would do any other or will I have to have the hassle of sending the thing to the USA if it needs attention? Applecare USA T&C's state only for the 50 States & Canada and Applecare UK state only for the UK & EU. Both however state international servicing?! I am a bit confused on this one. I travel a lot and need to know, that any Applecare I buy will not then be limited to just the places they state in the T&C's. As It reads to me, Applecare purchased in the USA/Canada will not cover the UK/Europe/ROTW and vice versa. Is this true or am I missing something or just plain thick?
    5). I really wish to upgrade the 120GB HDD. My understanding is that it must be done by either Apple (who charge really silly money) or if correct, at an "Authorized Apple Service Provider" who of course will be much cheaper. If true, does this mean at ANY authorized apple service provider on the planet or just ones in which the item is registered? If I do the upgrade with a service provider, will Apple then also service the new HDD if something goes wrong as per normal anywhere in the world or will they then say, sorry, will not service the new HDD and you have to go back to the place where you had it installed, even though it was one of their authorized service centers? (that would really suck)!
    6). The spelling and dictionary (and a few other things) are set to US English - how can I set to UK English? I have tried but to no avail so far.
    7) What and how should I set the Firewall settings so I will not get attacks by any form of malware? (I do not know much about this area and what the implications mean)!
    Well, that's it so far - please bear my ignorance, I am so new to Mac's and hope this to be one of the smarter decisions I have made in life! Already I have strange sensation that I never had with all those years of Microsoft & PC's - I kinda feel reassured, safe, that if I have problems, they will get sorted, My life will now be easier and not having to worry so much about crashes, viruses, trojans etc, gives me a sense of liberation and contentment almost - very strange feeling but a **** good one! (if only the women in my life were like that)!
    Thank You All From A PC to Mac Switcher (and NO! I do not feel guilty or scared anymore)!
    SuaveBhav!

    I can help you with your questions about AppleCare, and can also reassure you that both the macbook pro and Leopard will be worth your investment and the time you are putting into figuring out how to get your data across. I switched from windows when I bought my macbook a year and a half ago and would not use any other system now. The other day I completed the transition by erasing parallels and Windows from my system entirely.
    As for AppleCare, you can get warranty care anywhere in the world, no matter where you buy your AppleCare. Mine was bought and is registered in the US, I live in Slovakia, and have had it serviced several times in Austria and Slovakia under the warranty without any problems at all. There are differences, however, in exactly what the warranty covers from place to place, in accordance with the law in each place that AppleCare is issued. Even though I live in the EU, my agreement with Apple is an American one, and the American guarantees hold. If EU law would demand that Apple fix more things, for instance, than American law does, I could not get those things repaired under my agreement, and vice versa.
    Basically, though, I understand my agreement with AppleCare to be that they will fix all problems/damage that are not my fault free of charge for two years after my initial one-year warranty runs out, and that is good enough for me.

  • My 3GS keeps turning on and off  **Help me***

    my 3gs keeps saying it has a low battery but when i got to hook it up it turns on and freezes at the boot logo. if someone could help me i'd be grateful.

    You said that you restored it.  "forgot to mentioned that ive tried all of that"
    When you restore, you can restore from backup or as new.
    Did you or did you not restore it?
    iPhone User Guide (For iOS 5.0 Software)

  • My apps will not download to ipad2 this is something that has just recently happened.Have switched the pad on and off holding buttons down but it makes no difference.Has anyone got the solution to this problem Thank you.

    My apps will not download to iPad 2 This is something that has just recently happened. Have tried re-booting but that makes no difference .
    Has anyone got the answer to this problem please or do I need to take it into an Apple store Thanking you.

    If all of that stuff checks out - and iTunes is telling you that the apps have been downloaded to the iPad - try this.
    Connect your iPad to your computer and launch iTunes. Right click on your iPad name on the left side of iTunes under devices and select Transfer Purchases from the pop up menu. Then sync with iTunes again. Don't eject the iPad yet. If you still don't see the apps on the iPad - click on the Apps Tab in the iTunes window on the right and see if they show up on any of the iPad screens. If they do - make sure that all of the apps are selected (checked) to sync - (checkmarks in the boxes next to the app names) - check to make sure that the Sync Apps heading is checked and as well and then sync again. You may have to click on Apply in the lower right corner of iTunes if the apps were not selected to sync.

  • Illustrator CS4 switches on, then quickly turns off - help

    For the past few days I have have been experiencing problems with my product. As soon as I turn it on, it doesn't even make it to the opening dialog box (the one where it says New or Open etc). It briefly shows the box (blank) and the interface with all the tools etc behind it, but then it shuts down. Can anyone tell why this is happening?

    Hussnain,
    You may try to follow the explanations/suggestions in Move the folder or Other options (two of the hints on the web page linked to here).

  • Software switching a usb port on and off

    Hi,
    I write here because I hope somebody will be able to help.
    I have a simple little lamp that draws its power from a usb port.
    I'd like to know there is a way to turn the light on and off via software.
    Meaning I would have a script that toggle the power on the usb port on which the lamp is plugged, switching the light on and off.
    This way I could turn it on and off remotely.
    Does anybody here has an idea on how this can be done?
    Thanks.

    Hi,
    as far as I know USB ports (I have some experience with USB 1.1) there is no way. But I might be wrong!
    Volker

  • Using Equalizer presets without having to switch on and off

    Hi,
    I have assigned equalizer presets (eg. Equalizer preset = Dance) to a minority of songs in iTunes on my Mac. Most songs have no preset, so the setting is blank (Equalizer preset = None).
    The problem is that I can only get these settings to work by manually switching the EQ 'on' and 'off' by checking and unchecking the 'on' button in the Equalizer window.
    Can I combine presets and no presets in one playlist without having to manually switch the EQ on and off? If so, please tell me how. Thanks!
    iMac G5/17"   Mac OS X (10.3.9)  

    iTunes will change the EQ to a setting but not back to nothing.
    If your listening to a dance track with the EQ preset on Dance then thats fine. But continue on too listen to a rock track where the EQ preset is none and iTunes will continue to use the Dance EQ. The only way i can think of to get around this problem is to set EQ presets for all songs. If you have a large library its easiest to do this by browsing by genre and changing whole genres at once.
    There is no software i know of that helps prevent your EQ problem though sorry

  • Agreegate switch on and off

    q1.... in what circumstances should we switch the agreegate on and off. does this have to do anything with performance increase for data loading or query run performance.please explain the concept.
    q2.. if we have rolled up data in the aggregate and then deleted some data from the info cube then what si meant by deactivating the aggregate and build it again.
    would be greatfull if someone could answer this correctly.thanks

    Hi ,
    Aggregate is needed only if your query performance are very poor  due to huge volume of data.
    If the query is designed badly it may be corrected.( more negative logics in the query.)
    If the above scenario has happened and you need aggregates . You can create aggregate for the same.
    You can compress the cubes for performance instead of deleting if your deletion is due to performance.
    Otherwise if you need to remove the data then aggregates to be deactivated and filled again.
    Hope it helps your requirement.
    Amu

  • PID advanced not working after switching on and off

    Hello there,
    I am trying to simulate the control of an inverted pendulum with the simulation module and the PID toolkit and actually the model runs fine with one problem remaining. When I switch the PID to manual mode and then back to automatic the controller is not able to balance the pendulum to 0 degree like he has done when I started the program.
    I have added the project maybe someone has an idea how to get this working because I am not that familiar with these toolkits.
    Thanks in advance and best regards
    Philipp
    PS: I am using two different models in the project but both have the same problem.
    Attachments:
    Inverted Pendulum.zip ‏767 KB

    Philipp,
    The problem that you have is actually a common problem for those who try to use PID for this problem.
    When you try to use only one PID to control angle, the controller is able to keep it up right in the beginning. However, when you switch the controller on and off (going from automatic to manual), this perturbance will make the cart to move to one direction (adding momentum to it) and the PID will try to bring it back to the center, but it will be far away from the center. If you give time, it eventually will bring back to 0.
    In this link below, you have more information about this problem and, most important, tells you that for practical controllers, you can't use static PID for this problem. Maybe you could use gain scheduling PID or cascade PID to also control position also. In general, the LQR controller works pretty well for this problem.
    http://www.engin.umich.edu/group/ctm/examples/pend/invPID.html
    Anyway, let me know if that answer your question.
    Barp - Control & Simulation Group - National Instruments
    Barp - Control and Simulation Group - LabVIEW R&D - National Instruments

  • Since upgrading to Lion OS, the wifi connectivity keeps blocking up intermittently and we need to manually keep switching on and off the wifi utility to get the connection back. even locking the preferred wifi network in system preferences does not help.

    Since upgrading to Lion OS 10.7.1, the wifi connectivity keeps blocking up intermittently and we need to manually keep switching on and off the wifi utility to get the connection back. even locking the preferred wifi network in system preferences does not help. This never used to happen with Snow Leopard

    This is a big thank you to Rys Sinnefeldt who posted this fix.
    Rys has made this fix very easy to do and takes literally 2 mins. It involves replacing the Atheros Lion driver 4.0 and replacing it with the snow leopard driver. Don't worry, Rys has made this so simple to do even I could do it and so far I have had no more wifi drops.
    follow this link
    http://rys.pixeltards.com/2011/09/04/osx-lion-wifi.html
    Thanks again to Rys.

Maybe you are looking for

  • I'm trying to give BT more money, but the "system"...

    I'm losing my mind here. I have recently became aware of BT's decision to remove usage restrictions during peak hours for certain types of traffic (e.g. Peer to peer). As an existing Infinity customer ("BT Infinity Option 2") I would like to get rid

  • Bonjour for Windows no longer works after SP3 is installed

    Bonjour for Windows was working fine until SP3 came out. Now I can see the printer and Bonjour goes through the motions to set it up, but I can't print to the printer. The whole construct of "Printer.local" or "AirPortExpress.local" doesn't seem to w

  • How to create a PDF with markup enabled for Reader users?

    I have a bunch of Word 2007 documents containing project specs. I would like to be able to turn them into PDF documents that other people can markup using Reader. Is this possible? I tried using the built-in PDF output module. It creates a PDF docume

  • Blocking the Inactive Vendor Accounts

    Hi, I am new into FI and I have a very basic question. I want to find out if there is a program that can be scheduled to run every day to find and block the inactive vendor accounts for a specific period (say inactive for last 30 or 60 days). As of n

  • 2600 Classic

    Have an icon appeared on my screen, capital E in a square box, and can't phone out any more. Please tell me what and how to fix it?