List of usage examples for java.awt Desktop Desktop
private Desktop()
From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java
public MainForm(final Application application) throws Exception { Log.info("Start in application mode, application \"" + application.getID() + '\"'); this.application = application; initComponents();//from w ww.j a v a2s . c o m this.setJMenuBar(application.lookup(JMenuBar.class)); this.popupMenu = application.lookup(JPopupMenu.class); hexMapPanelDesktop = new Desktop(); layers = new LayerListModel(256, 128); try { this.setIconImage(ImageIO.read(this.getClass().getClassLoader() .getResource("com/igormaznitsa/jhexed/swing/editor/icons/logo.png"))); } catch (Exception ex) { Log.error("Can't load app icon", ex); } hexMapPanel = new HexMapPanel(this.layers); hexMapPanel.addHexMapPanelListener(this); hexMapPanel.addMouseListener(this); hexMapPanel.addMouseMotionListener(this); hexMapPanel.addMouseWheelListener(this); final Image icon = application.getApplicationIcon(); if (icon != null) { this.setIconImage(icon); } final String title = application.getTitle(); if (title != null) { this.setTitle(title); } this.panelMainArea.removeAll(); setComponentForPosition(this.panelMainArea, UIComponentPosition.TOP_PANEL, application.getUIComponent(UIComponentPosition.TOP_PANEL)); setComponentForPosition(this.panelMainArea, UIComponentPosition.LEFT_PANEL, application.getUIComponent(UIComponentPosition.LEFT_PANEL)); setComponentForPosition(this.panelMainArea, UIComponentPosition.RIGHT_PANEL, application.getUIComponent(UIComponentPosition.RIGHT_PANEL)); setComponentForPosition(this.panelMainArea, UIComponentPosition.BOTTOM_PANEL, application.getUIComponent(UIComponentPosition.BOTTOM_PANEL)); this.panelMainArea.add(hexMapPanelDesktop, BorderLayout.CENTER); hexMapPanelDesktop.setContentPane(hexMapPanel); this.applicationGraphics = application.lookup(ApplicationGraphics.class); this.frameLayers = null; this.frameToolOptions = null; this.frameTools = null; this.dsl = null; this.groovyShell = null; this.compilerConfiguration = null; this.lookupContainer = new ObjectLookup(this, this.hexMapPanel.getHexEngine(), this, Log.makeApplicationLog()); final InputStream initialMap = application.getInitialMap(this); try { final FileContainer container = new FileContainer(initialMap); loadState(container); } catch (Exception ex) { Log.error("Can't load initial map data or read that", ex); throw ex; } finally { IOUtils.closeQuietly(initialMap); } loadSettings(); final java.util.List<HexLayer> listOfLayers = new ArrayList<HexLayer>(); for (int i = 0; i < this.layers.getSize(); i++) { final LayerRecordPanel alayer = this.layers.getElementAt(i); listOfLayers.add(alayer); } this.hexLayerList = Collections.unmodifiableList(listOfLayers); this.hexMapPanel.setZoom(1.0f); }
From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java
public MainForm(final String fileToOpen) { Log.info("Start in editor mode"); this.application = null; this.hexLayerList = null; initComponents();/* w w w. ja va 2 s. c o m*/ final JFrame theFrame = this; for (final javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { final JMenuItem landfItem = new JMenuItem(info.getName()); landfItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { javax.swing.UIManager.setLookAndFeel(info.getClassName()); } catch (Exception ex) { Log.error("Can't change L&F", ex); } SwingUtilities.updateComponentTreeUI(theFrame); } }); menuLANDF.add(landfItem); } popupMenu = new JPopupMenu(); final JMenuItem comments = new JMenuItem("Comments"); comments.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // open dialog for cell comment final CellCommentDialog commentDialog = new CellCommentDialog(theFrame, "Commentaries for the cell at " + popupHex.getColumn() + "," + popupHex.getRow(), cellComments.getForHex(popupHex)); commentDialog.setVisible(true); final String result = commentDialog.getResult(); if (result != null) { cellComments.setForHex(popupHex, result); } } }); popupMenu.add(comments); hexMapPanelDesktop = new Desktop(); layers = new LayerListModel(256, 128); try { this.setIconImage(ImageIO.read(this.getClass().getClassLoader() .getResource("com/igormaznitsa/jhexed/swing/editor/icons/logo.png"))); } catch (Exception ex) { Log.error("Can't load app icon", ex); } hexMapPanel = new HexMapPanel(this.layers); hexMapPanel.addHexMapPanelListener(this); hexMapPanel.addMouseListener(this); hexMapPanel.addMouseMotionListener(this); hexMapPanel.addMouseWheelListener(this); this.panelMainArea.add(hexMapPanelDesktop, BorderLayout.CENTER); this.frameLayers = new FrameLayers(layers, hexMapPanel); this.frameTools = new FrameTools(); this.frameToolOptions = new FrameToolOptions(); hexMapPanelDesktop.addFrame(this.frameLayers); hexMapPanelDesktop.addFrame(this.frameTools); hexMapPanelDesktop.addFrame(this.frameToolOptions); this.frameLayers.setVisible(true); this.frameTools.setVisible(true); this.frameToolOptions.setVisible(true); hexMapPanelDesktop.setContentPane(hexMapPanel); this.dsl = new GroovyPluginBase(this, this.layers); this.compilerConfiguration = new CompilerConfiguration(); this.compilerConfiguration.setScriptBaseClass(DelegatingScript.class.getName()); this.groovyShell = new GroovyShell(this.compilerConfiguration); InsideApplicationBus.getInstance().addAppBusListener(this); loadSettings(); resetState(); Log.info("The MainForm created"); registerInternalPlugins(); registerExternalPlugins("."); if (fileToOpen != null) { Log.info("Started with parameter: " + fileToOpen); final File file = new File(fileToOpen); loadFromFile(file); } this.lookupContainer = new ObjectLookup(this, this.hexMapPanel.getHexEngine(), this, Log.makeApplicationLog()); this.applicationGraphics = null; }