List of usage examples for java.awt.event ComponentAdapter ComponentAdapter
ComponentAdapter
From source file:pl.otros.logview.gui.LogViewMainFrame.java
/** * @param args porgram CLI arguments//from www. ja v a2 s . c o m * @throws InitializationException * @throws InvocationTargetException * @throws InterruptedException */ public static void main(final String[] args) throws InitializationException, InterruptedException, InvocationTargetException { if (args.length > 0 && "-batch".equals(args[0])) { try { String[] batchArgs = new String[args.length - 1]; System.arraycopy(args, 1, batchArgs, 0, batchArgs.length); BatchProcessor.main(batchArgs); } catch (IOException e) { System.err.println("Error during batch processing: " + e.getMessage()); e.printStackTrace(); } catch (ConfigurationException e) { System.err.println("Error during batch processing: " + e.getMessage()); e.printStackTrace(); } return; } SingleInstanceRequestResponseDelegate singleInstanceRequestResponseDelegate = SingleInstanceRequestResponseDelegate .getInstance(); singleInstance = SingleInstance.request("OtrosLogViewer", singleInstanceRequestResponseDelegate, singleInstanceRequestResponseDelegate, args); if (singleInstance == null) { LOGGER.info("OtrosLogViewer is already running, params send using requestAction"); System.exit(0); } GuiJulHandler handler = new GuiJulHandler(); handler.setLevel(Level.ALL); Logger olvLogger = Logger.getLogger("pl.otros.logview"); olvLogger.setLevel(Level.ALL); olvLogger.addHandler(handler); LOGGER.info("Starting application"); OtrosSplash.setMessage("Starting application"); OtrosSplash.setMessage("Loading configuration"); final XMLConfiguration c = getConfiguration("config.xml"); if (!c.containsKey(ConfKeys.UUID)) { c.setProperty(ConfKeys.UUID, UUID.randomUUID().toString()); } IconsLoader.loadIcons(); OtrosSplash.setMessage("Loading icons"); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { try { OtrosSplash.setMessage("Loading L&F"); String lookAndFeel = c.getString("lookAndFeel", "com.jgoodies.looks.plastic.PlasticXPLookAndFeel"); LOGGER.config("Initializing look and feelL: " + lookAndFeel); PlasticLookAndFeel.setTabStyle(Plastic3DLookAndFeel.TAB_STYLE_METAL_VALUE); UIManager.setLookAndFeel(lookAndFeel); } catch (Throwable e1) { LOGGER.warning("Cannot initialize LookAndFeel: " + e1.getMessage()); } try { final DataConfiguration c1 = new OtrosConfiguration(c); final LogViewMainFrame mf = new LogViewMainFrame(c1); // mf.exitAction was instantiated in the constructor (previous line) // Not sure retrieving this from most appropriate Apache config // object. mf.exitAction.setConfirm(c.getBoolean("generalBehavior.confirmExit", true)); /* TODO: Implement User Preferences screen or checkbox on exit widget * that will update the same config object something like: * c.setProperty("generalBehavior.confirmExit", newValue); */ mf.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { c.setProperty("gui.state", mf.getExtendedState()); if (mf.getExtendedState() == Frame.NORMAL) { c.setProperty("gui.width", mf.getWidth()); c.setProperty("gui.height", mf.getHeight()); } } @Override public void componentMoved(ComponentEvent e) { c.setProperty("gui.location.x", mf.getLocation().x); c.setProperty("gui.location.y", mf.getLocation().y); } }); mf.addWindowListener(mf.exitAction); SingleInstanceRequestResponseDelegate.openFilesFromStartArgs(mf.otrosApplication, Arrays.asList(args), mf.otrosApplication.getAppProperties().getCurrentDir()); } catch (InitializationException e) { LOGGER.log(Level.SEVERE, "Cannot initialize main frame", e); } } }); }
From source file:com.sshtools.common.ui.SshToolsApplicationApplet.java
/** * * * @return// ww w . ja va 2 s.c o m * * @throws IOException * @throws SshToolsApplicationException */ public JComponent buildAppletComponent() throws IOException, SshToolsApplicationException { loadingPanel.setStatus("Creating application"); applicationPanel = createApplicationPanel(); loadingPanel.setStatus("Building action components"); applicationPanel.rebuildActionComponents(); log.debug("Disabled actions list = " + disabledActions); StringTokenizer tk = new StringTokenizer((disabledActions == null) ? "" : disabledActions, ","); while (tk.hasMoreTokens()) { String n = tk.nextToken(); log.debug("Disable " + n); applicationPanel.setActionVisible(n, false); } JPanel p = new JPanel(new BorderLayout()); JPanel n = new JPanel(new BorderLayout()); if (applicationPanel.getJMenuBar() != null) { n.add(applicationPanel.getJMenuBar(), BorderLayout.NORTH); log.debug("Setting menu bar visibility to " + menuBar); applicationPanel.setMenuBarVisible(menuBar); } if (applicationPanel.getToolBar() != null) { JPanel t = new JPanel(new BorderLayout()); t.add(applicationPanel.getToolBar(), BorderLayout.NORTH); applicationPanel.setToolBarVisible(toolBar); t.add(toolSeparator = new JSeparator(JSeparator.HORIZONTAL), BorderLayout.SOUTH); toolSeparator.setVisible(applicationPanel.getToolBar().isVisible()); final SshToolsApplicationPanel pnl = applicationPanel; applicationPanel.getToolBar().addComponentListener(new ComponentAdapter() { public void componentHidden(ComponentEvent evt) { toolSeparator.setVisible(pnl.getToolBar().isVisible()); } }); n.add(t, BorderLayout.SOUTH); } p.add(n, BorderLayout.NORTH); p.add(applicationPanel, BorderLayout.CENTER); if (applicationPanel.getStatusBar() != null) { p.add(applicationPanel.getStatusBar(), BorderLayout.SOUTH); applicationPanel.setStatusBarVisible(statusBar); } return p; }
From source file:studio.ui.Studio.java
public Studio(AppConfig config, String... args) { super(AppInformation.getInformation().getTitle()); setIconImage(IconsItem.IMAGE_APP);//from ww w. ja v a 2 s.c om enableEvents(AWTEvent.WINDOW_EVENT_MASK); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); setSize((int) (0.9 * screenSize.width), (int) (0.9 * screenSize.height)); setLocation(((int) Math.max(0, (screenSize.width - getWidth()) / 2.0)), (int) (Math.max(0, (screenSize.height - getHeight()) / 2.0))); this.studioConfig = config; if (studioConfig.isMaximized()) { setExtendedState(JFrame.MAXIMIZED_BOTH); //Maximizing the frame } addWindowStateListener(this); registerForMacOSXEvents(); splitViewer = new JSplitPane(); splitTopViewer = new JSplitPane(); tabConsoles = new ConsolesTabbedPane(); tabConsoles.addFireDataListener(this); tabEditors = new EditorsTabbedPane(tabConsoles); tabEditors.addFireDataListener(this); if (tabConsoles instanceof DataListener) { tabEditors.addFireDataListener((DataListener) tabConsoles); } tools = new ToolsPanel(); splitViewer.setOrientation(JSplitPane.VERTICAL_SPLIT); splitViewer.setDividerSize(0); splitViewer.setTopComponent(splitTopViewer); splitViewer.setBottomComponent(tabConsoles); splitViewer.setOneTouchExpandable(true); splitTopViewer.setOrientation(JSplitPane.HORIZONTAL_SPLIT); splitTopViewer.setDividerSize(9); splitTopViewer.setTopComponent(tools); splitTopViewer.setBottomComponent(tabEditors); splitTopViewer.setOneTouchExpandable(true); createConnectionsTree(); createProjectsTree(); rebuildMenus(null); getContentPane().add(splitViewer, BorderLayout.CENTER); splitViewer.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent event) { if (event.getComponent() instanceof JSplitPane) { if (((JSplitPane) event.getComponent()).getDividerSize() == 0) { ((JSplitPane) event.getComponent()).setDividerLocation(1d); } } } }); this.setVisible(true); splitTopViewer.setDividerLocation(.2d); splitViewer.setDividerLocation(1d); NewFileAction newAction = null; OpenFileAction openAction = null; ToolBarActions toolbar = appToolbar != null ? appToolbar.getToolBar("File") : null; if (toolbar != null) { for (int count = 0; count < toolbar.getComponentCount(); count++) { if (toolbar.getComponent(count) instanceof JButton) { if (((JButton) toolbar.getComponent(count)).getAction().getClass() == OpenFileAction.class) { openAction = (OpenFileAction) ((JButton) toolbar.getComponent(count)).getAction(); } else { if (((JButton) toolbar.getComponent(count)).getAction().getClass() == NewFileAction.class) { newAction = (NewFileAction) ((JButton) toolbar.getComponent(count)).getAction(); } } if (openAction != null && newAction != null) { break; } } } } EditorFile last = null; if (config.getLastFiles() != null && !config.getLastFiles().isEmpty()) { for (EditorFile file : config.getLastFiles()) { if (file.isActive()) { last = file; } try { openAction.initDocument(file); } catch (FileException ex) { JOptionPane.showMessageDialog(this, ex.getMessage(), "File", JOptionPane.WARNING_MESSAGE); } } } else { if (args == null || args.length == 0) { newAction.actionPerformed(null); } } if (args != null && args.length > 0) { for (String arg : args) { File file = new File(arg); if (file.exists() && file.canRead()) { try { openAction.initDocument(new EditorFile(file)); } catch (FileException ex) { JOptionPane.showMessageDialog(this, ex.getMessage(), "File", JOptionPane.WARNING_MESSAGE); } } } } if (tabEditors.getTabCount() > 0) { if (last == null) { tabEditors.setSelectedIndex(0); } else { for (int count = 0; count < tabEditors.getTabCount(); count++) { if (tabEditors.getEditor(count).getFile().equals(last)) { tabEditors.setSelectedIndex(count); } } } tabEditors.getEditor().requestFocusInWindow(); } ActionBase action = new ActionBase(null, (char) 0, null, null, null, null) { private static final long serialVersionUID = -1752094455650906542L; @Override public void actionPerformed(ActionEvent event) { treeConnections.requestFocus(); } }; splitViewer.registerKeyboardAction(action, KeyStroke.getKeyStroke("F5"), JComponent.WHEN_IN_FOCUSED_WINDOW); splitViewer.registerKeyboardAction(action, KeyStroke.getKeyStroke("control F5"), JComponent.WHEN_IN_FOCUSED_WINDOW); action = new ActionBase(null, (char) 0, null, null, null, null) { private static final long serialVersionUID = -1752094455650906542L; @Override public void actionPerformed(ActionEvent event) { if (tabEditors.getTabCount() > 0) { tabEditors.requestFocus(); tabEditors.getEditor().requestFocus(); } } }; splitViewer.registerKeyboardAction(action, KeyStroke.getKeyStroke("F3"), JComponent.WHEN_IN_FOCUSED_WINDOW); splitViewer.registerKeyboardAction(action, KeyStroke.getKeyStroke("control F3"), JComponent.WHEN_IN_FOCUSED_WINDOW); action = new ActionBase(null, (char) 0, null, null, null, null) { private static final long serialVersionUID = -7472441241172668338L; @Override public void actionPerformed(ActionEvent event) { treeProjects.requestFocus(); } }; splitViewer.registerKeyboardAction(action, KeyStroke.getKeyStroke("F6"), JComponent.WHEN_IN_FOCUSED_WINDOW); splitViewer.registerKeyboardAction(action, KeyStroke.getKeyStroke("control F6"), JComponent.WHEN_IN_FOCUSED_WINDOW); action = new ActionBase(null, (char) 0, null, null, null, null) { private static final long serialVersionUID = -1752094455650906542L; @Override public void actionPerformed(ActionEvent event) { if (tabConsoles.getTabCount() > 0) { tabConsoles.requestFocus(); if (tabConsoles.getSelectedIndex() != -1) { tabConsoles.getComponentAt(tabConsoles.getSelectedIndex()).requestFocus(); } } } }; splitViewer.registerKeyboardAction(action, KeyStroke.getKeyStroke("F4"), JComponent.WHEN_IN_FOCUSED_WINDOW); splitViewer.registerKeyboardAction(action, KeyStroke.getKeyStroke("control F4"), JComponent.WHEN_IN_FOCUSED_WINDOW); action = new WindowsListAction(tabEditors); splitViewer.registerKeyboardAction(action, action.getAccelerator(), JComponent.WHEN_IN_FOCUSED_WINDOW); }
From source file:de.juwimm.cms.content.panel.PanDocuments.java
public PanDocuments(boolean showRegionCombo, boolean showDocumentProperties) { this.showRegionCombo = showRegionCombo; this.showDocumentProperties = showDocumentProperties; viewComponentId = PanContentView.getInstance().getViewComponent().getViewComponentId(); try {/* ww w . j a v a2 s. com*/ jbInit(); tblDocuments.getSelectionModel().addListSelectionListener(new DocumentListSelectionListener()); tblDocuments.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); btnDelete.setText(Messages.getString("panel.content.documents.deleteDocument")); btnAdd.setText(Messages.getString("panel.content.documents.addDocument")); btnPreview.setText(Messages.getString("dialog.preview")); btnUpdate.setText(Messages.getString("panel.content.documents.updateDocument")); btnUpdate.setVisible(false); lbLinkDescription.setText(Messages.getString("panel.content.documents.linkdescription")); lbDocumentLabel.setText(Messages.getString("panel.content.documents.documentLabel")); lbDocumentDescription.setText(Messages.getString("panel.content.documents.documentDescription")); lbAuthor.setText(Messages.getString("panel.content.documents.author")); lbCategory.setText(Messages.getString("panel.content.documents.category")); ckbDocumentSearchable.setText(Messages.getString("panel.content.documents.documentSearchable")); ckbDocumentSearchable.setSelected(true); cbxDisplayTypeInline.setText(rb.getString("content.modules.externalLink.displayTypeInline")); } catch (Exception exe) { log.error("Initialization error", exe); } this.panDocumentButtons.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { resizeScrollpane(); } }); this.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { resizeScrollpane(); } }); intActUnit = new Integer(((ContentManager) getBean(Beans.CONTENT_MANAGER)).getActUnitId()); intRootUnit = new Integer(((ContentManager) getBean(Beans.CONTENT_MANAGER)).getRootUnitId()); this.cboRegion.addItem( new CboModel(Messages.getString("panel.content.documents.files4ThisUnit"), intActUnit, true)); this.cboRegion.addItem( new CboModel(Messages.getString("panel.content.documents.files4AllUnits"), intRootUnit, true)); this.cboRegion.addItem(new CboModel(Messages.getString("panel.content.documents.files4ThisComponent"), viewComponentId, false)); cboRegion.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { regionSelected(); } }); cboRegion.setSelectedIndex(2); btnAdd.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { btnAddActionPerformed(e); } }); btnPreview.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { btnPreviewActionPerformed(e); } }); btnUpdate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { btnUpdateActionPerformed(e); } }); btnDelete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { btnDeleteActionPerformed(e); } }); //regionSelected(); }
From source file:org.metacsp.utility.UI.ConstraintNetworkFrame.java
public ConstraintNetworkFrame(ObservableGraph<Variable, Constraint> graph, String title, final Callback cb) { super(title); this.g = graph; g.addGraphEventListener(new GraphEventListener<Variable, Constraint>() { @Override/*from w w w .j av a 2 s . c o m*/ public void handleGraphEvent(GraphEvent<Variable, Constraint> evt) { vv.getRenderContext().getPickedVertexState().clear(); vv.getRenderContext().getPickedEdgeState().clear(); try { layout.initialize(); try { Relaxer relaxer = new VisRunner((IterativeContext) layout); relaxer.stop(); relaxer.prerelax(); } catch (java.lang.ClassCastException e) { e.printStackTrace(); } StaticLayout<Variable, Constraint> staticLayout = new StaticLayout<Variable, Constraint>(g, layout); lt = new LayoutTransition<Variable, Constraint>(vv, vv.getGraphLayout(), staticLayout); animator = new MyAnimator(lt); animator.start(); //vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.repaint(); } catch (Exception e) { e.printStackTrace(); } } }); //create a graphdraw //layout = new FRLayout<Variable,Constraint>(g); //layout = new SpringLayout<Variable,Constraint>(g); //layout = new StaticLayout<Variable,Constraint>(g,new STNTransformer()); layout = new FRLayout2<Variable, Constraint>(g); //layout = new CircleLayout<Variable,Constraint>(g); //layout = new ISOMLayout<Variable,Constraint>(g); //layout = new KKLayout<Variable,Constraint>(g); layout.setSize(new Dimension(600, 600)); try { Relaxer relaxer = new VisRunner((IterativeContext) layout); relaxer.stop(); relaxer.prerelax(); } catch (java.lang.ClassCastException e) { e.printStackTrace(); } Layout<Variable, Constraint> staticLayout = new StaticLayout<Variable, Constraint>(g, layout); vv = new VisualizationViewer<Variable, Constraint>(staticLayout, new Dimension(600, 600)); JRootPane rp = this.getRootPane(); rp.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE); getContentPane().setLayout(new BorderLayout()); getContentPane().setBackground(java.awt.Color.lightGray); getContentPane().setFont(new Font("Serif", Font.PLAIN, 12)); vv.setGraphMouse(new DefaultModalGraphMouse<Variable, Constraint>()); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.S); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Variable>()); vv.setForeground(Color.black); //draw edge labels Transformer<Constraint, String> stringer = new Transformer<Constraint, String>() { @Override public String transform(Constraint e) { try { return e.getEdgeLabel(); } catch (NullPointerException ex) { return ""; } } }; Transformer<Variable, Paint> vertexPaint = new Transformer<Variable, Paint>() { public Paint transform(Variable v) { return v.getColor(); } }; Transformer<Constraint, Paint> constraintPaint = new Transformer<Constraint, Paint>() { public Paint transform(Constraint c) { return c.getColor(); } }; vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); // vv.getRenderContext().setEdgeFillPaintTransformer(constraintPaint); vv.getRenderContext().setEdgeLabelTransformer(stringer); // vv.getRenderContext().setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Constraint>(vv.getPickedEdgeState(), Color.black, Color.cyan)); vv.getRenderContext().setEdgeDrawPaintTransformer(constraintPaint); vv.addComponentListener(new ComponentAdapter() { /** * @see java.awt.event.ComponentAdapter#componentResized(java.awt.event.ComponentEvent) */ @Override public void componentResized(ComponentEvent arg0) { super.componentResized(arg0); layout.setSize(arg0.getComponent().getSize()); } }); getContentPane().add(vv); performOperation = new JButton("Perform operation"); if (cb == null) performOperation.setEnabled(false); else performOperation.setEnabled(true); performOperation.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (cb != null) cb.performOperation(); } }); switchLayout = new JButton("Switch to SpringLayout"); switchLayout.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Dimension d = vv.getSize();//new Dimension(600,600); if (switchLayout.getText().indexOf("Spring") > 0) { switchLayout.setText("Switch to FRLayout"); //layout = new SpringLayout<Variable,Constraint>(g, new ConstantTransformer(EDGE_LENGTH)); layout = new SpringLayout<Variable, Constraint>(g); layout.setSize(d); try { Relaxer relaxer = new VisRunner((IterativeContext) layout); relaxer.stop(); relaxer.prerelax(); } catch (java.lang.ClassCastException e) { e.printStackTrace(); } StaticLayout<Variable, Constraint> staticLayout = new StaticLayout<Variable, Constraint>(g, layout); lt = new LayoutTransition<Variable, Constraint>(vv, vv.getGraphLayout(), staticLayout); Animator animator = new MyAnimator(lt); animator.start(); // vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.repaint(); } else { switchLayout.setText("Switch to SpringLayout"); layout = new FRLayout<Variable, Constraint>(g, d); layout.setSize(d); try { Relaxer relaxer = new VisRunner((IterativeContext) layout); relaxer.stop(); relaxer.prerelax(); } catch (java.lang.ClassCastException e) { } StaticLayout<Variable, Constraint> staticLayout = new StaticLayout<Variable, Constraint>(g, layout); lt = new LayoutTransition<Variable, Constraint>(vv, vv.getGraphLayout(), staticLayout); Animator animator = new MyAnimator(lt); animator.start(); //vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.repaint(); } } }); getContentPane().add(performOperation, BorderLayout.SOUTH); //getContentPane().add(switchLayout, BorderLayout.SOUTH); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.pack(); this.setVisible(true); }
From source file:ome.formats.importer.gui.GuiImporter.java
/** * Main entry class for the application/*w w w .j ava 2 s. c om*/ * * @param config - ImportConfig file */ public GuiImporter(ImportConfig config) { //super(TITLE); //javax.swing.ToolTipManager.sharedInstance().setDismissDelay(0); this.setConfig(config); this.bounds = config.getUIBounds(); Level level = org.apache.log4j.Level.toLevel(config.getDebugLevel()); LogAppender.setLoggingLevel(level); historyHandler = new HistoryHandler(this); setHistoryTable(historyHandler.table); // Add a shutdown hook for when app closes Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { log.debug("Running shutdown hook."); shutdown(); } }); // Set app defaults setTitle(config.getAppTitle()); setIconImage(GuiCommonElements.getImageIcon(GuiImporter.ICON).getImage()); setPreferredSize(new Dimension(bounds.width, bounds.height)); setSize(bounds.width, bounds.height); setLocation(bounds.x, bounds.y); setLayout(new BorderLayout()); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); pack(); addWindowListener(this); // capture move info addComponentListener(new ComponentAdapter() { public void componentMoved(ComponentEvent evt) { bounds = getBounds(); } }); // capture resize info addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent evt) { bounds = getBounds(); } }); // menu bar menubar = new JMenuBar(); fileMenu = new JMenu("File"); menubar.add(fileMenu); login = new JMenuItem("Login to the server...", GuiCommonElements.getImageIcon(LOGIN_ICON)); login.setActionCommand("login"); login.addActionListener(this); fileMenu.add(login); options = new JMenuItem("Options...", GuiCommonElements.getImageIcon(CONFIG_ICON)); options.setActionCommand("options"); options.addActionListener(this); fileMenu.add(options); fileQuit = new JMenuItem("Quit", GuiCommonElements.getImageIcon(QUIT_ICON)); fileQuit.setActionCommand("quit"); fileQuit.addActionListener(this); fileMenu.add(fileQuit); helpMenu = new JMenu("Help"); menubar.add(helpMenu); helpComment = new JMenuItem("Send a Comment...", GuiCommonElements.getImageIcon(COMMENT_ICON)); helpComment.setActionCommand("comment"); helpComment.addActionListener(this); helpHome = new JMenuItem("Visit Importer Homepage...", GuiCommonElements.getImageIcon(HOME_ICON)); helpHome.setActionCommand("home"); helpHome.addActionListener(this); helpForums = new JMenuItem("Visit the OMERO Forums...", GuiCommonElements.getImageIcon(FORUM_ICON)); helpForums.setActionCommand("forums"); helpForums.addActionListener(this); helpAbout = new JMenuItem("About the Importer...", GuiCommonElements.getImageIcon(ABOUT_ICON)); helpAbout.setActionCommand("about"); helpAbout.addActionListener(this); helpMenu.add(helpComment); helpMenu.add(helpHome); helpMenu.add(helpForums); // Help --> Show log file location... JMenuItem helpShowLog = new JMenuItem("Show log file location...", GuiCommonElements.getImageIcon(LOGFILE_ICON)); helpShowLog.setActionCommand(show_log_file); helpShowLog.addActionListener(this); helpMenu.add(helpShowLog); helpMenu.add(helpAbout); // Help --> About setJMenuBar(menubar); // tabbed panes tPane = new JTabbedPane(); tPane.setOpaque(false); // content panes must be opaque // file chooser pane JPanel filePanel = new JPanel(new BorderLayout()); setStatusBar(new StatusBar()); getStatusBar().setStatusIcon("gfx/server_disconn16.png", "Server disconnected."); getStatusBar().setProgress(false, 0, ""); this.getContentPane().add(getStatusBar(), BorderLayout.SOUTH); // The file chooser sub-pane setFileQueueHandler(new FileQueueHandler(scanEx, importEx, this, config)); //splitPane.setResizeWeight(0.5); filePanel.add(getFileQueueHandler(), BorderLayout.CENTER); tPane.addTab("File Chooser", GuiCommonElements.getImageIcon(CHOOSER_ICON), filePanel, "Add and delete images here to the import queue."); tPane.setMnemonicAt(0, KeyEvent.VK_1); // history pane historyPanel = new JPanel(); historyPanel.setOpaque(false); historyPanel.setLayout(new BorderLayout()); tPane.addTab("Import History", GuiCommonElements.getImageIcon(HISTORY_ICON), historyPanel, "Import history is displayed here."); tPane.setMnemonicAt(0, KeyEvent.VK_4); // output text pane JPanel outputPanel = new JPanel(); outputPanel.setLayout(new BorderLayout()); outputTextPane = new JTextPane(); outputTextPane.setEditable(false); JScrollPane outputScrollPane = new JScrollPane(); outputScrollPane.getViewport().add(outputTextPane); outputScrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { try { outputTextPane.setCaretPosition(outputTextPane.getDocument().getLength()); } catch (IllegalArgumentException e1) { log.error("Error setting cursor:" + e1); } } }); outputPanel.add(outputScrollPane, BorderLayout.CENTER); tPane.addTab("Output Text", GuiCommonElements.getImageIcon(OUTPUT_ICON), outputPanel, "Standard output text goes here."); tPane.setMnemonicAt(0, KeyEvent.VK_2); // debug pane JPanel debugPanel = new JPanel(); debugPanel.setLayout(new BorderLayout()); debugTextPane = new JTextPane(); debugTextPane.setEditable(false); JScrollPane debugScrollPane = new JScrollPane(); debugScrollPane.getViewport().add(debugTextPane); debugScrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { try { debugTextPane.setCaretPosition(debugTextPane.getDocument().getLength()); } catch (IllegalArgumentException e1) { log.error("Error setting cursor:" + e1); } } }); debugPanel.add(debugScrollPane, BorderLayout.CENTER); tPane.addTab("Debug Text", GuiCommonElements.getImageIcon(BUG_ICON), debugPanel, "Debug messages are displayed here."); tPane.setMnemonicAt(0, KeyEvent.VK_3); // Error Pane errorPanel = new JPanel(); errorPanel.setOpaque(false); errorPanel.setLayout(new BorderLayout()); tPane.addTab("Import Errors", GuiCommonElements.getImageIcon(ERROR_ICON), errorPanel, "Import errors are displayed here."); tPane.setMnemonicAt(0, KeyEvent.VK_5); tPane.setSelectedIndex(0); if (getHistoryTable().db.historyEnabled == false) tPane.setEnabledAt(historyTabIndex, false); // Add the tabbed pane to this panel. add(tPane); this.setVisible(false); historyPanel.add(historyHandler, BorderLayout.CENTER); tPane.setEnabledAt(historyTabIndex, false); setLoginHandler(new LoginHandler(this, getHistoryTable())); LogAppender.getInstance().setTextArea(debugTextPane); appendToOutputLn("> Starting the importer (revision " + getPrintableKeyword(Version.revision) + ")."); appendToOutputLn("> Build date: " + getPrintableKeyword(Version.revisionDate)); appendToOutputLn("> Release date: " + Version.releaseDate); // TODO : should this be a third executor? setErrorHandler(new ErrorHandler(importEx, config)); getErrorHandler().addObserver(this); errorPanel.add(getErrorHandler(), BorderLayout.CENTER); macMenuFix(); //displayLoginDialog(this, true); }
From source file:com.tag.FramePreferences.java
public void install() { windowStateListener = new WindowStateListener() { public void windowStateChanged(WindowEvent e) { Object source = e.getSource(); if (source instanceof JFrame) { JFrame frame = (JFrame) source; int extendedState = frame.getExtendedState(); if (extendedState == JFrame.ICONIFIED) return; Preferences prefs = getPreferences(); prefs.putInt(KEY_EXTENDED_STATE, extendedState); }/* ww w . ja v a2 s .co m*/ } }; frame.addWindowStateListener(windowStateListener); componentListener = new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { Preferences prefs = getPreferences(); Dimension size = frame.getSize(); prefs.putInt(KEY_WIDTH, size.width); prefs.putInt(KEY_HEIGHT, size.height); } @Override public void componentMoved(ComponentEvent e) { Preferences prefs = getPreferences(); Point location = frame.getLocation(); prefs.putInt(KEY_X, location.x); prefs.putInt(KEY_Y, location.y); } }; frame.addComponentListener(componentListener); }
From source file:com.intel.stl.ui.common.view.ChartsView.java
@Override protected JComponent getMainComponent() { if (mainPanel == null) { mainPanel = new JPanel(new BorderLayout(0, 0)); mainPanel.setOpaque(false);//from w w w . j a v a2 s. co m mainPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); chartPanel = new JumpChartPanel(null); chartPanel.setOpaque(false); chartPanel.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { chartPanel.setMaximumDrawHeight(e.getComponent().getHeight()); chartPanel.setMaximumDrawWidth(e.getComponent().getWidth()); chartPanel.setMinimumDrawWidth(e.getComponent().getWidth()); chartPanel.setMinimumDrawHeight(e.getComponent().getHeight()); } }); mainPanel.add(chartPanel, BorderLayout.CENTER); } return mainPanel; }
From source file:org.isatools.isacreatorconfigurator.ontologyconfigurationtool.OntologyConfigUI.java
public void createGUI() { HUDTitleBar titlePanel = new HUDTitleBar(null, null, true); add(titlePanel, BorderLayout.NORTH); titlePanel.installListeners();/*from w w w . java2 s. c om*/ titlePanel.addPropertyChangeListener("windowClosed", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { firePropertyChange("ontologyClosed", "", "closed"); } }); // create left panel with list of selected ontology terms and Expandable panel createOntologySelectionPanel(); // create right panel containing tree showing the entirety of the ontology selected from the left pane. JPanel ontologySelectionPanel = new JPanel(new BorderLayout()); ontologyViewContainer = new JPanel(new BorderLayout()); ontologyViewContainer.setPreferredSize(new Dimension(500, 300)); // add placeholder panel by default with some image describing what to do setOntologySelectionPanelPlaceholder(infoImage); ontologyViewContainer.setBorder(new TitledBorder(new RoundedBorder(UIHelper.LIGHT_GREEN_COLOR, 7), "browse ontology", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR)); ontologySelectionPanel.add(ontologyViewContainer, BorderLayout.CENTER); ontologySelectionPanel.add(Box.createVerticalStrut(20), BorderLayout.SOUTH); add(ontologySelectionPanel, BorderLayout.CENTER); JPanel functionWrapper = new JPanel(new BorderLayout()); searchAndTermDefinitionViewer = new SearchAndDefinitionUI(); searchAndTermDefinitionViewer.setBorder(new TitledBorder(new RoundedBorder(UIHelper.LIGHT_GREEN_COLOR, 7), "functions", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR)); functionWrapper.add(searchAndTermDefinitionViewer); functionWrapper.add(createButtonPanel(), BorderLayout.SOUTH); add(functionWrapper, BorderLayout.EAST); this.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent componentEvent) { if (currentlyActiveBrowser != null && currentlyActiveBrowser.isShowing()) { ontologyViewContainer.setPreferredSize(getMaxBrowserSize()); currentlyActiveBrowser.setBrowserSize(getMaxBrowserSize()); ontologyViewContainer.repaint(); currentlyActiveBrowser.repaint(); } } }); FooterPanel footer = new FooterPanel(this); add(footer, BorderLayout.SOUTH); pack(); setVisible(true); }
From source file:de.mprengemann.intellij.plugin.androidicons.dialogs.IconImporter.java
public IconImporter(Project project, Module module) { super(project, true); this.project = project; this.module = module; final IconApplication container = ApplicationManager.getApplication().getComponent(IconApplication.class); androidIconsController = container.getControllerFactory().getAndroidIconsController(); materialIconsController = container.getControllerFactory().getMaterialIconsController(); settingsController = container.getControllerFactory().getSettingsController(); defaultsController = container.getControllerFactory().getDefaultsController(); controller = new IconsImporterController(defaultsController, androidIconsController, materialIconsController);/* ww w. j a v a2 s .c o m*/ initResRoot(); setTitle("Icon Pack Drawable Importer"); getHelpAction().setEnabled(true); AssetSpinnerRenderer renderer = new AssetSpinnerRenderer(); //noinspection GtkPreferredJComboBoxRenderer assetSpinner.setRenderer(renderer); imageContainer.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { super.componentResized(e); updateImage(); } }); initCheckBoxes(); initSearch(); controller.addObserver(this); init(); pack(); }