osx - Creating an offscreen frame in Java (or: how to avoid a blank menu on a Mac, when all application windows are closed)? -
I am creating a Mac application, and I have to look right on my menu bar.
Any Mac user knows that the menu bar should be in the top screen menu. Setting apple.laf.useScreenMenuBar
in the Property List file to true
can be rid of the in-frame menu of the screen and move the menu bar of the currently focused window to the screen Does.
However, when all windows are hidden or there are no windows, there is no menu bar to move to the top, and you get a blank menu. I have heard a solution that has been focused on creating an off-screen window, when there is no other one. Its sole purpose will be its menu, so that others have to fill it out.
However, I am increasing the burden of problems. I do not seem to move the window over the screen because Mac will not let you set coordinates to some before the screen's size; It just bites it and places it on the edge Do I have to do something to create an offscreen window?
You should definitely consider wizard objects to help use helpful answers correctly, And it's easy to set up the minimum to get started. A continuous file
menu will allow your application to open a new window when another window is closed. This is a simple link.
Although Apple is an excellent guide than your users, you can definitely use it from the suggested perspective in your question. Specifically, you can try the setLocation (short. MIN_VALUE, short.min.VALUE)
on the invisible window. In addition, you may want to answer in a particular way if it indicates the end view window closes.
Appendix: When your listener sees the last view window close, then create a new, empty application window. Alternatively, move the invisible window to the on-screen and make it visible until the user decides to proceed.
Appendix: Mac OS X prevents an visible window form from transferring offscreen, but as shown below, an invisible < / Em> It's easy to put in the window.
Import java.awt.BorderLayout; Import java.awt.EventQueue; Import java.awt.event.ItemEvent; Import java.awt.event.ItemListener; Import javax.swing.JFrame; Import javax.swing.JPanel; Import javax.swing.JToggleButton; Public Class Framework JFrame {Private Static Framework Marco; Private stable framesta polo; Private stable class MyPanel JPanel {Public MyPanel ()} {Super (true); Last JToggleButton b = new JToggleButton ("Test"); B.addItemListener (new item listener) {@Override Public Zero ItemState Change (item event e) {if (b.isSelected ()) {polo.setLocation (100, 100); polo.setVisible (true);} else { Polo.setvisible (false); polo .Set location (short. MIN_VALUE, short. MIN_VALUE);}}}); This.add (b); }} Public frametast (string title) {super (title); This.setLayout (new border layout ()); This.add (new MyPanel ()); This.pack (); This.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); } Public Static Zero Main (Last String [] Elps) {EventQueue.invokeLater (New Runnabal) {@ Override Public Wide Run ({{Marco = New Frame Test ("Marco"); Marco. CatalunyaRilletto (empty); Marco .Setvijbal (true); Polo = new frames ("polo"); Polo .Set Position (short. MIN_VALUE, short. MIN_VALUE);}}); }}
Comments
Post a Comment