List of usage examples for java.awt.event WindowAdapter WindowAdapter
WindowAdapter
From source file:com.wet.wired.jsr.recorder.JRecorder.java
private void showWindow() { this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { closeRecorder();// w w w .j a v a2 s . c o m System.exit(0); } }); setTitle("TestingOwl Recorder"); setIconImage(owl.getWelcomeIcon().getImage()); getContentPane().removeAll(); GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); this.getContentPane().setLayout(gbl); control = new JButton("Start Recording"); control.setActionCommand("start"); control.addActionListener(this); gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 1; gbc.weighty = 1; this.getContentPane().add(control, gbc); decorator.getButtonsAndSoundLevel(this.getContentPane(), gbc); player = new JButton("to Player"); player.setActionCommand("player"); player.addActionListener(this); gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 5; gbc.gridy = 0; gbc.weightx = 1; gbc.weighty = 1; this.getContentPane().add(player, gbc); text = new JLabel("Ready to record"); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = 0; gbc.gridy = 1; gbc.weightx = 1; gbc.weighty = 0; gbc.gridwidth = 5; this.getContentPane().add(text, gbc); getContentPane().doLayout(); this.pack(); this.setAlwaysOnTop(true); this.setVisible(true); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.ImageFrame.java
/** * Constructor. //from w w w .j a v a 2s .c om */ public ImageFrame(final int mapSize, final WorkbenchPaneSS wbPane, final Workbench workbench, final Taskable task, final boolean isReadOnly) { this.wbPane = wbPane; this.workbench = workbench; try { this.workbenchTask = (WorkbenchTask) task; } catch (ClassCastException e) { this.workbenchTask = null; } this.allowCloseWindow = true; this.defaultThumbIcon = IconManager.getIcon("image", IconSize.Std32); setIconImage(IconManager.getImage("AppIcon").getImage()); setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { if (allowCloseWindow) { wbPane.toggleImageFrameVisible(); } } }); Dimension minSize = new Dimension(mapSize, mapSize); cardImageLabel.setHorizontalTextPosition(SwingConstants.CENTER); PanelBuilder builder = new PanelBuilder(new FormLayout("f:p:g,c:p,f:p:g", "f:p:g,p,5px,p,f:p:g")); CellConstraints cc = new CellConstraints(); loadImgBtn = createButton(getResourceString("WB_LOAD_NEW_IMAGE")); builder.add(createLabel(getResourceString("WB_NO_IMAGE_ROW"), SwingConstants.CENTER), cc.xy(2, 2)); builder.add(loadImgBtn, cc.xy(2, 4)); loadImgBtn.setVisible(!isReadOnly); noCardImageMessagePanel = builder.getPanel(); noCardImageMessagePanel.setPreferredSize(minSize); noCardImageMessagePanel.setSize(minSize); builder = new PanelBuilder(new FormLayout("f:p:g,c:p,f:p:g", "f:p:g,c:p,f:p:g")); builder.add(createLabel(getResourceString("WB_NO_ROW_SELECTED"), SwingConstants.CENTER), cc.xy(2, 2)); noRowSelectedMessagePanel = builder.getPanel(); noRowSelectedMessagePanel.setPreferredSize(minSize); noRowSelectedMessagePanel.setSize(minSize); mainPane = new JPanel(new BorderLayout()); mainPane.setSize(minSize); mainPane.setPreferredSize(minSize); mainPane.setMinimumSize(minSize); mainPane.add(cardImageLabel, BorderLayout.CENTER); scrollPane = new JScrollPane(mainPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); statusBar = new JStatusBar(); thumbnailer = new ImageThumbnailGenerator(); thumbnailer.setMaxSize(256, 256); thumbnailer.setQuality(1); tray = new ThumbnailTray(); tray.getModel().removeAllElements(); tray.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } setImageIndex(tray.getSelectedIndex()); } }); JPanel southPanel = new JPanel(); southPanel.setLayout(new BorderLayout()); //southPanel.add(indexSlider,BorderLayout.NORTH); southPanel.add(tray, BorderLayout.CENTER); southPanel.add(statusBar, BorderLayout.SOUTH); JPanel basePanel = new JPanel(); basePanel.setLayout(new BorderLayout()); basePanel.add(scrollPane, BorderLayout.CENTER); basePanel.add(southPanel, BorderLayout.SOUTH); setContentPane(basePanel); JMenuBar menuBar = new JMenuBar(); String title = "FileMenu"; String mneu = "FileMneu"; JMenu fileMenu = UIHelper.createLocalizedMenu(menuBar, title, mneu); title = "WB_IMPORT_CARDS_TO_DATASET"; mneu = "WB_IMPORT_CARDS_MNEU"; if (!isReadOnly) { JMenuItem importImagesMI = UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, null); importImagesMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { importImages(); } }); } /* title = "ImageFrame.CLOSE"; mneu = "ImageFrame.CloseMneu"; closeMI = UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, null); closeMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { ImageFrame.this.setVisible(false); } });*/ title = "ImageFrame.View"; mneu = "ImageFrame.ViewMneu"; viewMenu = UIHelper.createLocalizedMenu(menuBar, title, mneu); reduceMI = UIHelper.createRadioButtonMenuItem(viewMenu, "WB_REDUCED_SIZE", "ImageFrame.ReducedSizeMneu", "", true, null); reduceMI.setSelected(true); reduceMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (row == null) { return; } // simply 'remember' that we want to show reduced images for this row rowToImageSizeHash.put(row.hashCode(), REDUCED_SIZE); // then 'reshow' the current image showImage(); } }); origMI = UIHelper.createRadioButtonMenuItem(viewMenu, "WB_ORIG_SIZE", "ImageFrame.OrigMneu", "", true, null); origMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (row == null) { return; } // simply 'remember' that we want to show fill size images for this row rowToImageSizeHash.put(row.hashCode(), FULL_SIZE); // then 'reshow' the current image showImage(); } }); ButtonGroup btnGrp = new ButtonGroup(); btnGrp.add(reduceMI); btnGrp.add(origMI); viewMenu.addSeparator(); alwaysOnTopMI = UIHelper.createCheckBoxMenuItem(viewMenu, "WB_ALWAYS_ON_TOP", null, "", true, null); alwaysOnTopMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { ImageFrame.this.setAlwaysOnTop(alwaysOnTopMI.isSelected()); } }); addPropertyChangeListener("alwaysOnTop", this); if (!isReadOnly) { ActionListener deleteImg = new ActionListener() { public void actionPerformed(ActionEvent ae) { deleteImage(); } }; ActionListener replaceImg = new ActionListener() { public void actionPerformed(ActionEvent ae) { replaceImage(); } }; ActionListener addImg = new ActionListener() { public void actionPerformed(ActionEvent ae) { addImages(); } }; title = "ImageFrame.Image"; mneu = "ImageFrame.ImageMneu"; imageMenu = UIHelper.createLocalizedMenu(menuBar, title, mneu); title = "WB_ADD_IMG"; mneu = "WB_ADD_IMG_MNEM"; addMI = UIHelper.createLocalizedMenuItem(imageMenu, title, mneu, "", true, addImg); title = "WB_REPLACE_IMG"; mneu = "WB_REPLACE_IMG_MNEU"; replaceMI = UIHelper.createLocalizedMenuItem(imageMenu, title, mneu, "", true, replaceImg); title = "WB_DEL_IMG_LINK"; mneu = "WB_DEL_IMG_LINK_MNEU"; deleteMI = UIHelper.createLocalizedMenuItem(imageMenu, title, mneu, "", true, deleteImg); loadImgBtn.addActionListener(addImg); } JMenu helpMenu = new JMenu(getResourceString("HELP")); menuBar.add(HelpMgr.createHelpMenuItem(helpMenu, getResourceString("WB_IMAGE_WINDOW"))); enableMenus(false); setJMenuBar(menuBar); pack(); HelpMgr.setHelpID(this, "WorkbenchWorkingWithImages"); }
From source file:com.att.aro.ui.view.menu.tools.RegexWizard.java
public void init() { GoogleAnalyticsUtil.getGoogleAnalyticsInstance().sendViews("VideoParserWizard"); setDefaultCloseOperation(RegexWizard.DISPOSE_ON_CLOSE); enableCheckBoxes(true);//from www . ja va2 s .com this.setSize(815, 800); this.setMaximumSize(new Dimension(815, 800)); this.setMinimumSize(new Dimension(815, 700)); this.setModal(false); this.setTitle(resourceBundle.getString("videoParser.wizard.title")); this.setLocationRelativeTo(getOwner()); this.setAlwaysOnTop(true); this.setResizable(false); setLayout(new GridBagLayout()); GridBagConstraints constraint = new GridBagConstraints(); constraint.fill = GridBagConstraints.BOTH; constraint.gridx = 0; constraint.gridy = 0; constraint.weightx = 1; constraint.weighty = 0.6; constraint.gridwidth = 2; add(getFieldPanel(), constraint); constraint.gridy = 1; constraint.gridwidth = 1; constraint.weighty = 0.38; constraint.weightx = 0.4; constraint.insets = new Insets(0, 2, 0, 5); add(getMatcherPanel(), constraint); constraint.weightx = 0.5; constraint.gridx = 1; constraint.insets = new Insets(0, 1, 0, 2); add(getResultPanel(), constraint); constraint.weightx = 1; constraint.gridy = 2; constraint.gridx = 0; constraint.weighty = 0.02; constraint.gridwidth = 2; add(getBottomPanel(), constraint); this.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent e) { clear(); } }); pack(); }
From source file:com.github.benchdoos.weblocopener.updater.gui.UpdateDialog.java
private void createGUI() { setContentPane(contentPane);//from w ww . java 2s . c om getRootPane().setDefaultButton(buttonOK); if (IS_WINDOWS_XP) { //for windows xp&server 2003 setIconImage(Toolkit.getDefaultToolkit() .getImage(UpdateDialog.class.getResource("/images/updaterIcon64_white.png"))); } else { setIconImage(Toolkit.getDefaultToolkit() .getImage(UpdateDialog.class.getResource("/images/updaterIcon64.png"))); } createDefaultActionListeners(); // call onCancel() when cross is clicked setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { onCancel(); } }); // call onCancel() on ESCAPE contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); updateInfoButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { onUpdateInfoButton(); } }); updateInfoButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); manualDownloadButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openSetupUrl(); } private void openSetupUrl() { log.debug("Calling to download setup manually"); URL url = null; if (updater != null) { if (updater.getAppVersion() != null) { try { log.debug("Trying to open [" + updater.getAppVersion().getDownloadUrl() + "]"); url = new URL(updater.getAppVersion().getDownloadUrl()); UrlValidator urlValidator = new UrlValidator(); UserUtils.openWebUrl(url); } catch (MalformedURLException e1) { openWebsite(url); } } else UserUtils.openWebUrl(ApplicationConstants.UPDATE_WEB_URL); } else UserUtils.openWebUrl(ApplicationConstants.UPDATE_WEB_URL); } private void openWebsite(URL url) { log.warn("Could not open setup url: [" + url + "]\n" + "Opening " + ApplicationConstants.UPDATE_WEB_URL); UserUtils.openWebUrl(ApplicationConstants.UPDATE_WEB_URL); } }); pack(); setLocation(FrameUtils.getFrameOnCenterLocationPoint(this)); setSize(new Dimension(400, 170)); setResizable(false); }
From source file:com.titan.mainframe.MainFrame.java
public MainFrame() { String osName = System.getProperty("os.name").toLowerCase(); if (osName.toLowerCase().contains("mac")) { com.apple.eawt.Application macApp = com.apple.eawt.Application.getApplication(); macApp.addApplicationListener(this); }//w ww . j a va 2 s.c o m addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { handleQuit(); } @Override public void windowOpened(WindowEvent e) { windowOpened = true; } }); setTitle("Titan " + Global.version); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); if (TitanSetting.getInstance().width == 0 || TitanSetting.getInstance().height == 0) { setBounds(TitanSetting.getInstance().x, TitanSetting.getInstance().y, 1200, 700); } else { setBounds(TitanSetting.getInstance().x, TitanSetting.getInstance().y, TitanSetting.getInstance().width, TitanSetting.getInstance().height); } setIconImage(new ImageIcon(getClass().getClassLoader().getResource("com/titan/image/titan_icon.png")) .getImage()); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(new BorderLayout(0, 0)); splitPane.setDividerLocation(TitanSetting.getInstance().mainframeDivX); contentPane.add(splitPane, BorderLayout.CENTER); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout(0, 0)); JLabel logoLabel = new JLabel(); logoLabel.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { mainContentPanel.removeAll(); mainContentPanel.add(welcomePanel, BorderLayout.CENTER); mainContentPanel.updateUI(); } }); // try { // BufferedImage b = ImageIO.read(MainFrame.class.getResource("/com/titan/image/titanLogo.png")); // Image i = b.getScaledInstance((int) (b.getWidth() * 0.6), (int) (b.getHeight() * 0.6), Image.SCALE_SMOOTH); logoLabel.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/titanLogo.png"))); // } catch (IOException e1) { // e1.printStackTrace(); // } // logoLabel.setMaximumSize(new Dimension(150, 150)); JPanel controlPanel = new JPanel(); controlPanel.setBackground(new Color(239, 249, 255)); controlPanel.setOpaque(true); panel.add(controlPanel, BorderLayout.CENTER); controlPanel.setLayout(new BorderLayout()); JScrollPane computeScrollPane = new JScrollPane(); tabbedPane.addTab("Compute", computeScrollPane); controlPanel.add(tabbedPane, BorderLayout.CENTER); serverTree = new JTree(); serverTree.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { // Object obj = mainContentPanel.getComponent(0); // if (obj instanceof VMMainPanel) { // ((MainPanel) obj).refresh(); // } } }); serverTree.setModel(computeTreeModel); serverTree.setCellRenderer(new ZoneTreeRenderer()); serverTree.setRootVisible(false); computeScrollPane.setViewportView(serverTree); updateComputeTree(); JScrollPane zoneScrollPane = new JScrollPane(); tabbedPane.addTab("Zone", zoneScrollPane); zoneTree = new JTree(); zoneTree.setModel(zoneTreeModel); zoneTree.setCellRenderer(new ZoneTreeRenderer()); zoneScrollPane.setViewportView(zoneTree); updateZoneTree(); splitPane.setLeftComponent(panel); splitPane.setRightComponent(mainContentPanel); mainContentPanel.setLayout(new BorderLayout(0, 0)); welcomePanel = new WelcomePanel(); mainContentPanel.add(welcomePanel, BorderLayout.CENTER); welcomePanel.setLayout(new BorderLayout(0, 0)); welcomePanel.add(mainScreenLabel, BorderLayout.CENTER); mainScreenLabel.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/mainscreen.png"))); JPanel panel_1 = new JPanel(); welcomePanel.add(panel_1, BorderLayout.SOUTH); JButton licenseButton = new JButton("License"); licenseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { InputStream in = MainFrame.class.getResourceAsStream("/com/titan/license.txt"); try { LicenseDialog dialog = new LicenseDialog(MainFrame.this, IOUtils.toString(in)); CommonLib.centerDialog(dialog); dialog.setVisible(true); } catch (IOException e1) { e1.printStackTrace(); } finally { IOUtils.closeQuietly(in); } } }); panel_1.add(licenseButton); ribbonPanel = new JPanel(); contentPane.add(ribbonPanel, BorderLayout.NORTH); ribbonPanel.setLayout(new BorderLayout(0, 0)); ribbonTabbedPane = new JTabbedPane(JTabbedPane.TOP); ribbonTabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { // if (!windowOpened) { // return; // } String tab = ribbonTabbedPane.getTitleAt(ribbonTabbedPane.getSelectedIndex()); if (tab.equals("Server")) { if (mainServerPanel == null || !mainServerPanel.serverPanel.jprogressBarDialog.isActive()) { SwingUtilities.invokeLater(new Runnable() { public void run() { mainContentPanel.removeAll(); mainServerPanel = new MainServerPanel(MainFrame.this); mainContentPanel.add(mainServerPanel, BorderLayout.CENTER); mainContentPanel.updateUI(); } }); } } else if (tab.equals("VM")) { SwingUtilities.invokeLater(new Runnable() { public void run() { mainContentPanel.removeAll(); mainContentPanel.add(new VMMainPanel(MainFrame.this), BorderLayout.CENTER); mainContentPanel.updateUI(); } }); } else if (tab.equals("Keystone")) { mainContentPanel.removeAll(); mainContentPanel.add(new KeystonePanel(MainFrame.this), BorderLayout.CENTER); mainContentPanel.updateUI(); } else if (tab.equals("Flavor")) { mainContentPanel.removeAll(); mainContentPanel.add(new FlavorPanel(MainFrame.this), BorderLayout.CENTER); mainContentPanel.updateUI(); } else if (tab.equals("Storage")) { mainContentPanel.removeAll(); mainContentPanel.add(new StoragePanel(MainFrame.this), BorderLayout.CENTER); mainContentPanel.updateUI(); } else if (tab.equals("Network")) { mainContentPanel.removeAll(); mainContentPanel.add(new SDNPanel(MainFrame.this), BorderLayout.CENTER); mainContentPanel.updateUI(); } else if (tab.equals("Setting")) { mainContentPanel.removeAll(); mainContentPanel.add(new SettingPanel(MainFrame.this), BorderLayout.CENTER); mainContentPanel.updateUI(); } } }); ribbonTabbedPane.putClientProperty("type", "ribbonType"); ribbonTabbedPane.setPreferredSize(new Dimension(1000, 140)); ribbonPanel.add(ribbonTabbedPane, BorderLayout.CENTER); serverPanel = new JRibbonPanel(); serverPanel.setLayout(new MigLayout("", "[][][][][][][][][][][][][][grow][]", "[grow][grow][]")); ribbonTabbedPane.addTab("Server", null, serverPanel, null); logoutButton = new JRibbonBigButton("Logout"); logoutButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { logout(); } }); rbnbgbtnAddServer = new JRibbonBigButton(); rbnbgbtnAddServer.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/add.png"))); rbnbgbtnAddServer.setText("Add Server"); serverPanel.add(rbnbgbtnAddServer, "cell 0 0 1 3,growy"); rbnbgbtnDeleteServer = new JRibbonBigButton(); rbnbgbtnDeleteServer .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/delete.png"))); rbnbgbtnDeleteServer.setText("Delete Server"); serverPanel.add(rbnbgbtnDeleteServer, "cell 1 0 1 3,growy"); logoutButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/logout.png"))); logoutButton.setVerticalTextPosition(SwingConstants.BOTTOM); logoutButton.setHorizontalTextPosition(SwingConstants.CENTER); serverPanel.add(logoutButton, "cell 14 0 1 3,growy"); vmPanel = new JRibbonPanel(); ribbonTabbedPane.addTab("VM", null, vmPanel, null); vmPanel.setLayout(new MigLayout("", "[][][][][][][][][][][][][][][grow][]", "[grow][grow][]")); launchButton = new JRibbonBigButton("Launch"); launchButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new LaunchInstanceDialog(MainFrame.this).setVisible(true); } }); launchButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/launch.png"))); launchButton.setVerticalTextPosition(SwingConstants.BOTTOM); launchButton.setHorizontalTextPosition(SwingConstants.CENTER); vmPanel.add(launchButton, "cell 0 0 1 3,growy"); pauseButton = new JRibbonButton("Pause"); pauseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.action("from titan: nova pause"); } }); pauseButton.setHorizontalAlignment(SwingConstants.LEFT); pauseButton.setIcon( new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/control_pause.png"))); vmPanel.add(pauseButton, "cell 2 0,growx"); stopButton = new JRibbonButton("Stop"); stopButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.action("from titan: nova stop"); } }); stopButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/stop.png"))); stopButton.setVerticalTextPosition(SwingConstants.BOTTOM); stopButton.setHorizontalTextPosition(SwingConstants.CENTER); vmPanel.add(stopButton, "cell 1 0 1 3,growy"); unpauseButton = new JRibbonButton("Unpause"); unpauseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.action("from titan: nova unpause"); } }); unpauseButton.setHorizontalAlignment(SwingConstants.LEFT); unpauseButton .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/control_play.png"))); suspendButton = new JRibbonButton("Suspend"); suspendButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.action("from titan: nova suspend"); } }); suspendButton.setHorizontalAlignment(SwingConstants.LEFT); suspendButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/disk.png"))); vmPanel.add(suspendButton, "cell 3 0,growx"); softRebootButton = new JRibbonButton("Soft reboot"); softRebootButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.action("from titan: nova soft-reboot"); } }); softRebootButton.setHorizontalAlignment(SwingConstants.LEFT); softRebootButton.setIcon(new ImageIcon( MainFrame.class.getResource("/com/titan/image/famfamfam/arrow_rotate_clockwise.png"))); selectAllVMButton = new JRibbonButton("Select all"); selectAllVMButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.selectAll(); } }); vmPanel.add(selectAllVMButton, "cell 4 0,growx"); vmPanel.add(softRebootButton, "cell 9 0,growx"); createMacroButton = new JRibbonButton("Create macro"); createMacroButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/add.png"))); createMacroButton.setHorizontalAlignment(SwingConstants.LEFT); setGroupNameButton = new JRibbonButton("Set group name"); setGroupNameButton.setHorizontalAlignment(SwingConstants.LEFT); setGroupNameButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.setGroupName(); } }); vmPanel.add(setGroupNameButton, "cell 10 0"); vmPanel.add(createMacroButton, "cell 13 0,growx"); ribbonSeparator_3 = new JRibbonSeparator(); vmPanel.add(ribbonSeparator_3, "cell 14 0 1 3,growy"); vmPanel.add(unpauseButton, "cell 2 1,growx"); remoteButton = new JRibbonButton("Remote"); remoteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.remote(); } }); remoteButton.setHorizontalAlignment(SwingConstants.LEFT); remoteButton.setIcon(new ImageIcon( MainFrame.class.getResource("/com/titan/image/famfamfam/application_osx_terminal.png"))); unselectAllButton = new JRibbonButton("Unselect all"); unselectAllButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.unselectAll(); } }); vmPanel.add(unselectAllButton, "cell 4 1,growx"); vmPanel.add(remoteButton, "cell 2 2,growx"); performanceMeterButton = new JRibbonButton("Performance meter"); performanceMeterButton .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/chart_curve.png"))); performanceMeterButton.setHorizontalAlignment(SwingConstants.LEFT); vmPanel.add(performanceMeterButton, "cell 13 1,growx"); resumeButton = new JRibbonButton("Resume"); resumeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.action("from titan: nova resume"); } }); resumeButton.setHorizontalAlignment(SwingConstants.LEFT); resumeButton .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/drive_disk.png"))); vmPanel.add(resumeButton, "cell 3 1,growx"); deleteButton = new JRibbonBigButton("Delete"); deleteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.action("from titan: nova delete"); } }); vmPanel.add(deleteButton, "cell 7 0 1 3,alignx center,growy"); deleteButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/delete.png"))); deleteButton.setVerticalTextPosition(SwingConstants.BOTTOM); deleteButton.setHorizontalTextPosition(SwingConstants.CENTER); logButton = new JRibbonBigButton("Log"); logButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.log(); } }); vmPanel.add(logButton, "cell 6 0 1 3,alignx center,growy"); logButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/log.png"))); logButton.setVerticalTextPosition(SwingConstants.BOTTOM); logButton.setHorizontalTextPosition(SwingConstants.CENTER); hardRebootButton = new JRibbonButton("Hard reboot"); hardRebootButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.action("from titan: nova hard-reboot"); } }); hardRebootButton.setHorizontalAlignment(SwingConstants.LEFT); hardRebootButton .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/arrow_undo.png"))); ribbonSeparator = new JRibbonSeparator(); vmPanel.add(ribbonSeparator, "cell 5 0 1 3,alignx center,growy"); ribbonSeparator_1 = new JRibbonSeparator(); vmPanel.add(ribbonSeparator_1, "cell 8 0 1 3,alignx center,growy"); vmPanel.add(hardRebootButton, "cell 9 1,growx"); ribbonSeparator_2 = new JRibbonSeparator(); vmPanel.add(ribbonSeparator_2, "cell 11 0 1 3,grow"); macroButton = new JRibbonBigButton("Macro"); macroButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/code.png"))); macroButton.setVerticalTextPosition(SwingConstants.BOTTOM); macroButton.setHorizontalTextPosition(SwingConstants.CENTER); vmPanel.add(macroButton, "cell 12 0 1 3,growy"); snapshotButton = new JRibbonButton("Snapshot"); snapshotButton.setHorizontalAlignment(SwingConstants.LEFT); snapshotButton.setIcon( new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/application_cascade.png"))); vmPanel.add(snapshotButton, "cell 3 2,growx"); advanceButton = new JRibbonButton("Advance"); advanceButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); advanceButton.setHorizontalAlignment(SwingConstants.LEFT); advanceButton.setIcon(new ImageIcon( MainFrame.class.getResource("/com/titan/image/famfamfam/application_view_detail.png"))); vmPanel.add(advanceButton, "cell 9 2,growx"); executionMapButton = new JRibbonButton("Execution map"); executionMapButton.setIcon( new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/chart_organisation.png"))); executionMapButton.setHorizontalAlignment(SwingConstants.LEFT); vmPanel.add(executionMapButton, "cell 13 2,growx"); keystonePanel = new JRibbonPanel(); ribbonTabbedPane.addTab("Keystone", null, keystonePanel, null); keystonePanel.setLayout(new MigLayout("", "[][][][][][][][][][]", "[grow][][][][]")); addUserButton = new JRibbonBigButton("Add user"); addUserButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0); keystonePanel.addUser(); } }); addUserButton.setVerticalTextPosition(SwingConstants.BOTTOM); addUserButton.setHorizontalTextPosition(SwingConstants.CENTER); addUserButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/addUser.png"))); keystonePanel.add(addUserButton, "cell 0 0 1 3,growy"); editUserButton = new JRibbonButton("Edit user"); editUserButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); editUserButton.setHorizontalAlignment(SwingConstants.LEFT); editUserButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/pencil.png"))); keystonePanel.add(editUserButton, "cell 1 0,growx"); changePasswordButton = new JRibbonButton("Change password"); keystonePanel.add(changePasswordButton, "cell 2 0"); ribbonSeparator_4 = new JRibbonSeparator(); keystonePanel.add(ribbonSeparator_4, "cell 3 0 1 3,growy"); addRoleButton = new JRibbonBigButton("Add role"); addRoleButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0); keystonePanel.addRole(); } }); addRoleButton.setVerticalTextPosition(SwingConstants.BOTTOM); addRoleButton.setHorizontalTextPosition(SwingConstants.CENTER); addRoleButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/addRole.png"))); keystonePanel.add(addRoleButton, "cell 4 0 1 3,growy"); deleteUserButton = new JRibbonButton("Delete user"); deleteUserButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); deleteUserButton.setHorizontalAlignment(SwingConstants.LEFT); deleteUserButton .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png"))); editRoleButton = new JRibbonButton("Edit role"); editRoleButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); editRoleButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/pencil.png"))); editRoleButton.setHorizontalAlignment(SwingConstants.LEFT); keystonePanel.add(editRoleButton, "cell 5 0,growx"); ribbonSeparator_5 = new JRibbonSeparator(); keystonePanel.add(ribbonSeparator_5, "cell 6 0 1 3,growy"); createTenantButton = new JRibbonBigButton("Create tenant"); createTenantButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0); keystonePanel.createTenant(); } }); createTenantButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/add.png"))); createTenantButton.setVerticalTextPosition(SwingConstants.BOTTOM); createTenantButton.setHorizontalTextPosition(SwingConstants.CENTER); keystonePanel.add(createTenantButton, "cell 7 0 1 3,growy"); deleteTenantButton = new JRibbonBigButton("Delete tenant"); deleteTenantButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0); keystonePanel.deleteTenant(); } }); deleteTenantButton .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/delete.png"))); deleteTenantButton.setVerticalTextPosition(SwingConstants.BOTTOM); deleteTenantButton.setHorizontalTextPosition(SwingConstants.CENTER); keystonePanel.add(deleteTenantButton, "cell 8 0 1 3,growy"); keystonePanel.add(deleteUserButton, "cell 1 1,growx"); detailUserButton = new JRibbonButton("Detail user"); detailUserButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0); keystonePanel.showUserDetail(); } }); detailUserButton.setHorizontalAlignment(SwingConstants.LEFT); detailUserButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/zoom.png"))); keystonePanel.add(detailUserButton, "cell 1 2,growx"); btnDeleteRole = new JRibbonButton("Delete role"); btnDeleteRole.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0); keystonePanel.deleteRole(); } }); btnDeleteRole.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png"))); keystonePanel.add(btnDeleteRole, "cell 5 1,growx"); assignRoleButton = new JRibbonButton("Assign role"); assignRoleButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0); keystonePanel.assignRole(); } }); assignRoleButton.setSelectedIcon( new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/user_add.png"))); keystonePanel.add(assignRoleButton, "cell 5 2,growx"); lblUser = new JRibbonLabel("user"); keystonePanel.add(lblUser, "cell 0 3 2 1,growx"); rbnlblRole = new JRibbonLabel("role"); keystonePanel.add(rbnlblRole, "cell 4 3 2 1,growx"); rbnlblTenant = new JRibbonLabel(); rbnlblTenant.setText("tenant"); keystonePanel.add(rbnlblTenant, "cell 7 3 2 1,growx"); flavorPanel = new JRibbonPanel(); ribbonTabbedPane.addTab("Flavor", null, flavorPanel, null); flavorPanel.setLayout(new MigLayout("", "[][]", "[grow][][][]")); rbnbgbtnCreateFlavor = new JRibbonBigButton(); rbnbgbtnCreateFlavor.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/add.png"))); rbnbgbtnCreateFlavor.setText("Create Flavor"); flavorPanel.add(rbnbgbtnCreateFlavor, "cell 0 0 1 3,growy"); btnDeleteFlavor = new JRibbonBigButton("Delete Flavor"); btnDeleteFlavor.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/delete.png"))); flavorPanel.add(btnDeleteFlavor, "cell 1 0 1 3,growy"); storagePanel = new JRibbonPanel(); ribbonTabbedPane.addTab("Storage", null, storagePanel, null); storagePanel.setLayout(new MigLayout("", "[][][][][][]", "[grow][][][]")); uploadImageButton = new JRibbonBigButton("Upload"); uploadImageButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/add.png"))); uploadImageButton.setVerticalTextPosition(SwingConstants.BOTTOM); uploadImageButton.setHorizontalTextPosition(SwingConstants.CENTER); storagePanel.add(uploadImageButton, "cell 0 0 1 3, growy"); btnDelete = new JRibbonButton("Delete"); btnDelete.setHorizontalAlignment(SwingConstants.LEFT); btnDelete.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png"))); storagePanel.add(btnDelete, "cell 1 0,growx"); ribbonSeparator_6 = new JRibbonSeparator(); storagePanel.add(ribbonSeparator_6, "cell 2 0 1 3,grow"); btnCreateVolume = new JRibbonBigButton("Create volume"); btnCreateVolume.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/add.png"))); btnCreateVolume.setVerticalTextPosition(SwingConstants.BOTTOM); btnCreateVolume.setHorizontalTextPosition(SwingConstants.CENTER); storagePanel.add(btnCreateVolume, "cell 3 0 1 3,growy"); btnDelete_1 = new JRibbonButton("Delete"); btnDelete_1.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png"))); btnDelete_1.setHorizontalAlignment(SwingConstants.LEFT); storagePanel.add(btnDelete_1, "cell 4 0,growx"); btnAttach = new JRibbonButton("Attach to vm"); btnAttach.setHorizontalAlignment(SwingConstants.LEFT); btnAttach.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/attach.png"))); storagePanel.add(btnAttach, "cell 5 0,growx"); btnChangeName = new JRibbonButton("Change name"); btnChangeName.setHorizontalAlignment(SwingConstants.LEFT); btnChangeName.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/pencil.png"))); storagePanel.add(btnChangeName, "cell 1 1,growx"); btnDetail = new JRibbonButton("Detail"); btnDetail.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/zoom.png"))); btnDetail.setHorizontalAlignment(SwingConstants.LEFT); storagePanel.add(btnDetail, "cell 4 1,growx"); btnDetachToVm = new JRibbonButton("Detach to vm"); btnDetachToVm.setHorizontalAlignment(SwingConstants.LEFT); btnDetachToVm.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/delete.png"))); storagePanel.add(btnDetachToVm, "cell 5 1,growx"); btnPublicprivate = new JRibbonButton("public/private"); btnPublicprivate.setHorizontalAlignment(SwingConstants.LEFT); btnPublicprivate.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/tick.png"))); storagePanel.add(btnPublicprivate, "cell 1 2,growx"); btnAddVolumeType = new JRibbonButton("Add volume type"); btnAddVolumeType.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/add.png"))); btnAddVolumeType.setHorizontalAlignment(SwingConstants.LEFT); storagePanel.add(btnAddVolumeType, "cell 4 2"); btnDeleteVolumeType = new JRibbonButton("Delete volume type"); btnDeleteVolumeType .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png"))); btnDeleteVolumeType.setHorizontalAlignment(SwingConstants.LEFT); storagePanel.add(btnDeleteVolumeType, "cell 5 2"); rbnlblImage = new JRibbonLabel(); rbnlblImage.setText("Image"); storagePanel.add(rbnlblImage, "cell 0 3 2 1,growx"); rbnlblVolume = new JRibbonLabel(); rbnlblVolume.setText("Volume"); storagePanel.add(rbnlblVolume, "cell 3 3 3 1,growx"); networkPanel = new JRibbonPanel(); ribbonTabbedPane.addTab("Network", null, networkPanel, null); settingPanel = new JRibbonPanel(); ribbonTabbedPane.addTab("Setting", null, settingPanel, null); settingPanel.setLayout(new MigLayout("", "[][][]", "[grow][grow][]")); rbnbgbtnSystemSetting = new JRibbonBigButton(); rbnbgbtnSystemSetting .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/systemSetting.png"))); rbnbgbtnSystemSetting.setText("System Setting"); settingPanel.add(rbnbgbtnSystemSetting, "cell 0 0 1 3,growy"); rbnbgbtnDatabase = new JRibbonBigButton(); rbnbgbtnDatabase .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/database.png"))); rbnbgbtnDatabase.setText("Database"); settingPanel.add(rbnbgbtnDatabase, "cell 1 0 1 3,growy"); rbnbtnAddGroup = new JRibbonButton(); rbnbtnAddGroup.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/add.png"))); rbnbtnAddGroup.setText("Add Group"); settingPanel.add(rbnbtnAddGroup, "cell 2 0"); rbnbtnEditGroup = new JRibbonButton(); rbnbtnEditGroup .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/pencil.png"))); rbnbtnEditGroup.setText("Edit Group"); settingPanel.add(rbnbtnEditGroup, "cell 2 1"); rbnbtnDeleteGroup = new JRibbonButton(); rbnbtnDeleteGroup .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png"))); rbnbtnDeleteGroup.setText("Delete Group"); settingPanel.add(rbnbtnDeleteGroup, "cell 2 2"); logoPanel = new JRibbonPanel(); ribbonPanel.add(logoPanel, BorderLayout.WEST); logoPanel.setLayout(new BorderLayout(0, 0)); logoPanel.add(logoLabel, BorderLayout.CENTER); setLocationRelativeTo(null); new Thread(new TitanServerUpdateThread()).start(); }
From source file:org.micromanager.asidispim.Utils.PlotUtils.java
/** * Create a frame with a plot of the data given in XYSeries overwrite any * previously created frame with the same title * /*from www.jav a 2 s .c om*/ * @param title shown in the top of the plot * @param data array with data series to be plotted * @param xTitle Title of the X axis * @param yTitle Title of the Y axis * @param showShapes whether or not to draw shapes at the data points * @param annotation to be shown in plot * @return Frame that displays the data */ public Frame plotDataN(String title, XYSeries[] data, String xTitle, String yTitle, boolean[] showShapes, String annotation) { // if we already have a plot open with this title, close it, but remember // its position Frame[] gfs = ChartFrame.getFrames(); for (Frame f : gfs) { if (f.getTitle().equals(title)) { f.dispose(); } } // JFreeChart code XYSeriesCollection dataset = new XYSeriesCollection(); // calculate min and max to scale the graph double minX, minY, maxX, maxY; minX = data[0].getMinX(); minY = data[0].getMinY(); maxX = data[0].getMaxX(); maxY = data[0].getMaxY(); for (XYSeries d : data) { dataset.addSeries(d); if (d.getMinX() < minX) { minX = d.getMinX(); } if (d.getMaxX() > maxX) { maxX = d.getMaxX(); } if (d.getMinY() < minY) { minY = d.getMinY(); } if (d.getMaxY() > maxY) { maxY = d.getMaxY(); } } JFreeChart chart = ChartFactory.createScatterPlot(title, // Title xTitle, // x-axis Label yTitle, // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation false, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); for (int i = 0; i < data.length; i++) { renderer.setSeriesFillPaint(i, Color.white); renderer.setSeriesLinesVisible(i, true); } renderer.setSeriesPaint(0, Color.blue); Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 4.0f, 4.0f); renderer.setSeriesShape(0, circle, false); if (data.length > 1) { renderer.setSeriesPaint(1, Color.red); Shape square = new Rectangle2D.Float(-2.0f, -2.0f, 4.0f, 4.0f); renderer.setSeriesShape(1, square, false); } if (data.length > 2) { renderer.setSeriesPaint(2, Color.darkGray); Shape rect = new Rectangle2D.Float(-2.0f, -1.0f, 4.0f, 2.0f); renderer.setSeriesShape(2, rect, false); } if (data.length > 3) { renderer.setSeriesPaint(3, Color.magenta); Shape rect = new Rectangle2D.Float(-1.0f, -2.0f, 2.0f, 4.0f); renderer.setSeriesShape(3, rect, false); } for (int i = 0; i < data.length; i++) { if (showShapes.length > i && !showShapes[i]) { renderer.setSeriesShapesVisible(i, false); } } XYAnnotation an = new XYTextAnnotation(annotation, maxX - 0.01, maxY); plot.addAnnotation(an); renderer.setUseFillPaint(true); final MyChartFrame graphFrame = new MyChartFrame(title, chart); graphFrame.getChartPanel().setMouseWheelEnabled(true); graphFrame.pack(); graphFrame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent arg0) { graphFrame.dispose(); } }); graphFrame.setVisible(true); return graphFrame; }
From source file:replicatorg.app.ui.panels.ControlPanel.java
public ControlPanel() { super(Base.getMainWindow(), Dialog.ModalityType.MODELESS); initComponents();/* w w w. j a v a 2 s . c o m*/ Base.writeLog("Control panel opened...", this.getClass()); setTextLanguage(); super.centerOnScreen(); super.enableDrag(); evaluateInitialConditions(); this.tempPanel.setLayout(new GridBagLayout()); this.tempPanel.add(this.makeChart()); //Sets legend colors BufferedImage image = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB); Graphics g = image.getGraphics(); g.setColor(t0MeasuredColor); g.fillRect(0, 0, 10, 10); Icon icon1 = new ImageIcon(image); this.colorCurrentTemp.setIcon(icon1); this.colorCurrentTemp.setText(""); BufferedImage image2 = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB); Graphics g2 = image2.getGraphics(); g2.setColor(t0TargetColor); g2.fillRect(0, 0, 10, 10); Icon icon2 = new ImageIcon(image2); this.colorTargetTemp.setIcon(icon2); this.colorTargetTemp.setText(""); if (connectedPrinter == PrinterInfo.BEETHEFIRST) { jSliderBlowerSpeed.setMaximum(1); jSliderBlowerSpeed.setMinorTickSpacing(0); jSliderBlowerSpeed.setMajorTickSpacing(1); jSliderExtruderSpeed.setEnabled(false); } this.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { consoleInput.requestFocus(); } @Override public void windowClosed(WindowEvent e) { if (movButtonHoldDown != null && movButtonHoldDown.isRunning()) { movButtonHoldDown.stop(); } driver.dispatchCommand("M1110 S0", COM.NO_RESPONSE); if (loggingTemperature == false) { disposeThread.cancel(); } inputValidationThread.cancel(); getInitialValuesThread.cancel(); } }); }
From source file:io.heming.accountbook.ui.MainFrame.java
public MainFrame() throws Exception { categoryFacade = new CategoryFacade(); recordFacade = new RecordFacade(); builder = new Pages.Builder(); builder.order("id", false); pages = builder.make();/* w w w . jav a 2s . c o m*/ date_chooser_visible = false; disable = false; // Create widgets model = new TableModel(); table = new JTable(model) { /** * tip. * * @param evt * @return */ @Override public String getToolTipText(MouseEvent evt) { String tip = null; java.awt.Point point = evt.getPoint(); int row = rowAtPoint(point); int col = columnAtPoint(point); Rectangle bounds = getCellRect(row, col, false); Component comp = prepareRenderer(getCellRenderer(row, col), row, col); try { if (comp.getPreferredSize().width > bounds.width) { tip = getValueAt(row, col).toString(); } } catch (RuntimeException e) { //catch null pointer exception if mouse is over an empty line } return tip; } }; if (pages.hasNext()) { model.setRecords(pages.next()); } // ? table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); TableColumnModel columnModel = table.getColumnModel(); columnModel.getColumn(0).setPreferredWidth(80); columnModel.getColumn(1).setPreferredWidth(160); columnModel.getColumn(2).setPreferredWidth(80); columnModel.getColumn(3).setPreferredWidth(100); columnModel.getColumn(4).setPreferredWidth(100); columnModel.getColumn(5).setPreferredWidth(360); // Layout JScrollPane pane = new JScrollPane(table); add(pane, BorderLayout.CENTER); table.getTableHeader().setReorderingAllowed(false); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // table header table.getTableHeader().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int col = table.columnAtPoint(e.getPoint()); String name = table.getColumnName(col); // TODO } }); // ? addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { quit(); } }); categories = categoryFacade.listBySale(); initMenuBar(); initToolBar(); initStatusBar(); initTablePopupMenu(); searchRecords(); setIconImage(new ImageIcon(getClass().getResource("64.png")).getImage()); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); setTitle(""); setSize(860, 620); }
From source file:AliasBean.java
/** Construct the object including its GUI */ public AliasBeanTest() { super("AliasBeanTest"); Container cp = getContentPane(); AliasBean ab = new AliasBean(); cp.add(BorderLayout.CENTER, ab); ab.addAlias("ian-cvs", "ian@openbsd.org"); ab.addAlias("ian-dos", "http://www.darwinsys.com/"); cp.add(BorderLayout.SOUTH, quitButton = new JButton("Exit")); quitButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false);//from ww w .j av a 2 s .c o m dispose(); System.exit(0); } }); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { setVisible(false); dispose(); System.exit(0); } }); pack(); }
From source file:com._17od.upm.gui.MainWindow.java
public MainWindow(String title) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException, IllegalBlockSizeException, IOException, GeneralSecurityException, ProblemReadingDatabaseFile {//from w ww . jav a 2 s. c om super(title); setIconImage(Util.loadImage("upm.gif").getImage()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); PlatformSpecificCode.getInstance().initialiseApplication(this); dbActions = new DatabaseActions(this); // Set up the content pane. addComponentsToPane(); // Add listener to store current position and size on closing this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { storeWindowBounds(); try { Preferences.save(); } catch (IOException ex) { // Not much we can do at this point ex.printStackTrace(); } } }); // Display the window. pack(); setLocationRelativeTo(null); boolean restore = Preferences.get(Preferences.ApplicationOptions.REMEMBER_WINDOW_POSITION, "false") .equals("true"); if (restore) { restoreWindowBounds(); } Boolean appAlwaysonTop = new Boolean( Preferences.get(Preferences.ApplicationOptions.MAINWINDOW_ALWAYS_ON_TOP, "false")); setAlwaysOnTop(appAlwaysonTop.booleanValue()); setVisible(true); try { // Load the startup database if it's configured String db = Preferences.get(Preferences.ApplicationOptions.DB_TO_LOAD_ON_STARTUP); if (db != null && !db.equals("")) { File dbFile = new File(db); if (!dbFile.exists()) { dbActions.errorHandler(new Exception(Translator.translate("dbDoesNotExist", db))); } else { dbActions.openDatabase(db); } } } catch (Exception e) { dbActions.errorHandler(e); } // Give the search field focus // I'm using requestFocusInWindow() rathar than requestFocus() // because the javadocs recommend it searchField.requestFocusInWindow(); }