/** * Lazily building of layer icon. * * @return the layer icon */ public Icon getIcon () { if (icon == null) { ResourceMap resource = Application.getInstance().getContext().getResourceMap( ViewParameters.class); String key = getClass().getSimpleName() + "." + this + ".icon"; String resourceName = resource.getString(key); icon = new ImageIcon(ViewParameters.class.getResource(resourceName)); } return icon; } }
/** * Just to allow stand-alone running of this class * * @param args not used */ public static void main (String... args) { standAlone = true; // Set UI Look and Feel UILookAndFeel.setUI(null); Locale.setDefault(Locale.ENGLISH); // Off we go... Application.launch(Trainer.class, args); }
/** * The {@code Application} singleton. * <p> * This method is only called after an Application has * been launched. * * @param applicationClass this Application's subclass * @return the launched Application singleton. * @see Application#launch */ public static synchronized <T extends Application> T getInstance(Class<T> applicationClass) { if (Beans.isDesignTime() && application==null) { try { application = create(applicationClass); } catch (Exception ex) { String msg = String.format("Couldn't construct %s", applicationClass); Logger.getLogger(Application.class.getName()).log(Level.SEVERE, msg, ex); throw new Error(msg, ex); } } checkApplicationLaunched(); return applicationClass.cast(application); }
@Override public void run() { try { application = create(applicationClass); application.initialize(args); application.startup(); application.waitForReady(); } catch (Exception e) { String msg = String.format("Application %s failed to launch", applicationClass); logger.log(Level.SEVERE, msg, e); throw (new Error(msg, e)); } } };
/** * Report the single instance of this GUI SAF application. * * @return the SingleFrameApplication instance */ public static SingleFrameApplication getApplication () { return (SingleFrameApplication) Application.getInstance(); } }
/** * Gets the {@code ApplicationContext} for the {@code * Application} that's responsible for showing/hiding this View. * This method is just shorthand for {@code getApplication().getContext()}. * * @return the Application that owns this View * @see #getApplication * @see Application#show(View) * @see Application#hide(View) */ public final ApplicationContext getContext() { return getApplication().getContext(); }
@Override public void run() { for (ExitListener listener : exitListeners) { if (!listener.canExit(event)) { return; } } try { for (ExitListener listener : exitListeners) { try { listener.willExit(event); } catch (Exception e) { logger.log(Level.WARNING, "ExitListener.willExit() failed", e); } } shutdown(); } catch (Exception e) { logger.log(Level.WARNING, "unexpected error in Application.shutdown()", e); } finally { end(); } } };
/** * Handles quit even on Mac Os X * Developer should not use it directly * @return always <tt>true</tt> */ public boolean handleQuit() { exit(); return false; }
@Override protected void end() { JFrame mainFrame = getMainFrame(); if (mainFrame != null || mainFrame.isDisplayable()) { mainFrame.setVisible(false); mainFrame.dispose(); } super.end(); } }
/** * The {@code Application} singleton. * <p> * This method is only called after an Application has * been launched. * * @return the Application singleton or a placeholder * @see Application#launch * @see Application#getInstance(Class) */ public static synchronized Application getInstance() { if (Beans.isDesignTime() && application==null) { application = new DesignTimeApplication(); } checkApplicationLaunched(); return application; }
@Override public boolean canExit (EventObject eo) { // Check whether the repository has been saved (or user has declined) if (isModified()) { SingleFrameApplication appli = (SingleFrameApplication) Application.getInstance(); int answer = JOptionPane.showConfirmDialog( appli.getMainFrame(), "Save " + SampleRepository.this + "?"); if (answer == JOptionPane.YES_OPTION) { storeRepository(); return true; // Here user has saved the repository } // True: user specifically chooses NOT to save the script // False: user says Oops!, cancelling the current close request return answer == JOptionPane.NO_OPTION; } return true; }
/** * The {@code ApplicationContext} for the {@code * Application} that's responsible for showing/hiding this View. * This method is just shorthand for {@code getApplication().getContext()}. * * @return the Application that owns this View * @see #getApplication * @see Application#show(View) * @see Application#hide(View) */ public final ApplicationContext getContext() { return getApplication().getContext(); }
/** * Gracefully shutdowns the application, calls {@code exit(null)} * This version of exit() is convenient if the decision to exit the * application wasn't triggered by an event. * * @see #exit(EventObject) */ public final void exit() { exit(null); }
/** * Lazily building of mode icon. * * @return the mode icon */ public Icon getIcon () { if (icon == null) { ResourceMap resource = Application.getInstance().getContext().getResourceMap( ViewParameters.class); String key = getClass().getSimpleName() + "." + this + ".icon"; String resourceName = resource.getString(key); icon = new ImageIcon(ViewParameters.class.getResource(resourceName)); } return icon; } }
jScrollPane1.setViewportView(jTextArea1); org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(com.moneychanger.app.Moneychanger.class).getContext().getResourceMap(OTWriteChequeOutput.class); jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N jButton1.setName("jButton1"); // NOI18N
public final ApplicationContext getContext() { return getApplication().getContext(); }
private void startGui(final String[] args) { if (AppHelper.getPlatform() == PlatformType.OS_X) { MacSetup.setupMac(); } Application.launch(PortMapperApp.class, args); }
/** * The default {@code Action} for quitting an application, * {@code quit} just exits the application by calling {@code exit(e)}. * * @param e the triggering event * @see #exit(EventObject) */ @Action public void quit(ActionEvent e) { exit(e); }
/** * Display the UI frame. */ public static void showFrame () { if (frame == null) { frame = new JFrame(); frame.setName("shapeColorChooserFrame"); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.add(new ShapeColorChooser().component); // Resources injection ResourceMap resource = Application.getInstance().getContext().getResourceMap( ShapeColorChooser.class); resource.injectComponents(frame); } OmrGui.getApplication().show(frame); }
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(com.moneychanger.app.Moneychanger.class).getContext().getResourceMap(NYMAdditionDialog.class); jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N jButton1.setName("jButton1"); // NOI18N