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:dpcs.AppPackagesList.java
@SuppressWarnings({ "unchecked", "rawtypes", "deprecation" }) public AppPackagesList() { setResizable(false);// w w w.j a v a 2s . c om setTitle("App Packages List"); setIconImage(Toolkit.getDefaultToolkit().getImage(AppPackagesList.class.getResource("/graphics/Icon.png"))); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setBounds(100, 100, 479, 451); contentPane = new JPanel(); contentPane.setBackground(Color.WHITE); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(22, 12, 428, 333); contentPane.add(scrollPane); JButton btnRefresh = new JButton("Refresh"); btnRefresh.setToolTipText("Refresh the apps list"); btnRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { Process p1 = Runtime.getRuntime().exec("adb shell pm list packages > /sdcard/.allapps.txt"); p1.waitFor(); Process p2 = Runtime.getRuntime().exec("adb pull /sdcard/.allapps.txt"); p2.waitFor(); Process p3 = Runtime.getRuntime().exec("adb shell rm /sdcard/.allapps.txt"); p3.waitFor(); lines = IOUtils.readLines(new FileInputStream(".allapps.txt")); values = new String[lines.size()]; values = lines.toArray(values); moddedvalues = new String[values.length]; for (int i = 0; i < values.length; i++) { moddedvalues[i] = values[i].substring(8); } applist = new JList(); applist.setModel(new AbstractListModel() { public int getSize() { return moddedvalues.length; } public Object getElementAt(int index) { return moddedvalues[index]; } }); scrollPane.setViewportView(applist); File file = new File(".allapps.txt"); if (file.exists() && !file.isDirectory()) { file.delete(); } } catch (Exception e1) { System.err.println(e1); } } }); btnRefresh.setBounds(125, 357, 220, 47); contentPane.add(btnRefresh); try { Process p1 = Runtime.getRuntime().exec("adb shell pm list packages > /sdcard/.allapps.txt"); p1.waitFor(); Process p2 = Runtime.getRuntime().exec("adb pull /sdcard/.allapps.txt"); p2.waitFor(); Process p3 = Runtime.getRuntime().exec("adb shell rm /sdcard/.allapps.txt"); p3.waitFor(); lines = IOUtils.readLines(new FileInputStream(".allapps.txt")); values = new String[lines.size()]; values = lines.toArray(values); moddedvalues = new String[values.length]; for (int i = 0; i < values.length; i++) { moddedvalues[i] = values[i].substring(8); } applist = new JList(); applist.setModel(new AbstractListModel() { public int getSize() { return moddedvalues.length; } public Object getElementAt(int index) { return moddedvalues[index]; } }); scrollPane.setViewportView(applist); File file = new File(".allapps.txt"); if (file.exists() && !file.isDirectory()) { file.delete(); } } catch (Exception e1) { System.err.println(e1); } }
From source file:components.ToolBarDemo2.java
protected JButton makeNavigationButton(String imageName, String actionCommand, String toolTipText, String altText) {/*from w w w .j av a 2s. com*/ //Look for the image. String imgLocation = "images/" + imageName + ".gif"; URL imageURL = ToolBarDemo2.class.getResource(imgLocation); //Create and initialize the button. JButton button = new JButton(); button.setActionCommand(actionCommand); button.setToolTipText(toolTipText); button.addActionListener(this); if (imageURL != null) { //image found button.setIcon(new ImageIcon(imageURL, altText)); } else { //no image found button.setText(altText); System.err.println("Resource not found: " + imgLocation); } return button; }
From source file:net.brtly.monkeyboard.plugin.ConsolePanel.java
public ConsolePanel(PluginDelegate service) { super(service); setLayout(new MigLayout("inset 5", "[grow][:100:100][24:n:24][24:n:24]", "[::24][grow]")); JComboBox comboBox = new JComboBox(); comboBox.setToolTipText("Log Level"); comboBox.setMaximumRowCount(6);// www .j a v a 2 s. c o m comboBox.setModel( new DefaultComboBoxModel(new String[] { "Fatal", "Error", "Warn", "Info", "Debug", "Trace" })); comboBox.setSelectedIndex(5); add(comboBox, "cell 1 0,growx"); JButton btnC = new JButton(""); btnC.setToolTipText("Clear Buffer"); btnC.setIcon(new ImageIcon(ConsolePanel.class.getResource("/img/clear-document.png"))); btnC.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { logPangrams(); } }); add(btnC, "cell 2 0,wmax 24,hmax 26"); tglbtnV = new JToggleButton(""); tglbtnV.setToolTipText("Auto Scroll"); tglbtnV.setIcon(new ImageIcon(ConsolePanel.class.getResource("/img/auto-scroll.png"))); tglbtnV.setSelected(true); tglbtnV.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { if (ev.getStateChange() == ItemEvent.SELECTED) { _table.setAutoScroll(true); } else if (ev.getStateChange() == ItemEvent.DESELECTED) { _table.setAutoScroll(false); } } }); add(tglbtnV, "cell 3 0,wmax 24,hmax 26"); scrollPane = new JScrollPane(); scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { // TODO figure out what to do with this event? } }); add(scrollPane, "cell 0 1 4 1,grow"); _table = new JLogTable("Time", "Source", "Message"); _table.getColumnModel().getColumn(0).setMinWidth(50); _table.getColumnModel().getColumn(0).setPreferredWidth(50); _table.getColumnModel().getColumn(0).setMaxWidth(100); _table.getColumnModel().getColumn(1).setMinWidth(50); _table.getColumnModel().getColumn(1).setPreferredWidth(50); _table.getColumnModel().getColumn(1).setMaxWidth(100); _table.getColumnModel().getColumn(2).setMinWidth(50); _table.getColumnModel().getColumn(2).setWidth(255); _table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); scrollPane.setViewportView(_table); _appender = new JLogTableAppender(); _appender.setThreshold(Level.ALL); Logger.getRootLogger().addAppender(_appender); }
From source file:ToolBarDemo2.java
protected JButton makeNavigationButton(String imageName, String actionCommand, String toolTipText, String altText) {/*from w w w . j a v a 2 s.c o m*/ //Look for the image. String imgLocation = "toolbarButtonGraphics/navigation/" + imageName + ".gif"; URL imageURL = ToolBarDemo2.class.getResource(imgLocation); //Create and initialize the button. JButton button = new JButton(); button.setActionCommand(actionCommand); button.setToolTipText(toolTipText); button.addActionListener(this); if (imageURL != null) { //image found button.setIcon(new ImageIcon(imageURL, altText)); } else { //no image found button.setText(altText); System.err.println("Resource not found: " + imgLocation); } return button; }
From source file:com.opendoorlogistics.components.reports.ReporterPanel.java
public ReporterPanel(final ComponentConfigurationEditorAPI api, final ReporterConfig config) { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // setAlignmentX(LEFT_ALIGNMENT); // add config panel ReporterConfigPanel configPanel = new ReporterConfigPanel(config); configPanel.setBorder(createBorder("Export and processing options")); add(configPanel);/*from www. j a va 2 s.c om*/ // add gap add(Box.createRigidArea(new Dimension(1, 10))); // add tools panel JPanel toolContainer = new JPanel(); toolContainer.setLayout(new BorderLayout()); toolContainer.setBorder(createBorder("Tools")); add(toolContainer); JPanel tools = new JPanel(); toolContainer.add(tools, BorderLayout.NORTH); toolContainer.setMaximumSize(new Dimension(Integer.MAX_VALUE, api.isInstruction() ? 120 : 80)); // tools.setLayout(new BoxLayout(tools, BoxLayout.X_AXIS)); tools.setLayout(new GridLayout(api == null || api.isInstruction() ? 2 : 1, 3)); JButton compileButton = new JButton("Compile .jrxml file"); compileButton.setToolTipText("Compile a JasperReports .jrxml file"); compileButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { File file = ReporterTools.chooseJRXMLFile(api.getComponentPreferences(), LAST_JRXML_TO_COMPILE, ReporterPanel.this); if (file == null) { return; } final ExecutionReport report = api.getApi().uiFactory().createExecutionReport(); try { JasperDesign design = JRXmlLoader.load(file); if (design == null) { throw new RuntimeException("File to load jrxml: " + file.getAbsolutePath()); } String filename = FilenameUtils.removeExtension(file.getAbsolutePath()) + ".jasper"; JasperCompileManager.compileReportToFile(design, filename); } catch (Throwable e2) { report.setFailed(e2); report.setFailed("Failed to compile file " + file.getAbsolutePath()); } finally { if (report.isFailed()) { Window window = SwingUtilities.getWindowAncestor(ReporterPanel.this); api.getApi().uiFactory() .createExecutionReportDialog( JFrame.class.isInstance(window) ? (JFrame) window : null, "Compiling jrxml file", report, true) .setVisible(true); } else { JOptionPane.showMessageDialog(ReporterPanel.this, "Compiled jxrml successfully: " + file.getAbsolutePath()); } } } }); tools.add(compileButton); for (final OrientationEnum orientation : new OrientationEnum[] { OrientationEnum.LANDSCAPE, OrientationEnum.PORTRAIT }) { // create export button JButton button = new JButton("Export " + orientation.getName().toLowerCase() + " template"); button.setToolTipText( "Export template (editable .jrxml and compiled .jasper) based on the input tables (" + orientation.getName().toLowerCase() + ")"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ReporterTools.exportReportTemplate(api, config, orientation, ReporterPanel.this); } }); tools.add(button); // create view button if (api.isInstruction()) { final String title = "View basic " + orientation.getName().toLowerCase() + " report"; button = new JButton(title); button.setToolTipText("View basic report based on the input tables (" + orientation.getName().toLowerCase() + ")"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (api != null) { api.executeInPlace(title, orientation == OrientationEnum.LANDSCAPE ? ReporterComponent.VIEW_BASIC_LANDSCAPE : ReporterComponent.VIEW_BASIC_PORTRAIT); } } }); tools.add(button); } } }
From source file:ToolbarDemo.java
protected JMenuBar createMenuBar() { final JMenuBar menuBar = new JMenuBar(); JMenu mFile = new JMenu("File"); mFile.setMnemonic('f'); ImageIcon iconNew = new ImageIcon("file_new.gif"); Action actionNew = new AbstractAction("New", iconNew) { public void actionPerformed(ActionEvent e) { System.out.println("new action"); }//w w w .j av a2 s . c o m }; JMenuItem item = mFile.add(actionNew); mFile.add(item); ImageIcon iconOpen = new ImageIcon("file_open.gif"); Action actionOpen = new AbstractAction("Open...", iconOpen) { public void actionPerformed(ActionEvent e) { System.out.println("open action"); } }; item = mFile.add(actionOpen); mFile.add(item); ImageIcon iconSave = new ImageIcon("file_save.gif"); Action actionSave = new AbstractAction("Save...", iconSave) { public void actionPerformed(ActionEvent e) { System.out.println("save action"); } }; item = mFile.add(actionSave); mFile.add(item); mFile.addSeparator(); Action actionExit = new AbstractAction("Exit") { public void actionPerformed(ActionEvent e) { System.exit(0); } }; item = mFile.add(actionExit); item.setMnemonic('x'); menuBar.add(mFile); toolBar = new JToolBar(); JButton btn1 = toolBar.add(actionNew); btn1.setToolTipText("New text"); JButton btn2 = toolBar.add(actionOpen); btn2.setToolTipText("Open text file"); JButton btn3 = toolBar.add(actionSave); btn3.setToolTipText("Save text file"); ActionListener fontListener = new ActionListener() { public void actionPerformed(ActionEvent e) { updateMonitor(); } }; JMenu mFont = new JMenu("Font"); mFont.setMnemonic('o'); ButtonGroup group = new ButtonGroup(); fontMenus = new JMenuItem[FontNames.length]; for (int k = 0; k < FontNames.length; k++) { int m = k + 1; fontMenus[k] = new JRadioButtonMenuItem(m + " " + FontNames[k]); boolean selected = (k == 0); fontMenus[k].setSelected(selected); fontMenus[k].setMnemonic('1' + k); fontMenus[k].setFont(fonts[k]); fontMenus[k].addActionListener(fontListener); group.add(fontMenus[k]); mFont.add(fontMenus[k]); } mFont.addSeparator(); boldMenu.setMnemonic('b'); Font fn = fonts[1].deriveFont(Font.BOLD); boldMenu.setFont(fn); boldMenu.setSelected(false); boldMenu.addActionListener(fontListener); mFont.add(boldMenu); italicMenu.setMnemonic('i'); fn = fonts[1].deriveFont(Font.ITALIC); italicMenu.setFont(fn); italicMenu.setSelected(false); italicMenu.addActionListener(fontListener); mFont.add(italicMenu); menuBar.add(mFont); getContentPane().add(toolBar, BorderLayout.NORTH); return menuBar; }
From source file:fi.smaa.jsmaa.gui.SMAA2GUIFactory.java
@Override protected JButton buildToolBarAddCriterionButton() { JButton button = new JButton(ImageFactory.IMAGELOADER.getIcon(FileNames.ICON_ADDCRITERION)); button.setToolTipText("Add criterion"); final JPopupMenu addMenu = new JPopupMenu(); addUtilityAddItemsToMenu(addMenu);/*from w ww. j a v a 2 s . c om*/ button.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { addMenu.show((Component) evt.getSource(), evt.getX(), evt.getY()); } }); return button; }
From source file:AliasBean.java
public AliasBean() { aliVector = new Vector(); aliJList = new JList(); // XXX MUST FIX THIS // aliJList.setSelectionMode(JList.SINGLE_SELECTION); aliJList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { int i = aliJList.getSelectedIndex(); if (i < 0) return; Alias al = (Alias) aliVector.get(i); nameTF.setText(al.getName()); addrTF.setText(al.getAddress()); }/*from w w w. j av a2 s. c om*/ }); setLayout(new BorderLayout()); add(BorderLayout.WEST, new JScrollPane(aliJList)); JPanel rightPanel = new JPanel(); add(BorderLayout.EAST, rightPanel); rightPanel.setLayout(new GridLayout(0, 1)); JPanel buttons = new JPanel(); rightPanel.add(buttons); buttons.setLayout(new GridLayout(0, 1, 15, 15)); JButton b; buttons.add(b = new JButton("Set")); b.setToolTipText("Add or Change an alias"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { int i = aliJList.getSelectedIndex(); if (i < 0) { // XXX error dialog?? return; } setAlias(i, nameTF.getText(), addrTF.getText()); } }); buttons.add(b = new JButton("Delete")); b.setToolTipText("Delete the selected alias"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { int i = aliJList.getSelectedIndex(); if (i < 0) { return; } deleteAlias(i); } }); buttons.add(b = new JButton("Apply")); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.err.println("NOT WRITTEN YET"); } }); JPanel fields = new JPanel(); rightPanel.add(fields); fields.setLayout(new GridLayout(2, 2)); fields.add(new JLabel("Name")); fields.add(nameTF = new JTextField(10)); fields.add(new JLabel("Address")); fields.add(addrTF = new JTextField(20)); }
From source file:org.eobjects.datacleaner.widgets.result.PatternFinderResultSwingRendererCrosstabDelegate.java
@Override protected void decorate(CrosstabResult result, DCTable table, DisplayChartCallback displayChartCallback) { super.decorate(result, table, displayChartCallback); table.setAlignment(1, Alignment.RIGHT); final int rowCount = table.getRowCount(); for (int i = 0; i < rowCount; i++) { final Object expressionObject = table.getValueAt(i, 0); final String label = extractString(expressionObject); final String expression = extractExpression(label); final String stringPatternName = "PF: " + label; if (!_catalog.containsStringPattern(stringPatternName)) { DCPanel panel = new DCPanel(); panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); panel.add(Box.createHorizontalStrut(4)); panel.add(new JLabel(label)); final JButton button = WidgetFactory.createSmallButton("images/actions/save.png"); button.setToolTipText("Save as string pattern"); button.addActionListener(new ActionListener() { @Override/* w w w .j a va 2 s . c o m*/ public void actionPerformed(ActionEvent e) { _catalog.addStringPattern(new SimpleStringPattern(stringPatternName, expression)); button.setEnabled(false); } }); panel.add(Box.createHorizontalStrut(4)); panel.add(button); table.setValueAt(panel, i, 0); } } if (isInitiallyCharted(table)) { displayChart(table, displayChartCallback); } }
From source file:com.documentgenerator.view.MainWindow.java
private ArrayList<JMenuItem> getMenuItem(JSONArray jsonMenuItems) { int count = jsonMenuItems.size(), i; menuItems = new ArrayList<>(); for (i = 0; i < count; i++) { jsonMenuItem = (JSONObject) jsonMenuItems.get(i); String menuTitle = (String) jsonMenuItem.get("menuTitle"); ImageIcon imageIcon = new ImageIcon( ClassLoader.getSystemResource((String) jsonMenuItem.get("imageIcon"))); menuItem = new JMenuItem(menuTitle, imageIcon); String className = (String) jsonMenuItem.get("className"); String shortcut = (String) jsonMenuItem.get("shortcut"); Boolean hasSeparator = (Boolean) jsonMenuItem.get("separator"); Boolean hasToolbar = (Boolean) jsonMenuItem.get("hasToolbar"); if (!Strings.isNullOrEmpty(shortcut)) { menuItem.setAccelerator(utils.getKeyStroke(shortcut)); }/* w ww.j a v a 2s . c o m*/ if (className.equals("string")) { menuItem.setActionCommand(menuTitle); menuItem.addActionListener(actionListener); } else { menuItem.setActionCommand(className); menuItem.addActionListener(new MenuItemActionListener(this, className)); } menu.add(menuItem); if (hasToolbar) { JButton button = new JButton(imageIcon); button.setToolTipText(menuTitle); button.addActionListener(new MenuItemActionListener(this, className)); toolBar.add(button); } } return menuItems; }