List of usage examples for javax.swing ToolTipManager sharedInstance
public static ToolTipManager sharedInstance()
ToolTipManager
instance. From source file:ch.epfl.lis.gnwgui.Simulation.java
/** Add tooltips for all elements of the window */ private void addTooltips() { dream4Settings_.setToolTipText("<html>Set all parameters of this window to the values<br>" + "that were used to generate the DREAM4 challenges</html>"); normalizeNoise_.setToolTipText("<html>After adding experimental noise (measurement error), normalize<br>" + "by dividing all concentrations values by the maximum mRNA<br>" + "concentration of all datasets</html>"); noNoise_.setToolTipText(/*from w w w .j av a2s. c o m*/ "<html>Do not add any experimental noise (measurement error) after the simulation<br>" + "(if SDEs are used, there will still be noise in the dynamics)</html>"); wtSS_.setToolTipText("<html>Generate the steady state of the wild-type<br>" + "(can't be disabled)</html>"); useLogNormalNoise_.setToolTipText("<html>Select checkboxes below to add normal (Gaussian)<br>" + "and/or log-normal noise after the simulation</html>"); addGaussianNoise_.setToolTipText("<html>Select to add normal (Gaussian) noise</html>"); addLogNormalNoise_.setToolTipText("<html>Select to add log-normal noise</html>"); useMicroarrayNoise_.setToolTipText( "<html>Select to use the model of noise in microarrays that was used for the DREAM4<br>" + "challenges, which is similar to a mix of normal and log-normal noise<br>" + "(Tu, Stolovitzky, and Klein. <i>PNAS</i>, 99:14031-14036, 2002)</html>"); String networkName = "<i>" + item_.getLabel() + "</i>"; perturbationLoad_.setToolTipText("<html>Load the perturbations from the following files<br>" + "(they must be located in the output directory):<br>" + "- " + networkName + "_multifactorial_perturbations.tsv<br>" + "- " + networkName + "_dualknockouts_perturbations.tsv<br>" + "- " + networkName + "_dream4_timeseries_perturbations.tsv</html>"); perturbationNew_.setToolTipText("<html>Generate new perturbations, select if you don't have<br>" + "predefined perturbations that you want to use</html>"); timeSeriesAsDream4_ .setToolTipText("<html>Generate time series as those provided in DREAM4 (<i>in addition</i><br>" + "to time series for knockouts, knockdowns, etc. selected above)</html>"); dualKnockoutTS_.setToolTipText("<html>Trajectories for dual knockouts (at t=0 is the<br>" + "wild-type, at this time the dual knockout is done)</html>"); multifactorialTS_.setToolTipText("<html>Trajectories for multifactorial perturbations (at t=0 is<br>" + "the wild-type, at this time the perturbation is applied)</html>"); knockdownTS_.setToolTipText("<html>Trajectories for knockdowns (at t=0 is the<br>" + "wild-type, at this time the knockdown is done)</html>"); knockoutTS_.setToolTipText("<html>Trajectories for the knockouts (at t=0 is the<br>" + " wild-type, at this time the knockout is done)</html>"); dualKnockoutSS_.setToolTipText("<html>Steady states for dual knockouts (pairs are selected<br>" + "according to how many genes they co-regulate)</html>"); multifactorialSS_.setToolTipText("<html>Steady states for multifactorial perturbations</html>"); logNormalNoise_.setToolTipText("<html>Standard deviation of the log-normal noise</html>"); numTimeSeries_.setToolTipText("<html>The number of time series (a different perturbation<br>" + "is used for every time series)</html>"); knockdownSS_.setToolTipText("<html>Steady states for knockdown of every gene</html>"); knockoutSS_.setToolTipText("<html>Steady states for knockout of every gene</html>"); model_.setToolTipText("<html>Select ODEs (deterministic) or SDEs (noise in dynamics) for the<br>" + "simulation of all experiments selected below. If you select both,<br>" + "they will be run one after the other using the same perturbations<br>" + "and the label <i>nonoise</i> will be added to the data from the ODEs.</html>"); tmax_.setToolTipText("<html>Duration of the time series experiments</html>"); sdeDiffusionCoeff_.setToolTipText("<html>Multiplicative constant of the noise term in the SDEs<br>" + "(if set to 0, using SDEs is equivalent to using ODEs)</html>"); gaussianNoise_.setToolTipText("<html>Standard deviation of the Gaussian noise</html>"); numPointsPerTimeSeries_ .setToolTipText("<html>Number of points per time series (defines how many points are saved<br>" + "in the datasets, does not affect precision of numerical integration)</html>"); runButton_.setToolTipText("<html>Set parameters to the given values and run all experiments</html>"); cancelButton_.setToolTipText( "<html>Abort (the thread may finish the current experiment before it exits)</html>"); // tooltips disappear only after 10s ToolTipManager.sharedInstance().setDismissDelay(10000); }
From source file:com.isti.traceview.common.TraceViewChartPanel.java
/** * Constructs a JFreeChart panel./*from www. j a v a 2 s . c o m*/ * * @param chart * the chart. * @param width * the preferred width of the panel. * @param height * the preferred height of the panel. * @param minimumDrawWidth * the minimum drawing width. * @param minimumDrawHeight * the minimum drawing height. * @param maximumDrawWidth * the maximum drawing width. * @param maximumDrawHeight * the maximum drawing height. * @param useBuffer * a flag that indicates whether to use the off-screen buffer to improve performance * (at the expense of memory). * @param properties * a flag indicating whether or not the chart property editor should be available via * the popup menu. * @param save * a flag indicating whether or not save options should be available via the popup * menu. * @param print * a flag indicating whether or not the print option should be available via the * popup menu. * @param zoom * a flag indicating whether or not zoom options should be added to the popup menu. * @param tooltips * a flag indicating whether or not tooltips should be enabled for the chart. */ public TraceViewChartPanel(JFreeChart chart, int width, int height, int minimumDrawWidth, int minimumDrawHeight, int maximumDrawWidth, int maximumDrawHeight, boolean useBuffer, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips) { this.setChart(chart); this.chartMouseListeners = new EventListenerList(); this.info = new ChartRenderingInfo(); setPreferredSize(new Dimension(width, height)); this.useBuffer = useBuffer; this.refreshBuffer = false; this.minimumDrawWidth = minimumDrawWidth; this.minimumDrawHeight = minimumDrawHeight; this.maximumDrawWidth = maximumDrawWidth; this.maximumDrawHeight = maximumDrawHeight; this.zoomTriggerDistance = DEFAULT_ZOOM_TRIGGER_DISTANCE; // set up popup menu... this.popup = null; if (properties || save || print || zoom) { this.popup = createPopupMenu(properties, save, print, zoom); } enableEvents(AWTEvent.MOUSE_EVENT_MASK); enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK); setDisplayToolTips(tooltips); addMouseListener(this); addMouseMotionListener(this); this.enforceFileExtensions = true; // initialize ChartPanel-specific tool tip delays with // values the from ToolTipManager.sharedInstance() ToolTipManager ttm = ToolTipManager.sharedInstance(); this.ownToolTipInitialDelay = ttm.getInitialDelay(); this.ownToolTipDismissDelay = ttm.getDismissDelay(); this.ownToolTipReshowDelay = ttm.getReshowDelay(); }
From source file:org.rdv.viz.chart.ChartPanel.java
/** * Constructs a JFreeChart panel./* w w w. ja va 2s . co m*/ * * @param chart the chart. * @param width the preferred width of the panel. * @param height the preferred height of the panel. * @param minimumDrawWidth the minimum drawing width. * @param minimumDrawHeight the minimum drawing height. * @param maximumDrawWidth the maximum drawing width. * @param maximumDrawHeight the maximum drawing height. * @param useBuffer a flag that indicates whether to use the off-screen * buffer to improve performance (at the expense of * memory). * @param properties a flag indicating whether or not the chart property * editor should be available via the popup menu. * @param save a flag indicating whether or not save options should be * available via the popup menu. * @param print a flag indicating whether or not the print option * should be available via the popup menu. * @param zoom a flag indicating whether or not zoom options should be * added to the popup menu. * @param tooltips a flag indicating whether or not tooltips should be * enabled for the chart. */ public ChartPanel(JFreeChart chart, int width, int height, int minimumDrawWidth, int minimumDrawHeight, int maximumDrawWidth, int maximumDrawHeight, boolean useBuffer, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips) { this.setChart(chart); this.chartMouseListeners = new EventListenerList(); this.info = new ChartRenderingInfo(); setPreferredSize(new Dimension(width, height)); this.useBuffer = useBuffer; this.refreshBuffer = false; this.minimumDrawWidth = minimumDrawWidth; this.minimumDrawHeight = minimumDrawHeight; this.maximumDrawWidth = maximumDrawWidth; this.maximumDrawHeight = maximumDrawHeight; this.zoomTriggerDistance = DEFAULT_ZOOM_TRIGGER_DISTANCE; // set up popup menu... this.popup = null; if (properties || save || print || zoom) { this.popup = createPopupMenu(properties, save, print, zoom); } enableEvents(AWTEvent.MOUSE_EVENT_MASK); enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK); setDisplayToolTips(tooltips); addMouseListener(this); addMouseMotionListener(this); this.defaultDirectoryForSaveAs = null; this.enforceFileExtensions = true; // initialize ChartPanel-specific tool tip delays with // values the from ToolTipManager.sharedInstance() ToolTipManager ttm = ToolTipManager.sharedInstance(); this.ownToolTipInitialDelay = ttm.getInitialDelay(); this.ownToolTipDismissDelay = ttm.getDismissDelay(); this.ownToolTipReshowDelay = ttm.getReshowDelay(); this.zoomAroundAnchor = false; this.rangeHistory = new Stack<Range>(); }
From source file:edu.harvard.i2b2.previousquery.ui.QueryPreviousRunsPanel.java
/** * This method is called from within the constructor to initialize the form. *///from w ww. j ava 2 s .c om private void initComponents() { System.setProperty("PQSortByTimeCheckBox", "true"); System.setProperty("QueryToolMaxQueryNumber", "20"); System.setProperty("PQMaxPatientsNumber", "200"); System.setProperty("PQSortByNameCheckBox", "false"); jScrollPane1 = new javax.swing.JScrollPane(); jTree1 = new javax.swing.JTree(); setLayout(new java.awt.BorderLayout()); QueryMasterData tmpData = new QueryMasterData(); tmpData.name("Queries by " + UserInfoBean.getInstance().getUserName()); tmpData.tooltip("Previous query runs"); tmpData.visualAttribute("CA"); top = new DefaultMutableTreeNode(tmpData); // top = new DefaultMutableTreeNode("Root Node"); treeModel = new DefaultTreeModel(top); // treeModel.addTreeModelListener(new MyTreeModelListener()); jTree1 = new JTree(treeModel); jTree1.setEditable(false); // jTree1.getSelectionModel().setSelectionMode // (TreeSelectionModel.SINGLE_TREE_SELECTION); jTree1.setShowsRootHandles(true); // JScrollPane treeView = new JScrollPane(jTree1); jTree1.setRootVisible(false); jTree1.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); jTree1.setCellRenderer(new MyRenderer()); ToolTipManager.sharedInstance().registerComponent(jTree1); if (cellStatus.equalsIgnoreCase("CellDown")) { DefaultMutableTreeNode childNode = new DefaultMutableTreeNode("Data Repository Cell is unavailable"); treeModel.insertNodeInto(childNode, top, top.getChildCount()); // Make sure the user can see the lovely new node. jTree1.expandPath(new TreePath(top.getPath())); } ArrayList<QueryMasterData> queries = previousQueries; if (queries != null) { for (int i = 0; i < queries.size(); i++) { addNode(queries.get(i)); } } jScrollPane1.setViewportView(jTree1); add(jScrollPane1, java.awt.BorderLayout.CENTER); jTree1.setTransferHandler(new NodeCopyTransferHandler()); jTree1.addTreeExpansionListener(this); jTree1.addTreeWillExpandListener(this); }
From source file:com.intel.stl.ui.common.view.ComponentFactory.java
public static JPasswordField createPasswordField(DocumentListener... docListeners) { final JPasswordField field = new JPasswordField(); final Border oldBorder = field.getBorder(); if (docListeners != null) { for (DocumentListener docListener : docListeners) { field.getDocument().addDocumentListener(docListener); field.getDocument().putProperty("owner", field); }/*from w w w . j a v a 2 s. c om*/ } final InputVerifier verifier = new InputVerifier() { @Override public boolean verify(final JComponent input) { final JPasswordField field = (JPasswordField) input; char[] txt = field.getPassword(); if (txt.length == 0) { // Run in EDT to avoid deadlock in case this gets called // from not swing thread Util.runInEDT(new Runnable() { @Override public void run() { field.setToolTipText(UILabels.STL50084_CANT_BE_BLANK.getDescription()); input.setBackground(UIConstants.INTEL_LIGHT_RED); input.setBorder(BorderFactory.createLineBorder(UIConstants.INTEL_RED, 2)); // show tooltip immediately ToolTipManager.sharedInstance() .mouseMoved(new MouseEvent(field, 0, 0, 0, 0, 0, 0, false)); } }); return false; } else { Util.runInEDT(new Runnable() { @Override public void run() { input.setBackground(UIConstants.INTEL_WHITE); input.setBorder(oldBorder); } }); return true; } } }; DocumentListener dynamicChecker = new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { verifier.verify(field); } @Override public void removeUpdate(DocumentEvent e) { verifier.verify(field); } @Override public void changedUpdate(DocumentEvent e) { verifier.verify(field); } }; field.getDocument().addDocumentListener(dynamicChecker); // Add the input verifier field.setInputVerifier(verifier); return field; }
From source file:net.sf.firemox.Magic.java
public void actionPerformed(ActionEvent e) { final String command = e.getActionCommand(); final Object obj = e.getSource(); if (obj == sendButton) { if (sendTxt.getText().length() != 0) { MChat.getInstance().sendMessage(sendTxt.getText() + "\n"); sendTxt.setText(""); }/*from w w w.j a va 2s .co m*/ } else if (command != null && command.startsWith("border-")) { for (int i = cardBorderMenu.getComponentCount(); i-- > 0;) { ((JRadioButtonMenuItem) cardBorderMenu.getComponent(i)).setSelected(false); } ((JRadioButtonMenuItem) obj).setSelected(true); CardFactory.updateColor(command.substring("border-".length())); CardFactory.updateAllCardsUI(); magicForm.repaint(); } else if ("menu_help_mailing".equals(command)) { try { WebBrowser.launchBrowser( "http://lists.sourceforge.net/lists/listinfo/" + IdConst.PROJECT_NAME + "-user"); } catch (Exception e1) { JOptionPane.showOptionDialog(this, LanguageManager.getString("error") + " : " + e1.getMessage(), LanguageManager.getString("web-pb"), JOptionPane.OK_OPTION, JOptionPane.INFORMATION_MESSAGE, UIHelper.getIcon("wiz_update_error.gif"), null, null); } } else if ("menu_options_settings".equals(command)) { // Setting panel final Wizard settingsPanel = new Settings(); settingsPanel.setVisible(true); } else if ("menu_help_check-update".equals(command)) { VersionChecker.checkVersion(this); } else if ("menu_game_new_client".equals(command)) { new net.sf.firemox.ui.wizard.Client().setVisible(true); } else if ("menu_game_new_server".equals(command)) { new net.sf.firemox.ui.wizard.Server().setVisible(true); } else if ("menu_tools_log".equals(command)) { new net.sf.firemox.ui.wizard.Log().setVisible(true); } else if ("menu_tools_featurerequest".equals(command)) { new Feature().setVisible(true); } else if ("menu_tools_bugreport".equals(command)) { new Bug().setVisible(true); } else if ("menu_game_skip".equals(command)) { if (ConnectionManager.isConnected() && skipButton.isEnabled() && StackManager.idHandedPlayer == 0) { StackManager.noReplayToken.take(); try { manualSkip(); } catch (Throwable t) { t.printStackTrace(); } finally { StackManager.noReplayToken.release(); } } } else if ("menu_game_disconnect".equals(command)) { ConnectionManager.closeConnexions(); } else if ("menu_tools_jdb".equals(command)) { DeckBuilder.loadFromMagic(); } else if ("menu_game_exit".equals(command)) { exitForm(null); } else if (obj == autoManaMenu) { /* * invoked you click directly on the "auto-mana option" of the menu * "options". The opponent has to know that we are in "auto colorless mana * use", since player will no longer click on the mana icon to define * which colored mana active player has used as colorless mana, then the * opponent have not to wait for active player choice, but apply the same * Algorithm calculating which colored manas are used as colorless manas. * This information is not sent immediately, but will be sent with the * next action of active player. */ MCommonVars.autoMana = autoManaMenu.isSelected(); } else if (obj == autoPlayMenu) { /* * invoked you click directly on the "auto-play option" of the menu * "options". */ MCommonVars.autoStack = autoPlayMenu.isSelected(); } else if ("menu_tools_jcb".equals(command)) { // TODO cardBuilderMenu -> not yet implemented Log.info("cardBuilderMenu -> not yet implemented"); } else if ("menu_game_proxy".equals(command)) { new ProxyConfiguration().setVisible(true); } else if ("menu_help_help".equals(command)) { /* * Invoked you click directly on youLabel. Opponent will receive this * information. */ try { WebBrowser.launchBrowser("http://prdownloads.sourceforge.net/" + IdConst.PROJECT_NAME + "/7e_rulebook_EN.pdf?download"); } catch (Exception e1) { JOptionPane.showOptionDialog(this, LanguageManager.getString("error") + " : " + e1.getMessage(), LanguageManager.getString("web-pb"), JOptionPane.OK_OPTION, JOptionPane.INFORMATION_MESSAGE, UIHelper.getIcon("wiz_update_error.gif"), null, null); } } else if ("menu_help_about".equals(command)) { new About(this).setVisible(true); } else if ("menu_help_about.tbs".equals(command)) { new AboutMdb(this).setVisible(true); } else if (obj == reverseArtCheck || obj == reverseSideCheck) { Configuration.setProperty("reverseArt", reverseArtCheck.isSelected()); Configuration.setProperty("reverseSide", reverseSideCheck.isSelected()); ZoneManager.updateReversed(); StackManager.PLAYERS[1].updateReversed(); repaint(); SwingUtilities.invokeLater(SkinLF.REFRESH_RUNNER); } else if (obj == soundMenu) { Configuration.setProperty("sound", soundMenu.isSelected()); soundMenu.setIcon( soundMenu.isSelected() ? UIHelper.getIcon("sound.gif") : UIHelper.getIcon("soundoff.gif")); } else if ("menu_lf_randomAngle".equals(command)) { Configuration.setProperty("randomAngle", ((AbstractButton) e.getSource()).isSelected()); CardFactory.updateAllCardsUI(); } else if ("menu_lf_powerToughnessColor".equals(command)) { final Color powerToughnessColor = JColorChooser.showDialog(this, LanguageManager.getString("menu_lf_powerToughnessColor"), CardFactory.powerToughnessColor); if (powerToughnessColor != null) { Configuration.setProperty("powerToughnessColor", powerToughnessColor.getRGB()); CardFactory.updateColor(null); repaint(); } } else if (obj == initialdelayMenu) { // TODO factor this code with the one of Magic.class final ToolTipManager toolTipManager = ToolTipManager.sharedInstance(); new InputNumber(LanguageManager.getString("initialdelay"), LanguageManager.getString("initialdelay.tooltip"), 0, Integer.MAX_VALUE, toolTipManager.getInitialDelay()).setVisible(true); if (Wizard.optionAnswer == JOptionPane.YES_OPTION) { toolTipManager.setEnabled(Wizard.indexAnswer != 0); toolTipManager.setInitialDelay(Wizard.indexAnswer); initialdelayMenu.setText(LanguageManager.getString("initialdelay") + (toolTipManager.isEnabled() ? " : " + Wizard.indexAnswer + " ms" : "(disabled)")); Configuration.setProperty("initialdelay", Wizard.indexAnswer); } } else if (obj == dismissdelayMenu) { // TODO factor this code with the one of Magic.class final ToolTipManager toolTipManager = ToolTipManager.sharedInstance(); new InputNumber(LanguageManager.getString("dismissdelay"), LanguageManager.getString("dismissdelay.tooltip"), 0, Integer.MAX_VALUE, toolTipManager.getDismissDelay()).setVisible(true); if (Wizard.optionAnswer == JOptionPane.YES_OPTION) { toolTipManager.setDismissDelay(Wizard.indexAnswer); Configuration.setProperty("dismissdelay", Wizard.indexAnswer); dismissdelayMenu.setText(LanguageManager.getString("dismissdelay") + Wizard.indexAnswer + " ms"); } } }
From source file:com.eviware.soapui.SoapUI.java
public static SoapUI startSoapUI(String[] args, String title, String splashImage, SwingSoapUICore core) throws Exception { System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "SoapUI"); frame = new JFrame(title); SoapUISplash splash = new SoapUISplash(splashImage, frame); frame.setIconImage(UISupport.createImageIcon(FRAME_ICON).getImage()); JPopupMenu.setDefaultLightWeightPopupEnabled(false); ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); isStandalone = true;/*from w w w . ja v a 2 s. com*/ soapUICore = core; SoapUI soapUI = new SoapUI(); Workspace workspace = null; org.apache.commons.cli.Options options = initSoapUIOptions(); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(options, args); if (!processCommandLineArgs(cmd, options)) { System.exit(1); } if (workspaceName != null) { workspace = WorkspaceFactory.getInstance().openWorkspace(workspaceName, projectOptions); soapUICore.getSettings().setString(CURRENT_SOAPUI_WORKSPACE, workspaceName); } else { String wsfile = soapUICore.getSettings().getString(CURRENT_SOAPUI_WORKSPACE, System.getProperty("user.home") + File.separatorChar + DEFAULT_WORKSPACE_FILE); try { workspace = WorkspaceFactory.getInstance().openWorkspace(wsfile, projectOptions); } catch (Exception e) { UISupport.setDialogs(new SwingDialogs(null)); if (UISupport.confirm("Failed to open workspace: [" + e.toString() + "], create new one instead?", "Error")) { new File(wsfile).renameTo(new File(wsfile + ".bak")); workspace = WorkspaceFactory.getInstance().openWorkspace(wsfile, projectOptions); } else { System.exit(1); } } } core.prepareUI(); soapUI.show(workspace); core.afterStartup(workspace); Thread.sleep(500); splash.setVisible(false); if (getSettings().getBoolean(UISettings.SHOW_STARTUP_PAGE) && !SoapUI.isJXBrowserDisabled(true)) { SwingUtilities.invokeLater(new Runnable() { public void run() { showPushPage(); } }); } frame.setSize(1000, 750); String[] args2 = cmd.getArgs(); if (args2 != null && args2.length > 0) { String arg = args2[0]; if (arg.toUpperCase().endsWith(".WSDL") || arg.toUpperCase().endsWith(".WADL")) { SwingUtilities.invokeLater(new WsdlProjectCreator(arg)); } else { try { URL url = new URL(arg); SwingUtilities.invokeLater(new RestProjectCreator(url)); } catch (Exception e) { } } } return soapUI; }
From source file:gtu._work.etc._3DSMovieRenamer.java
private void initGUI() { try {// ww w .java2s . c o m final SwingActionUtil swingUtil = (SwingActionUtil) SwingActionUtil.newInstance(this); BorderLayout thisLayout = new BorderLayout(); getContentPane().setLayout(thisLayout); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setTitle("3DS Rename"); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("vid list", null, jPanel1, null); { openDir = new JButton(); jPanel1.add(openDir, BorderLayout.NORTH); openDir.setText("open dir"); openDir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { swingUtil.invokeAction("openDir.actionPerformed", evt); } }); } { ListModel vidListModel = new DefaultListModel(); vidList = new JList(); jPanel1.add(vidList, BorderLayout.CENTER); vidList.setModel(vidListModel); vidList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { swingUtil.invokeAction("vidList.mouseClicked", evt); } }); vidList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { swingUtil.invokeAction("vidList.keyPressed", evt); } }); } { jPanel3 = new JPanel(); jPanel1.add(jPanel3, BorderLayout.SOUTH); jPanel3.setPreferredSize(new java.awt.Dimension(445, 34)); { renameText = new JTextField(); jPanel3.add(renameText); renameText.setPreferredSize(new java.awt.Dimension(187, 24)); } { renameBtn = new JButton(); jPanel3.add(renameBtn); renameBtn.setText("rename"); renameBtn.setPreferredSize(new java.awt.Dimension(106, 24)); renameBtn.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { swingUtil.invokeAction("renameBtn.mouseClicked", evt); } }); } { forceChange = new JCheckBox(); jPanel3.add(forceChange); forceChange.setText("force"); forceChange.setPreferredSize(new java.awt.Dimension(64, 21)); } } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("copy", null, jPanel2, null); { jScrollPane1 = new JScrollPane(); jPanel2.add(jScrollPane1, BorderLayout.CENTER); { ListModel copyToListModel = new DefaultListModel(); copyToList = new JList(); jScrollPane1.setViewportView(copyToList); copyToList.setModel(copyToListModel); copyToList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { swingUtil.invokeAction("copyToList.mouseClicked", evt); } }); } } } { jPanel4 = new JPanel(); BorderLayout jPanel4Layout = new BorderLayout(); jPanel4.setLayout(jPanel4Layout); jTabbedPane1.addTab("BT Movie", null, jPanel4, null); { jScrollPane2 = new JScrollPane(); jPanel4.add(jScrollPane2, BorderLayout.WEST); jScrollPane2.setPreferredSize(new java.awt.Dimension(254, 355)); { btDirTree = new JTree(); jScrollPane2.setViewportView(btDirTree); btDirTree.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { swingUtil.invokeAction(evt); } }); btDirTree.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { swingUtil.invokeAction(evt); } }); JTreeUtil.newInstance(btDirTree).fileSystem(DEFAULT_BT_DIR); } } { jPanel5 = new JPanel(); BorderLayout jPanel5Layout = new BorderLayout(); jPanel5.setLayout(jPanel5Layout); jPanel4.add(jPanel5, BorderLayout.CENTER); { jScrollPane3 = new JScrollPane(); jPanel5.add(jScrollPane3, BorderLayout.CENTER); jScrollPane3.setPreferredSize(new java.awt.Dimension(427, 355)); { DefaultListModel btMovListModel = new DefaultListModel(); btMovList = new JList(); jScrollPane3.setViewportView(btMovList); btMovList.setModel(btMovListModel); btMovList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { swingUtil.invokeAction(evt); } }); btMovList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(btMovList).defaultJListKeyPressed(evt); } }); } } } } { jPanel6 = new JPanel(); FlowLayout jPanel6Layout = new FlowLayout(); jTabbedPane1.addTab("common", null, jPanel6, null); jPanel6.setLayout(jPanel6Layout); { execute3dsVidTransfer = new JButton(); jPanel6.add(execute3dsVidTransfer); execute3dsVidTransfer.setText("execute 3ds video transfer"); execute3dsVidTransfer.setPreferredSize(new java.awt.Dimension(207, 42)); execute3dsVidTransfer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String bat = "C:/apps/_movie/3DSVideov1.00/3DS Video.exe"; try { Runtime.getRuntime().exec(String.format("cmd /c call \"%s\"", bat)); } catch (IOException e) { JCommonUtil.handleException(e); } } }); } { openMovieAppDir = new JButton(); jPanel6.add(openMovieAppDir); openMovieAppDir.setText("open movie app dir"); openMovieAppDir.setPreferredSize(new java.awt.Dimension(207, 42)); openMovieAppDir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { Desktop.getDesktop().open(new File("C:/apps/_movie")); } catch (IOException e) { JCommonUtil.handleException(e); } } }); } } { jPanel7 = new JPanel(); BorderLayout jPanel7Layout = new BorderLayout(); jTabbedPane1.addTab("fake rename", null, jPanel7, null); jPanel7.setLayout(jPanel7Layout); { openFakeRenameDir = new JButton(); jPanel7.add(openFakeRenameDir, BorderLayout.NORTH); openFakeRenameDir.setText("open dir"); openFakeRenameDir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JCommonUtil._jFileChooser_selectDirectoryOnly(); if (file != null) { DefaultListModel model = new DefaultListModel(); for (File f : file.listFiles()) { model.addElement(f); } openFakeRenameDirList.setModel(model); } } }); } { DefaultListModel openFakeRenameDirListModel = new DefaultListModel(); openFakeRenameDirList = new JList(); jPanel7.add(openFakeRenameDirList, BorderLayout.CENTER); openFakeRenameDirList.setModel(openFakeRenameDirListModel); openFakeRenameDirList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { File file = (File) JListUtil.getLeadSelectionObject(openFakeRenameDirList); try { Process process = Runtime.getRuntime() .exec(String.format("cmd /c call \"%s\"", file)); InputStream ins = process.getInputStream(); while (ins.read() != -1) { //TODO } ins.close(); System.out.println("done..."); } catch (IOException e) { e.printStackTrace(); } } }); openFakeRenameDirList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(openFakeRenameDirList).defaultJListKeyPressed(evt); } }); } { jPanel8 = new JPanel(); jPanel7.add(jPanel8, BorderLayout.SOUTH); jPanel8.setPreferredSize(new java.awt.Dimension(681, 43)); { openFakeRenameDir_newName = new JTextField(); jPanel8.add(openFakeRenameDir_newName); openFakeRenameDir_newName.setPreferredSize(new java.awt.Dimension(287, 27)); } { fakeRenameExecute = new JButton(); jPanel8.add(fakeRenameExecute); fakeRenameExecute.setText("execute"); fakeRenameExecute.setPreferredSize(new java.awt.Dimension(95, 27)); fakeRenameExecute.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { DefaultListModel model = (DefaultListModel) openFakeRenameDirList.getModel(); //TODO } }); } } } swingUtil.addAction("copyToList.mouseClicked", new Action() { public void action(EventObject evt) throws Exception { try { if (((MouseEvent) evt).getButton() == 3) { JMenuItem reloadMenu = new JMenuItem(); reloadMenu.setText("reload SD card directory"); reloadMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DefaultListModel copyToListModel = new DefaultListModel(); for (final File f : load3DSDir.listFiles(new FilenameFilter() { public boolean accept(File paramFile, String paramString) { if (paramFile.isDirectory() && paramString.matches(CUSTOM_3DS_DIR_PATTERN)) { return true; } return false; } })) { copyToListModel.addElement(f); } copyToList.setModel(copyToListModel); } }); JMenuItem copyAllToMenu = new JMenuItem(); { copyAllToMenu.setText( String.format("move %d vids to...", vidList.getModel().getSize())); final File toDir = (File) JListUtil.getLeadSelectionObject(copyToList); if (toDir == null || !toDir.exists() || !toDir.isDirectory()) { copyAllToMenu.setEnabled(false); } if (vidList.getModel().getSize() == 0) { copyAllToMenu.setText("copy no file..."); copyAllToMenu.setEnabled(false); } copyAllToMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DefaultListModel model = JListUtil.newInstance(vidList).getModel(); if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION != JOptionPaneUtil .newInstance().iconWaringMessage().confirmButtonYesNo() .showConfirmDialog("are you sure copy files : " + model.getSize() + "\n to dir : " + toDir, "COPY VIDS")) { return; } for (int ii = 0; ii < model.getSize(); ii++) { File src = (File) model.getElementAt(ii); src.renameTo(new File(toDir, src.getName())); } JOptionPaneUtil.newInstance().iconInformationMessage() .showMessageDialog("copy completed!", "SUCCESS"); loadDirVids(); } }); } JPopupMenuUtil.newInstance(copyToList).applyEvent((MouseEvent) evt) .addJMenuItem(reloadMenu, copyAllToMenu).show(); } } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); swingUtil.addAction("openDir.actionPerformed", new Action() { public void action(EventObject evt) throws Exception { File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog() .getApproveSelectedFile(); if (file == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("dir not corrent!, set desktop", getTitle()); loadDir = FileUtil.DESKTOP_DIR; } else { loadDir = file; } loadDirVids(); } }); swingUtil.addAction("vidList.mouseClicked", new Action() { // final String player = "C:/Program Files (x86)/GRETECH/GomPlayer/GOM.EXE"; public void action(EventObject evt) throws Exception { int pos = -1; if ((pos = vidList.getLeadSelectionIndex()) == -1) { return; } MouseEvent mevt = (MouseEvent) evt; final File selectItem = (File) vidList.getModel().getElementAt(pos); List<JMenuItem> menuList = new ArrayList<JMenuItem>(); JMenuItem simpleRenamer = new JMenuItem(); final String simpleRenamePrefix = RandomUtil.upperCase(3); simpleRenamer.setText("Rename : " + simpleRenamePrefix); simpleRenamer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { String value = StringUtils.defaultString(JOptionPaneUtil.newInstance() .showInputDialog("3 char prefix?", "AVI PREFIX"), simpleRenamePrefix); if (value != null && value.matches("[a-zA-Z]{3}")) { selectItem.renameTo(getNewFile(selectItem.getParentFile(), value)); loadDirVids(); } else { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("prefix is not correct!", "ERROR"); } } }); menuList.add(simpleRenamer); if (load3DSDir == null) { reload3DSDir(); if (load3DSDir == null) { JMenuItem disable = new JMenuItem(); disable.setText("MOVE : SD card is not set!"); disable.setEnabled(false); menuList.add(disable); } } else { for (final File f : load3DSDir.listFiles(new FilenameFilter() { public boolean accept(File paramFile, String paramString) { if (paramFile.isDirectory() && paramString.matches(CUSTOM_3DS_DIR_PATTERN)) { return true; } return false; } })) { JMenuItem copyTo = new JMenuItem(); copyTo.setText("MOVE : " + f.getName()); copyTo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION == JOptionPaneUtil .newInstance().iconQuestionMessage().confirmButtonYesNo() .showConfirmDialog(// "are you sure move file\n" + // selectItem + "\n" + // "to\n" + // "dir : " + f + " ??"// , "COPY FILE")) { File copyToNewDirFile = new File(f, selectItem.getName()); if (copyToNewDirFile.exists()) { JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog( "target dir file already exist!, need rename!", "FILE ALREADY EXIST"); return; } selectItem.renameTo(copyToNewDirFile); loadDirVids(); JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("move completed!", "MOVE FILE"); } } }); menuList.add(copyTo); } } JPopupMenuUtil.newInstance(vidList).applyEvent(mevt) .addJMenuItem(menuList.toArray(new JMenuItem[menuList.size()])).show(); if (mevt.getClickCount() != 2) { return; } String clkItemPath = selectItem.getAbsolutePath(); String command = "cmd /c call \"" + clkItemPath + "\""; System.out.println(command); Runtime.getRuntime().exec(command); } }); swingUtil.addAction("vidList.keyPressed", new Action() { public void action(EventObject evt) throws Exception { JListUtil.newInstance(vidList).defaultJListKeyPressed(evt); } }); swingUtil.addAction("renameBtn.mouseClicked", new Action() { Pattern aviNamePattern = Pattern.compile("^([a-zA-Z]{3})_\\d{4}\\.[aA][vV][iI]$"); public void action(EventObject evt) throws Exception { String name = StringUtils.defaultIfEmpty(renameText.getText(), RandomUtil.upperCase(3)); System.out.println("name = " + name + ", force : " + forceChange.isSelected()); if (!name.matches("[a-zA-Z]{3}")) { renameText.setText(""); JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("rename must eng 3 char!", "ERROR"); return; } DefaultListModel model = (DefaultListModel) vidList.getModel(); boolean matchOk = false; if (model.size() != 0) { File oldFile = null; Matcher matcher = null; for (int ii = 0; ii < model.getSize(); ii++) { oldFile = (File) model.getElementAt(ii); if (!oldFile.exists()) { JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog( "file not exeist : \n" + oldFile.getAbsolutePath(), getTitle()); return; } matcher = aviNamePattern.matcher(oldFile.getName()); matchOk = matcher.find(); System.out.println("matchOk = " + matchOk); if (matchOk && !forceChange.isSelected()) { oldFile.renameTo(getNewFile(oldFile.getParentFile(), matcher.group(1))); } else { oldFile.renameTo(getNewFile(oldFile.getParentFile(), name)); } } JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog("success!", getTitle()); } loadDirVids(); } }); ToolTipManager.sharedInstance().setInitialDelay(0); swingUtil.addAction(btMovList, MouseEvent.class, new Action() { public void action(EventObject evt) throws Exception { final File file = (File) JListUtil.getLeadSelectionObject(btMovList); if (JMouseEventUtil.buttonLeftClick(1, evt)) { btMovList.setToolTipText( DateFormatUtils.format(file.lastModified(), "yyyy/MM/dd HH:mm:ss") + " length:" + (file.length() / 1024) + "k"); } final Object[] objects = btMovList.getSelectedValues(); JPopupMenuUtil.newInstance(btMovList).applyEvent(evt)// .addJMenuItem("move out", (objects != null && objects.length > 0), new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { List<File> list = new ArrayList<File>(); for (Object val : objects) { list.add((File) val); } if (!JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption( "sure move file from\n" + list.toString().replace(',', '\n') + "\nto\n" + DEFAULT_BT_DIR, "MOVE")) { return; } StringBuilder sb = new StringBuilder(); File moveTo = null; for (File file : list) { sb.append((file.renameTo( moveTo = new File(DEFAULT_BT_DIR, file.getName())) && moveTo.exists()) ? "" : file + "\n"); } JCommonUtil._jOptionPane_showMessageDialog_info( sb.length() == 0 ? "move success!" : "move failed!\n" + sb); } }) .addJMenuItem("delete this", file.exists(), new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { if (!JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption( "sure delete file \n" + file, "DELETE")) { return; } boolean result = file.delete(); System.out.println("!!!!!" + result + "..." + file.exists()); JCommonUtil._jOptionPane_showMessageDialog_info( result ? "delete success!" : "delete failed!"); } }).show(); if (JMouseEventUtil.buttonLeftClick(2, evt)) { Runtime.getRuntime().exec(String.format("cmd /c call \"%s\"", file)); } } }); swingUtil.addAction(btDirTree, MouseEvent.class, new Action() { File getSingleFile() { return ((JFile) JTreeUtil.newInstance(btDirTree).getSelectItem().getUserObject()).getFile(); } public void action(EventObject evt) throws Exception { int selectCount = btDirTree.getSelectionModel().getSelectionCount(); if (selectCount == 1) { final File file = getSingleFile(); JPopupMenuUtil.newInstance(btDirTree).applyEvent(evt).addJMenuItem("delete this", selectCount == 1 && file.exists(), new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { if (file.isFile()) { if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption( "sure delete FILE : \n" + file, "WARNING")) { file.delete(); JCommonUtil._jOptionPane_showMessageDialog_info( (file.exists() ? "delete failed!" : "delete success!")); } } if (file.isDirectory()) { StringBuilder sb = new StringBuilder(); if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption( "sure delete DIR : \n" + file, "WARNING")) { List<Boolean> delL = new ArrayList<Boolean>(); for (File f : file.listFiles()) { if (fileExtensionPattern.matcher(f.getName()).find() || f.length() > 1000000L) { if (!JCommonUtil ._JOptionPane_showConfirmDialog_yesNoOption( "delete this : \n" + f, "CHECK AGAIN")) { continue; } delL.add(f.delete()); } delL.add(f.delete()); } for (File f : file.listFiles()) { if (f.exists()) { sb.append(f + "\n"); } } System.out.println("delL.contains(false)==================>" + delL.contains(false)); } if (!file.delete()) { sb.append(file + "\n"); } JCommonUtil._jOptionPane_showMessageDialog_info( sb.length() > 0 ? "delete failed!\nlist:\n" + sb : "delete success!"); if (sb.length() == 0) { DefaultMutableTreeNode node = JTreeUtil.newInstance(btDirTree) .getSelectItem(); System.out.println( JTreeUtil.newInstance(btDirTree).removeNode(node)); } } } }).addJMenuItem("open dir", new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { File openTarget = file; if (file.isFile()) { openTarget = file.getParentFile(); } try { Desktop.getDesktop().open(openTarget); } catch (IOException e) { JCommonUtil.handleException(e); } } }).show(); } } }); swingUtil.addAction(btDirTree, PropertyChangeEvent.class, new Action() { public void action(EventObject evt) throws Exception { List<File> list = new ArrayList<File>(); for (DefaultMutableTreeNode node : JTreeUtil.newInstance(btDirTree).getSelectItems()) { JFile jfile = (JFile) node.getUserObject(); if (jfile.getFile().isDirectory()) { for (File f : jfile.getFile().listFiles(new FilenameFilter() { public boolean accept(File paramFile, String paramString) { return fileExtensionPattern.matcher(paramString).find(); } })) { System.out.println(f.getName() + "...." + f.length()); list.add(f); } } } Collections.sort(list, new Comparator<File>() { public int compare(File paramT1, File paramT2) { return paramT1.lastModified() > paramT2.lastModified() ? -1 : 1; } }); btMovList.setModel(JListUtil.createModel(list.iterator())); } }); } this.setSize(702, 422); loadDirVids(); reload3DSDir(); } catch (Exception e) { e.printStackTrace(); } }
From source file:it.iit.genomics.cru.igb.bundles.mi.view.MITable.java
@Override public String getToolTipText(MouseEvent e) { String tip = null;/* w w w. j av a 2s . c o m*/ java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); int colIndex = columnAtPoint(p); try { ToolTipManager.sharedInstance().setInitialDelay(500); if (colIndex == MITableModel.STRUCTURES_COLUMN) { return ""; } // comment row, exclude heading if (rowIndex >= 0) { int modelRow = rowAtPoint(e.getPoint()); // getSelectedRow(); //convertRowIndexToModel(getSelectedRow()); Object value = getValueAt(modelRow, colIndex); if (colIndex == MITableModel.SYMS1_COLUMN || colIndex == MITableModel.SYMS2_COLUMN || colIndex == MITableModel.INTERACTOR1_COLUMN || colIndex == MITableModel.INTERACTOR2_COLUMN) { MoleculeEntry entry = (MoleculeEntry) value; tip = entry.getGeneName() + " (" + entry.getUniprotAc() + ", " + entry.getOrganism() + ")"; } else if (colIndex == MITableModel.TRACK_COLUMN) { if (JButton.class.isInstance(value)) { tip = "Press this button to create a new track for this interaction"; } else { tip = ((JLabel) value).getText(); } } else if (colIndex == MITableModel.INTERACTION_TYPE_COLUMN) { Interaction interaction = (Interaction) value; tip = "<html>Type: " + StringUtils.join(interaction.getInteractionTypes(), ", ") + "<br/>Method: " + StringUtils.join(interaction.getMethods(), ", ") + "<br/>Bibliographic references: " + StringUtils.join(interaction.getBibRefs(), ", ") + "</html>"; } else { tip = value.toString(); } } } catch (RuntimeException e1) { igbLogger.getLogger().error("exception, row " + rowIndex, e1); // catch null pointer exception if mouse is over an empty line } return tip; }
From source file:com.isti.traceview.common.TraceViewChartPanel.java
/** * Switches the display of tooltips for the panel on or off. Note that tooltips can only be * displayed if the chart has been configured to generate tooltip items. * // w ww . ja va2 s . c om * @param flag * <code>true</code> to enable tooltips, <code>false</code> to disable tooltips. */ public void setDisplayToolTips(boolean flag) { if (flag) { ToolTipManager.sharedInstance().registerComponent(this); } else { ToolTipManager.sharedInstance().unregisterComponent(this); } }