Disable close opearion(X) on the title bar of a frame.

Hai,
I need to disable the close operation on the title bar of the frame.
Can anyone give me the solution.
Thanks
SmartStar.

hai,
the code given is allowing me not to colse the frame, but it is not displaying the frame with the size i had given in the setSize().
I need a code to achive a task such that, even after i click on the close on the title bar, it should not perform any function and display the frame as it is. with out any resizing.

Similar Messages

  • Disabling close 'X' icon in the title bar of JDialog

    I found that JDialogs by default come up with the close 'X' icon. The only manipulation that can be done is by setting the DefaultCloseOperation.
    Is there some way I can avoid showing that icon on the title bar?
    My JDialog already has a 'Close' button and I have written an action listener for it. I dont want to listen to WindowEvents as well.

    JDialog d = new JDialog((Frame)c, true);
    d.setSize(400,300);
    d.setUndecorated(true);
    d.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);That bit of code seems to get rid of the title bar entirely and cause a MetalLookAndFeel dragging bar without an X to appear.
    Let me know if this is a satisfying solution
    My full test code followsimport java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class DyalogTest extends JFrame
       public DyalogTest()
          super("Dialog Test");
          setSize(500, 400);
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          Container c = getContentPane();
          c.setLayout(new FlowLayout());
          JButton b = new JButton("Initiate Dialog");
          b.addActionListener(new ActionListener()
             public void actionPerformed(ActionEvent e)
                Component c = SwingUtilities.getRoot((Component)e.getSource());
                JDialog d = new JDialog((Frame)c, true);
                d.setUndecorated(true);
                d.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
                JButton b = new JButton("Dispose");
                b.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent e)
                      Component c = SwingUtilities.getRoot((Component)e.getSource());
                      JDialog d = (JDialog)c;
                      d.setVisible(false);
                      d.dispose();
                d.getContentPane().setLayout(new FlowLayout());
                JPanel p = new JPanel();
                p.setPreferredSize(new Dimension(400,300));
                p.setBorder(BorderFactory.createTitledBorder("Vanilla Dialog"));
                p.add(b);
                d.setContentPane(p);
                d.pack();
                d.setVisible(true);
          c.add(b);
       public static void main(String[] args)
          new DyalogTest().setVisible(true);
    }

  • Displaying our own icon at the title bar of a frame.

    Hai,
    How do i display an Icon of my choice at the title bar of a frame or a dialog box.
    Thank you.

    Thank you shahidjava for the kind reply,
    I tried your code as follows but I'am getting an exception saying "wrong number of arguments in the method.".
    Can you please help this out.
    import java.awt.*;
    import java.awt.event.*;
    public class testIcon extends Frame
         public testIcon()
         setVisible(true);
         setTitle("mohammad afzal....!");
         setBounds(100,100,200,200);
         getIconImage("afzal.gif");
         public static void main(String args[])
         testIcon ti=new testIcon();
    }

  • How to remove the title bar of a frame(java.awt.Frame)?

    How to get a frame without any TitleBar?

    setUndecorated(true);
    This also gets rid of the minimize, normalize, and close buttons from the upper right corner of the screen--so have a way to close and resize if you need it.
    btw: do you know how to bring up the API docs?

  • Color of the title bar

    HI
    How do you change the color of the title bar of a frame....also is it possible to paint an image on the tile bar so that its looks could be enhanced..pls help

    Hi Arya,
    There are 2 questions here, 1 is simple to answer the other is quite difficult.
    How do you change the color of the title bar of a frameSimply add the colors you want to the UIManager
    UIManager.put("Frame.activeTitleBackground", new ColorUIResource(YOURCOLOUR_BACKGROUND));
    UIManager.put("Frame.activeTitleForeground", new ColorUIResource(YOURCOLOUR_FOREGROUND));
    UIManager.put("Frame.inactiveTitleBackground", new ColorUIResource(YOURCOLOUR_INACTIVE_BACKGROUND));
    UIManager.put("Frame.inactiveTitleForeground", new ColorUIResource(YOURCOLOUR_INACTIVE_FOREGROUND));
    also is it possible to paint an image on the tile bar This is a bit more tricky. You will need to implement your own RootPaneUI which in turn uses a TitlePane class that represents the title bar. In your implementation of the title bar you will handle adding an image.
    Have a look at MetalRootPaneUI and MetalTitlePane to get an idea about the implementation.
    N35Sy

  • How to send a warning message before closing soft via X of the title bar

    With labview 8.2:
    I would like to send a warning message before closing my soft when the user press the "X" of the title bar. Is it possible to do that without a Windows dll?
    Thanks a lot,
    Daniel.

    Gerd,
    I think a filter event for 'Panel close?' is more appropriate because you have the possibility to cancel the event or continue the event.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • Disable Refresh menu option on Page Title Bar

    Hi,
    We have a TLN node that opens an iview in a new window. Therefore nothing is displayed in the portal page. However the Page Title Bar menu still has all the options (Open in New Window, Refresh, Details etc.) and if a user selects Refresh, it throws a portal runtime error (iView not found: .default). How can I disable the menu options for this iview? I have tried setting the Show Refresh etc. parameters to No but it didn't work - I assume because the iview isn't being opened in the portal page.
    Many thanks
    Jane

    hi
    the iview you need to explore is page title bar i view in default framework page available in  portal standard user  directory in portal content.In this context i would like to suggest a solution why don,t you creat a default framework page just copy it in your folder  and open it and disable all checkboxes associated to page title bar and save after that go on to create a deskttop in portal display in system configuration and add your framework page and theme from themes in portal content and then add a rule to the main rule in super administrators  folder which will for role of the user will display onle that desktop.i have illustrated the concept of branding if you want to avoid codeing or command groups which is long approach.hope this helps youplease do not forget to give points
    with regards
    subrato kundu

  • Who Will Be the First to Tweak IE9 To Restore the Page Title into the Title Bar?

    It's a well-known fact that if you disable the tabbed view (i.e., you prefer to use multiple separate windows for your browser pages) the Page Title from whatever web page you visit doesn't show up anywhere.
    How does a blatant omission like this pass a design review?
    It's like someone at Microsoft doesn't think titles belong in Title Bars any more.  Who is this person, and do they actually USE a computer?
    In a similar vein, Windows Explorer windows no longer put the path in the Title Bar -
    unless you use one of the fine aftermarket products such as ShellFolderFix or ClassicShell to restore the Title Bar to service.
    Has anyone figured out yet what to tweak to put the page title in the Window Title Bar for IE9?
    -Noel

    I see I just got another up-vote for the original post in this thread.
    Perhaps it's time to follow up...
    TODAY, with Windows 8.1 and IE11, we see that you can no longer eliminate tabbed view.  Thus there is a place - at the expense of some space for the address bar, where the page
    title appears.  But it is not the Title bar, and it's usually not wide enough to fit the whole title.
    Why is Microsoft continuing to choose to do ANYTHING but follow their own desktop usability standards? 
    We see the ongoing departure of application design from standards not only in IE, but also in Office and other Microsoft applications.
    Hey!  We users didn't designate that space across the tops of windows as a title area.  Microsoft did.  We just got used to using it.  When we look to activate the proper window on our desktops, we look at the titles.  Fortunately,
    there are 3rd party developers who make programs to put the right things back, but I'm forced to ask:  Why?  This is not an accident.
    Are we being groomed by Microsoft to become used to and ultimately begin to accept random UI design?
    Microsoft engineers, are you being instructed to make your designs less conformant to desktop usability standards by your bosses?  If so, you need to tell them to kiss your collective asses!  You're not doing your products any favors by following
    such ridiculous advice, and as your products go so will your company.  You are not too big to fail!
    People will only allow themselves to be manipulated for so long.  Then you'll find some other company has made a product that's better (something you're
    facilitating by making your product worse) and is eating your lunch.
    Have a nice day in Redmond.
    -Noel
    Detailed how-to in my eBooks:  
    Configure The Windows 7 "To Work" Options
    Configure The Windows 8 "To Work" Options

  • How to customize the title bar on my own Look And Feel?

    Hi all!
    I am creating my own Look and Feel which extends from NimbusLookAndFeel. What I'm doing is overwriting UIDefaults values??, referring to the Painters. For example:
    +uiDefault.put ("Button [Enabled]", new ButtonEnabledPainter());+
    But now I need is to customize the title bar of the JFrame's, but I do not see this option in Painter's values ??can be overwritten by Nimbus (http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/_nimbusDefaults . html).
    You know as possible? I have to overwrite an existing UI component? The idea is I want to make the look and feel like SeaGlass, but the code seems a bit complex to know where to begin.
    I hope you can guide me on this issue.
    Thank you very much for everything! And excuse my English!.
    Greetings!

    very simple example, with direct methods
    import java.awt.*;
    import java.awt.event.*;
    import java.util.LinkedList;
    import java.util.Queue;
    import javax.swing.*;
    public class NimbusBorderPainterDemo extends JFrame {
        private static final long serialVersionUID = 1L;
        private JFrame frame = new JFrame();
        private JPanel fatherPanel = new JPanel();
        private JPanel contentPanel = new JPanel();
        private GradientPanel titlePanel = new GradientPanel(Color.BLACK);
        private JLabel buttonPanel = new JLabel();
        private Queue<Icon> iconQueue = new LinkedList<Icon>();
        public NimbusBorderPainterDemo() {
            iconQueue.add(UIManager.getIcon("OptionPane.errorIcon"));
            iconQueue.add(UIManager.getIcon("OptionPane.informationIcon"));
            iconQueue.add(UIManager.getIcon("OptionPane.warningIcon"));
            iconQueue.add(UIManager.getIcon("OptionPane.questionIcon"));
            JButton button0 = createButton();
            button0.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    frame.setExtendedState(ICONIFIED);
            JButton button1 = createButton();
            button1.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    frame.setExtendedState(MAXIMIZED_BOTH | NORMAL);
                }//quick implemented, not correct you have to override both methods
            JButton button2 = createButton();
            button2.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    int confirm = JOptionPane.showOptionDialog(frame,
                            "Are You Sure to Close Application?", "Exit Confirmation",
                            JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
                            null, null, null);
                    if (confirm == JOptionPane.YES_OPTION) {
                        System.exit(1);
            buttonPanel.setLayout(new GridLayout(0, 3, 5, 0));
            buttonPanel.setPreferredSize(new Dimension(160, 30));
            buttonPanel.add(button0);// JLabel is best and cross_platform JComponents
            buttonPanel.add(button1);// not possible put there witouth set Dimmnesion
            buttonPanel.add(button2);// and LayoutManager, work in all cases better
            titlePanel.setLayout(new BorderLayout());//than JPanel or JCompoenent
            titlePanel.add(new JLabel(nextIcon()), BorderLayout.WEST);
            titlePanel.add(new JLabel("My Frame"), BorderLayout.CENTER);
            titlePanel.setBorder(BorderFactory.createLineBorder(Color.GRAY));
            titlePanel.add(buttonPanel, BorderLayout.EAST);
            JTextField field = new JTextField(50);
            JButton btn = new JButton("Close Me");
            btn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    System.exit(1);
            contentPanel.add(field);
            contentPanel.add(btn);
            fatherPanel.setLayout(new BorderLayout());
            fatherPanel.add(titlePanel, BorderLayout.NORTH);
            fatherPanel.add(contentPanel, BorderLayout.CENTER);
            frame.setUndecorated(true);
            frame.add(fatherPanel);
            frame.setLocation(50, 50);
            frame.pack();
            frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
            frame.setVisible(true);
            ComponentMover cm = new ComponentMover(frame, titlePanel);
            //by camickr http://tips4java.wordpress.com/2009/06/14/moving-windows/
        private JButton createButton() {
            JButton button = new JButton();
            button.setBorderPainted(false);
            button.setBorder(null);
            button.setFocusable(false);
            button.setMargin(new Insets(0, 0, 0, 0));
            button.setContentAreaFilled(false);
            button.setIcon(nextIcon());
            button.setRolloverIcon(nextIcon());
            button.setPressedIcon(nextIcon());
            button.setDisabledIcon(nextIcon());
            nextIcon();
            return button;
        private Icon nextIcon() {
            Icon icon = iconQueue.peek();
            iconQueue.add(iconQueue.remove());
            return icon;
        private class GradientPanel extends JPanel {
            private static final long serialVersionUID = 1L;
            public GradientPanel(Color background) {
                setBackground(background);
            @Override
            public void paintComponent(Graphics g) {
                super.paintComponent(g);
                if (isOpaque()) {
                    Color background = new Color(168, 210, 241);
                    Color controlColor = new Color(230, 240, 230);
                    int width = getWidth();
                    int height = getHeight();
                    Graphics2D g2 = (Graphics2D) g;
                    Paint oldPaint = g2.getPaint();
                    g2.setPaint(new GradientPaint(0, 0, background, width, 0, controlColor));
                    g2.fillRect(0, 0, width, height);
                    g2.setPaint(oldPaint);
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    try {
                        UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
                    } catch (Exception fail) {
                    UIManager.getLookAndFeelDefaults().put("nimbusFocus", Color.RED);
                    NimbusBorderPainterDemo nimbusBorderPainterDemo = new NimbusBorderPainterDemo();
    }

  • How to change the title bar wdith , scroll bar widths in tune with a 7" screen

    can you please help me customize my user chrome section so that I can REDUCE the WIDTH of the scroll bar ( horizontal and vertical ) . That is , at max the scroll bar can be ___ pixels of __ % of total width. ( prefer the relative reference )
    Also the title bar ( that black surrounding area that bears the minimize, maximize,close buttons ) needs its width reduced to half of what it is now. How do I do this ?

    No. That doesn't work any more. In current Firefox versions native scroll bars are used and you can't do style those via userChrome.css (user interface; chrome windows) and userContent.css (websites). You can try a large theme if you do not want to make the changes via the Control Panel

  • How do I remove the title bar from a Palm PDA front panel?

    On several PDA screens, I need all the real esate I can get. The title bar chews up a lot of it.  Is there any way, in the vi settings or programmatically, that I can remove the title bar?
    I've already tried the obvious step of unchecking "window has a title bar" in the window appearance catagory of the vi properties.  No apparent effect is seen.

    Hello,
    It sounds like you are referring to the GUI actually on your Palm devices.  I believe on Palm devices all applications have a title bar, and there isn't a way to get rid of it.  My guess is that perhaps this is a feature you can enable/disable as a Palm OS setting, or may simply be the way the Palm has defined its user interface.  If you have your Palm devices handy, check out the display settings to see any has an option to remove the title bars in general.  If you find out either way, definitely repost so the community can find the answer here as well!
    Thank you,
    Best Regards,
    JLS
    Best,
    JLS
    Sixclear

  • User-defined F4 Search - cancel button in the title bar

    Hi,
    I implement user-defined F4 search for my WD application. F4 view comes from another component (as described in the tutorial). Everything is fine, I see that view popuped when F4 is clicked for an input field. My problem is, how to make visible the Close button in the title bar of that popup window.
    I was able to set window's title text, but have no idea how to control those buttons. I only see maximize button which comes by default.
    Also would be nice to create kind of standard OK and Cancel buttons on the bottom bar instead of creating them manually on my view... I've tried set_button_kind(), it works somehow: displayes three empty buttons without icons - need more info about it too...
    Thanks

    Hi Serguei,
    The empty buttons are worth a ticket.
    The behavior for the close button in popups is that the application developer can determine its visibility independent from the buttons in the lower row.
    The second aspect is the action that is triggered if someone clicks that button. There the application developer is able to bind a separate action to that close button. If no action was bound and if a cancel button is visible, clicking the close button will trigger the same action as it would have been the case for the cancel button. A bit complicated, I know. We had to do the latter for backwards compatibility.
    Best regards,
    Thomas

  • Remove (Private Browsing) in the Title bar

    When in Private Browsing mode is there any way to remove the identifying text in the Title bar?

    Enter Private Browsing mode this way and close and restart Firefox (File > Exit) by starting Firefox automatically in Private Browsing mode.
    To see all History settings, choose: Tools > Options > Privacy, choose the setting '''Firefox will: Use custom settings for history'''
    Check: [[ ] "Automatically start Firefox in a private browsing session"
    See also [[Private Browsing|#Always_start_Firefox_in_a_private_browsing_session|Always start Firefox in a private browsing session]]

  • Regarding the Title Bar

    I recently got Premiere pro cs4. I was wondering if there is anyway, be it by other 3rd party software, to hide the title bar in Premiere.
    I wish to do this because i have a program called Objectbar installed. Which acts as a second title bar for any program. Similar to the Mac menu bar. Gets a bit annoying if i have to look at two menus right on top of each other.
    -Thanks in advance.

    Adobe apps have historically ignored *any* commands from ObjectBar. And in the rare cases where they did "respect" OB's title/menu bar arrangement, strange behavior and app hangs were often the result.
    I tried really hard to make my PC look like a Mac several years ago. It was always "close, but no cigar" with a ton of small issues and irritations to try to work around.
    I finally decided to customize Windows to look the best it could look while keeping the Windows paradigm. Now that I'm on Vista 64 with strong CPU hardware and more RAM than I've ever had before, I don't have any Stardock apps installed. Not even my favorite, ObjectDock Plus.
    "Render unto Caesar what is Caesar's"
    IOw, if you want a Mac UI, and Mac UI behavior, then buy a Mac. Celebrate and enjoy Windows for what it is. With Stardock's help, you can do all kinds of amazing things that will make Windows far more attractive and functional than OSX will ever be for the Mac.
    IMHO, of course. :)
    -Jeff

  • The Title Bar locks while surfing the web.

    The Title Bar on my Firefox has started to lock during surfing. This has happened on both my home and work laptops. I cannot work any Title Bar controls nor can I right click on the Taskbar button to resize the window but can still work Menu Bar controls and continue surfing. Sometimes the Title Bar returns to normal. Many times it does not. Occasionally it locks Firefox and I have to close via the Task Manager.

    Do you have that problem when running in the Firefox SafeMode? <br />
    [http://support.mozilla.com/en-US/kb/Safe+Mode] <br />
    ''Don't select anything right now, just use "Continue in SafeMode."''
    If not, see this: <br />
    [http://support.mozilla.com/en-US/kb/troubleshooting+extensions+and+themes]

Maybe you are looking for