List of usage examples for javax.swing JButton setToolTipText
@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.") public void setToolTipText(String text)
From source file:JXTransformer.java
private JPanel createStressTestPanel() { JPanel panel = new JPanel(); TitledBorder titledBorder = BorderFactory.createTitledBorder("Stress test (with tooltips)"); titledBorder.setTitleJustification(TitledBorder.CENTER); panel.setBorder(titledBorder);/*from www . ja v a 2 s. c om*/ JButton lowerButton = new JButton("Button"); lowerButton.setLayout(new FlowLayout()); lowerButton.setToolTipText("Lower button"); JButton middleButton = new JButton(); middleButton.setToolTipText("Middle button"); middleButton.setLayout(new FlowLayout()); lowerButton.add(middleButton); JButton upperButton = new JButton("Upper button"); upperButton.setToolTipText("Upper button"); middleButton.add(upperButton); panel.add(createTransformer(lowerButton)); return panel; }
From source file:com.eviware.soapui.support.components.SimpleForm.java
public JButton appendButton(String label, String tooltip) { JButton button = new JButton(); button.setToolTipText(StringUtils.defaultIfEmpty(tooltip, null)); button.getAccessibleContext().setAccessibleDescription(tooltip); append(label, button);/*from w w w . j a v a 2 s . co m*/ return button; }
From source file:org.drugis.addis.gui.builder.SMAAView.java
private JButton createExportButton() { JButton expButton = new JButton("Export model to JSON"); expButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FileSaveDialog dialog = new FileSaveDialog(d_mainWindow, "json", "JSON") { @Override// w w w . j a v a 2s . c o m public void doAction(String path, String extension) { d_pm.saveSmaa(path); } }; dialog.saveActions(); } }); expButton.setToolTipText("Save SMAA model to JSON."); return expButton; }
From source file:net.sf.jabref.gui.fieldeditors.FileListEditor.java
public FileListEditor(JabRefFrame frame, BibDatabaseContext databaseContext, String fieldName, String content, EntryEditor entryEditor) {/*w w w . j a v a 2 s . com*/ this.frame = frame; this.databaseContext = databaseContext; this.fieldName = fieldName; this.entryEditor = entryEditor; label = new FieldNameLabel(fieldName); tableModel = new FileListTableModel(); setText(content); setModel(tableModel); JScrollPane sPane = new JScrollPane(this); setTableHeader(null); addMouseListener(new TableClickListener()); JButton add = new JButton(IconTheme.JabRefIcon.ADD_NOBOX.getSmallIcon()); add.setToolTipText(Localization.lang("New file link (INSERT)")); JButton remove = new JButton(IconTheme.JabRefIcon.REMOVE_NOBOX.getSmallIcon()); remove.setToolTipText(Localization.lang("Remove file link (DELETE)")); JButton up = new JButton(IconTheme.JabRefIcon.UP.getSmallIcon()); JButton down = new JButton(IconTheme.JabRefIcon.DOWN.getSmallIcon()); auto = new JButton(Localization.lang("Get fulltext")); JButton download = new JButton(Localization.lang("Download from URL")); add.setMargin(new Insets(0, 0, 0, 0)); remove.setMargin(new Insets(0, 0, 0, 0)); up.setMargin(new Insets(0, 0, 0, 0)); down.setMargin(new Insets(0, 0, 0, 0)); add.addActionListener(e -> addEntry()); remove.addActionListener(e -> removeEntries()); up.addActionListener(e -> moveEntry(-1)); down.addActionListener(e -> moveEntry(1)); auto.addActionListener(e -> autoSetLinks()); download.addActionListener(e -> downloadFile()); FormBuilder builder = FormBuilder.create() .layout(new FormLayout("fill:pref,1dlu,fill:pref,1dlu,fill:pref", "fill:pref,fill:pref")); builder.add(up).xy(1, 1); builder.add(add).xy(3, 1); builder.add(auto).xy(5, 1); builder.add(down).xy(1, 2); builder.add(remove).xy(3, 2); builder.add(download).xy(5, 2); panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(sPane, BorderLayout.CENTER); panel.add(builder.getPanel(), BorderLayout.EAST); TransferHandler transferHandler = new FileListEditorTransferHandler(frame, entryEditor, null); setTransferHandler(transferHandler); panel.setTransferHandler(transferHandler); // Add an input/action pair for deleting entries: getInputMap().put(KeyStroke.getKeyStroke("DELETE"), "delete"); getActionMap().put("delete", new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { int row = getSelectedRow(); removeEntries(); row = Math.min(row, getRowCount() - 1); if (row >= 0) { setRowSelectionInterval(row, row); } } }); // Add an input/action pair for inserting an entry: getInputMap().put(KeyStroke.getKeyStroke("INSERT"), "insert"); getActionMap().put("insert", new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { addEntry(); } }); // Add input/action pair for moving an entry up: getInputMap().put(Globals.getKeyPrefs().getKey(KeyBinding.FILE_LIST_EDITOR_MOVE_ENTRY_UP), "move up"); getActionMap().put("move up", new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { moveEntry(-1); } }); // Add input/action pair for moving an entry down: getInputMap().put(Globals.getKeyPrefs().getKey(KeyBinding.FILE_LIST_EDITOR_MOVE_ENTRY_DOWN), "move down"); getActionMap().put("move down", new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { moveEntry(1); } }); JMenuItem openLink = new JMenuItem(Localization.lang("Open")); menu.add(openLink); openLink.addActionListener(e -> openSelectedFile()); JMenuItem openFolder = new JMenuItem(Localization.lang("Open folder")); menu.add(openFolder); openFolder.addActionListener(e -> { int row = getSelectedRow(); if (row >= 0) { FileListEntry entry = tableModel.getEntry(row); try { String path = ""; // absolute path if (Paths.get(entry.link).isAbsolute()) { path = Paths.get(entry.link).toString(); } else { // relative to file folder for (String folder : databaseContext.getFileDirectory()) { Path file = Paths.get(folder, entry.link); if (Files.exists(file)) { path = file.toString(); break; } } } if (!path.isEmpty()) { JabRefDesktop.openFolderAndSelectFile(path); } else { JOptionPane.showMessageDialog(frame, Localization.lang("File not found"), Localization.lang("Error"), JOptionPane.ERROR_MESSAGE); } } catch (IOException ex) { LOGGER.debug("Cannot open folder", ex); } } }); JMenuItem rename = new JMenuItem(Localization.lang("Move/Rename file")); menu.add(rename); rename.addActionListener(new MoveFileAction(frame, entryEditor, this, false)); JMenuItem moveToFileDir = new JMenuItem(Localization.lang("Move file to file directory")); menu.add(moveToFileDir); moveToFileDir.addActionListener(new MoveFileAction(frame, entryEditor, this, true)); JMenuItem deleteFile = new JMenuItem(Localization.lang("Delete local file")); menu.add(deleteFile); deleteFile.addActionListener(e -> { int row = getSelectedRow(); // no selection if (row != -1) { FileListEntry entry = tableModel.getEntry(row); // null if file does not exist Optional<File> file = FileUtil.expandFilename(databaseContext, entry.link); // transactional delete and unlink try { if (file.isPresent()) { Files.delete(file.get().toPath()); } removeEntries(); } catch (IOException ex) { JOptionPane.showMessageDialog(frame, Localization.lang("File permission error"), Localization.lang("Cannot delete file"), JOptionPane.ERROR_MESSAGE); LOGGER.warn("File permission error while deleting: " + entry.link, ex); } } }); adjustColumnWidth(); }
From source file:jchrest.gui.Shell.java
private JPanel getHistogramPane(Map<Integer, Integer> contentSizes, String label, String title, String xAxis) { int largest = 0; for (Integer key : contentSizes.keySet()) { if (key > largest) largest = key;//from w w w. j a v a 2 s . co m } SimpleHistogramDataset dataset = new SimpleHistogramDataset(label); for (int i = 0; i <= largest; ++i) { SimpleHistogramBin bin = new SimpleHistogramBin((double) i, (double) (i + 1), true, false); int count = 0; if (contentSizes.containsKey(i)) { count = contentSizes.get(i); } bin.setItemCount(count); dataset.addBin(bin); } PlotOrientation orientation = PlotOrientation.VERTICAL; boolean show = false; boolean toolTips = true; boolean urls = false; JFreeChart chart = ChartFactory.createHistogram(title, xAxis, "frequency", dataset, orientation, show, toolTips, urls); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(new ChartPanel(chart, 400, 300, 200, 100, 600, 600, true, true, true, true, true, true)); JButton saveButton = new JButton("Save Data"); saveButton.setToolTipText("Save the histogram data to a CSV file"); saveButton.addActionListener(new SaveHistogramActionListener(this, contentSizes)); panel.add(saveButton, BorderLayout.SOUTH); return panel; }
From source file:org.obiba.onyx.jade.instrument.ricelake.RiceLakeWeightInstrumentRunner.java
/** * Build action buttons sub panel// ww w . ja v a 2 s .com */ protected JPanel buildActionButtonSubPanel() { JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); panel.add(Box.createHorizontalGlue()); panel.add(saveButton); JButton resetButton = new JButton(resourceBundle.getString("Reset")); resetButton.setMnemonic('R'); resetButton.setToolTipText(resourceBundle.getString("ToolTip.Reset_measurement")); panel.add(Box.createRigidArea(new Dimension(10, 0))); panel.add(resetButton); JButton cancelButton = new JButton(resourceBundle.getString("Cancel")); cancelButton.setMnemonic('A'); cancelButton.setToolTipText(resourceBundle.getString("ToolTip.Cancel_measurement")); panel.add(Box.createRigidArea(new Dimension(10, 0))); panel.add(cancelButton); JButton configureButton = new JButton(resourceBundle.getString("Configure")); configureButton.setMnemonic('C'); configureButton.setToolTipText(resourceBundle.getString("ToolTip.Configure")); panel.add(Box.createRigidArea(new Dimension(10, 0))); panel.add(configureButton); // Configure button listener configureButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { configure(); } }); // Reset button listener resetButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { clearData(); } }); // Save button listener. saveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { sendOutputToServer(); } }); // Cancel button listener. cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { confirmOnExit(); } }); panel.setAlignmentX(Component.LEFT_ALIGNMENT); return (panel); }
From source file:ToolBarDemo2.java
protected void addButtons(JToolBar toolBar) { JButton button = null; //first button button = makeNavigationButton("Back24", PREVIOUS, "Back to previous something-or-other", "Previous"); toolBar.add(button);//w w w . java 2s. c o m //second button button = makeNavigationButton("Up24", UP, "Up to something-or-other", "Up"); toolBar.add(button); //third button button = makeNavigationButton("Forward24", NEXT, "Forward to something-or-other", "Next"); toolBar.add(button); //separator toolBar.addSeparator(); //fourth button button = new JButton("Another button"); button.setActionCommand(SOMETHING_ELSE); button.setToolTipText("Something else"); button.addActionListener(this); toolBar.add(button); //fifth component is NOT a button! JTextField textField = new JTextField("A text field"); textField.setColumns(10); textField.addActionListener(this); textField.setActionCommand(TEXT_ENTERED); toolBar.add(textField); }
From source file:jchrest.gui.VisualSearchPane.java
private JPanel runTrainingButtons() { JPanel panel = new JPanel(); _trainingTimes = new XYSeries("CHREST model"); _trainAction = new TrainAction(); JButton trainButton = new JButton(_trainAction); trainButton.setToolTipText("Train a fresh CHREST model up to the given network size"); _stopAction = new StopAction(); _stopAction.setEnabled(false);//w w w . j av a2 s . co m JButton stopButton = new JButton(_stopAction); stopButton.setToolTipText("Stop the current training"); _feedback = new JProgressBar(0, 100); _feedback.setToolTipText("Proportion of target network size"); _feedback.setValue(0); _feedback.setStringPainted(true); panel.add(trainButton); panel.add(stopButton); panel.add(_feedback); return panel; }
From source file:jchrest.gui.VisualSearchPane.java
private JPanel runAnalysisButtons(JSpinner numFixations) { JPanel panel = new JPanel(); _analyseAction = new AnalyseAction(numFixations); JButton analyseButton = new JButton(_analyseAction); analyseButton.setToolTipText("Analyse CHREST model on all scenes"); _stopAnalysisAction = new StopAnalysisAction(); _stopAnalysisAction.setEnabled(false); JButton stopAnalysisButton = new JButton(_stopAnalysisAction); stopAnalysisButton.setToolTipText("Stop the current analysis"); _feedbackAnalysis = new JProgressBar(0, 100); _feedbackAnalysis.setToolTipText("Proportion of scenes analysed"); _feedbackAnalysis.setValue(0);/*w ww .ja v a 2 s . c o m*/ _feedbackAnalysis.setStringPainted(true); panel.add(analyseButton); panel.add(stopAnalysisButton); panel.add(_feedbackAnalysis); return panel; }
From source file:ConfigFiles.java
public ConfigFiles(Dimension screensize) { // initializeFileBrowser(); paths = new JPanel(); paths.setBackground(Color.WHITE); //paths.setBorder(BorderFactory.createTitledBorder("Paths")); paths.setLayout(null);// w w w .j a v a 2s .c o m paths.setPreferredSize(new Dimension(930, 1144)); paths.setSize(new Dimension(930, 1144)); paths.setMinimumSize(new Dimension(930, 1144)); paths.setMaximumSize(new Dimension(930, 1144)); //paths.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); setLayout(null); ttcpath = new JTextField(); addPanel("TestCase Source Path", "Master directory with the test cases that can" + " be run by the framework", ttcpath, RunnerRepository.TESTSUITEPATH, 10, true, null); tMasterXML = new JTextField(); tUsers = new JTextField(); addPanel("Projects Path", "Location of projects XML files", tUsers, RunnerRepository.REMOTEUSERSDIRECTORY, 83, true, null); tSuites = new JTextField(); addPanel("Predefined Suites Path", "Location of predefined suites", tSuites, RunnerRepository.PREDEFINEDSUITES, 156, true, null); testconfigpath = new JTextField(); addPanel("Test Configuration Path", "Test Configuration path", testconfigpath, RunnerRepository.TESTCONFIGPATH, 303, true, null); tepid = new JTextField(); addPanel("EP name File", "Location of the file that contains" + " the Ep name list", tepid, RunnerRepository.REMOTEEPIDDIR, 595, true, null); tlog = new JTextField(); addPanel("Logs Path", "Location of the directory that stores the most recent log files." + " The files are re-used each Run.", tlog, RunnerRepository.LOGSPATH, 667, true, null); tsecondarylog = new JTextField(); JPanel p = addPanel("Secondary Logs Path", "Location of the directory that archives copies of the most recent log files, with" + " original file names appended with <.epoch time>", tsecondarylog, RunnerRepository.SECONDARYLOGSPATH, 930, true, null); logsenabled.setSelected(Boolean.parseBoolean(RunnerRepository.PATHENABLED)); logsenabled.setBackground(Color.WHITE); p.add(logsenabled); JPanel p7 = new JPanel(); p7.setBackground(Color.WHITE); TitledBorder border7 = BorderFactory.createTitledBorder("Log Files"); border7.setTitleFont(new Font("Arial", Font.PLAIN, 14)); border7.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1)); p7.setBorder(border7); p7.setLayout(new BoxLayout(p7, BoxLayout.Y_AXIS)); p7.setBounds(80, 740, 800, 190); paths.add(p7); JTextArea log2 = new JTextArea("All the log files that will be monitored"); log2.setWrapStyleWord(true); log2.setLineWrap(true); log2.setEditable(false); log2.setCursor(null); log2.setOpaque(false); log2.setFocusable(false); log2.setBorder(null); log2.setFont(new Font("Arial", Font.PLAIN, 12)); log2.setBackground(getBackground()); log2.setMaximumSize(new Dimension(170, 25)); log2.setPreferredSize(new Dimension(170, 25)); JPanel p71 = new JPanel(); p71.setBackground(Color.WHITE); p71.setLayout(new GridLayout()); p71.setMaximumSize(new Dimension(700, 13)); p71.setPreferredSize(new Dimension(700, 13)); p71.add(log2); JPanel p72 = new JPanel(); p72.setBackground(Color.WHITE); p72.setLayout(new BoxLayout(p72, BoxLayout.Y_AXIS)); trunning = new JTextField(); p72.add(addField(trunning, "Running: ", 0)); tdebug = new JTextField(); p72.add(addField(tdebug, "Debug: ", 1)); tsummary = new JTextField(); p72.add(addField(tsummary, "Summary: ", 2)); tinfo = new JTextField(); p72.add(addField(tinfo, "Info: ", 3)); tcli = new JTextField(); p72.add(addField(tcli, "Cli: ", 4)); p7.add(p71); p7.add(p72); libpath = new JTextField(); addPanel("Library path", "Secondary user library path", libpath, RunnerRepository.REMOTELIBRARY, 229, true, null); JPanel p8 = new JPanel(); p8.setBackground(Color.WHITE); TitledBorder border8 = BorderFactory.createTitledBorder("File"); border8.setTitleFont(new Font("Arial", Font.PLAIN, 14)); border8.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1)); p8.setBorder(border8); p8.setLayout(null); p8.setBounds(80, 1076, 800, 50); if (PermissionValidator.canChangeFWM()) { paths.add(p8); } JButton save = new JButton("Save"); save.setToolTipText("Save and automatically load config"); save.setBounds(490, 20, 70, 20); save.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { saveXML(false, "fwmconfig"); loadConfig("fwmconfig.xml"); } }); p8.add(save); // if(!PermissionValidator.canChangeFWM()){ // save.setEnabled(false); // } JButton saveas = new JButton("Save as"); saveas.setBounds(570, 20, 90, 20); saveas.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { String filename = CustomDialog.showInputDialog(JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, ConfigFiles.this, "File Name", "Please enter file name"); if (!filename.equals("NULL")) { saveXML(false, filename); } } }); p8.add(saveas); final JButton loadXML = new JButton("Load Config"); loadXML.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { try { String[] configs = RunnerRepository .getRemoteFolderContent(RunnerRepository.USERHOME + "/twister/config/"); JComboBox combo = new JComboBox(configs); int resp = (Integer) CustomDialog.showDialog(combo, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, ConfigFiles.this, "Config", null); final String config; if (resp == JOptionPane.OK_OPTION) config = combo.getSelectedItem().toString(); else config = null; if (config != null) { new Thread() { public void run() { setEnabledTabs(false); JFrame progress = new JFrame(); progress.setAlwaysOnTop(true); progress.setLocation((int) loadXML.getLocationOnScreen().getX(), (int) loadXML.getLocationOnScreen().getY()); progress.setUndecorated(true); JProgressBar bar = new JProgressBar(); bar.setIndeterminate(true); progress.add(bar); progress.pack(); progress.setVisible(true); loadConfig(config); progress.dispose(); setEnabledTabs(true); } }.start(); } } catch (Exception e) { e.printStackTrace(); } } }); loadXML.setBounds(670, 20, 120, 20); p8.add(loadXML); // if(!PermissionValidator.canChangeFWM()){ // loadXML.setEnabled(false); // } tdbfile = new JTextField(); addPanel("Database XML path", "File location for database configuration", tdbfile, RunnerRepository.REMOTEDATABASECONFIGPATH + RunnerRepository.REMOTEDATABASECONFIGFILE, 375, true, null); temailfile = new JTextField(); // emailpanel = (JPanel) addPanel("Email XML path", "File location for email configuration", temailfile, RunnerRepository.REMOTEEMAILCONFIGPATH + RunnerRepository.REMOTEEMAILCONFIGFILE, 448, true, null) .getParent(); //paths.remove(emailpanel); // emailpanel.setBounds(360,440,350,100); // RunnerRepository.window.mainpanel.p4.getEmails().add(emailpanel); tglobalsfile = new JTextField(); addPanel("Globals XML file", "File location for globals parameters", tglobalsfile, RunnerRepository.GLOBALSREMOTEFILE, 521, true, null); tceport = new JTextField(); addPanel("Central Engine Port", "Central Engine port", tceport, RunnerRepository.getCentralEnginePort(), 1003, false, null); // traPort = new JTextField(); // addPanel("Resource Allocator Port","Resource Allocator Port", // traPort,RunnerRepository.getResourceAllocatorPort(),808,false,null); // thttpPort = new JTextField(); // addPanel("HTTP Server Port","HTTP Server Port",thttpPort, // RunnerRepository.getHTTPServerPort(),740,false,null); //paths.add(loadXML); if (!PermissionValidator.canChangeFWM()) { ttcpath.setEnabled(false); tMasterXML.setEnabled(false); tUsers.setEnabled(false); tepid.setEnabled(false); tSuites.setEnabled(false); tlog.setEnabled(false); trunning.setEnabled(false); tdebug.setEnabled(false); tsummary.setEnabled(false); tinfo.setEnabled(false); tcli.setEnabled(false); tdbfile.setEnabled(false); temailfile.setEnabled(false); tceport.setEnabled(false); libpath.setEnabled(false); tsecondarylog.setEnabled(false); testconfigpath.setEnabled(false); tglobalsfile.setEnabled(false); logsenabled.setEnabled(false); } }