public CustomIconDemo() { Icon leftButtonIcon = new ArrowIcon(SwingConstants.RIGHT); Icon middleButtonIcon = createImageIcon("images/middle.gif", "the middle button"); Icon rightButtonIcon = new ArrowIcon(SwingConstants.LEFT); b1 = new JButton("Disable middle button", leftButtonIcon); b1.setVerticalTextPosition(AbstractButton.CENTER); b1.setHorizontalTextPosition(AbstractButton.LEADING); b1.setMnemonic(KeyEvent.VK_D); b1.setActionCommand("disable"); b2 = new JButton("Middle button", middleButtonIcon); b2.setVerticalTextPosition(AbstractButton.BOTTOM); b2.setHorizontalTextPosition(AbstractButton.CENTER); b2.setMnemonic(KeyEvent.VK_M); b3 = new JButton("Enable middle button", rightButtonIcon); // Use the default text position of CENTER, TRAILING (RIGHT). b3.setMnemonic(KeyEvent.VK_E); b3.setActionCommand("enable"); b3.setEnabled(false); // Listen for actions on buttons 1 and 3. b1.addActionListener(this); b3.addActionListener(this); b1.setToolTipText("Click this button to disable the middle button."); b2.setToolTipText("This middle button does nothing when you click it."); b3.setToolTipText("Click this button to enable the middle button."); // Add Components to this container, using the default FlowLayout. add(b1); add(b2); add(b3); }
public ButtonDemo() { ImageIcon leftButtonIcon = new ImageIcon("src/images/right.png"); ImageIcon middleButtonIcon = new ImageIcon("src/images/middle.png"); ImageIcon rightButtonIcon = new ImageIcon("src/images/left.png"); b1 = new JButton("가운데 버튼은 사용 불가", leftButtonIcon); b1.setVerticalTextPosition(AbstractButton.CENTER); b1.setHorizontalTextPosition(AbstractButton.LEADING); // aka LEFT, for left-to-right locales b1.setMnemonic(KeyEvent.VK_D); b1.setActionCommand("disable"); b2 = new JButton("Middle button", middleButtonIcon); b2.setVerticalTextPosition(AbstractButton.BOTTOM); b2.setHorizontalTextPosition(AbstractButton.CENTER); b2.setMnemonic(KeyEvent.VK_M); b3 = new JButton("Enable middle button", rightButtonIcon); // Use the default text position of CENTER, TRAILING (RIGHT). b3.setMnemonic(KeyEvent.VK_E); b3.setActionCommand("enable"); b3.setEnabled(false); // Listen for actions on buttons 1 and 3. b1.addActionListener(this); b3.addActionListener(this); b1.setToolTipText("Click this button to disable the middle button."); b2.setToolTipText("This middle button does nothing when you click it."); b3.setToolTipText("Click this button to enable the middle button."); // Add Components to this container, using the default FlowLayout. add(b1); add(b2); add(b3); }
/** Install Add and Remove Buttons into the toolbar */ private void installAddRemovePointButtons() { URL imgURL = ClassLoader.getSystemResource("ch/tbe/pics/plus.gif"); ImageIcon plus = new ImageIcon(imgURL); imgURL = ClassLoader.getSystemResource("ch/tbe/pics/minus.gif"); ImageIcon minus = new ImageIcon(imgURL); add = new JButton(plus); rem = new JButton(minus); add.setToolTipText(workingViewLabels.getString("plus")); rem.setToolTipText(workingViewLabels.getString("minus")); add.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { WorkingView.this.addRemovePoint(true); } }); rem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { WorkingView.this.addRemovePoint(false); } }); add.setContentAreaFilled(false); add.setBorderPainted(false); rem.setContentAreaFilled(false); rem.setBorderPainted(false); toolbar.add(add); toolbar.add(rem); }
/** * Refreshes the undo/redo icons with the last action performed. * * @param oUndoManager, the manager to use to check for undo/redo possibilities. */ public void refreshUndoRedo(UndoManager oUndoManager) { // refresh undo pbUndo.setToolTipText(oUndoManager.getUndoPresentationName()); pbUndo.setEnabled(oUndoManager.canUndo()); // refresh redo pbRedo.setToolTipText(oUndoManager.getRedoPresentationName()); pbRedo.setEnabled(oUndoManager.canRedo()); }
// ------------------------------------------------------------------------------------- protected JPanel createScrolledPdfViewer(String clusterIdAs3DigitString) { final PdfDecoder pdfDecoder = new PdfDecoder(); String urlString = baseUrl + "/" + imageFileNameBase + clusterIdAs3DigitString + imageFileNameSuffix; currentFile = urlString; System.out.println("url: " + urlString); try { pdfDecoder.openPdfFileFromURL(urlString); // System.out.println ("page count: " + pdfDecoder.getPageCount ()); pdfDecoder.decodePage(1); pdfDecoder.setPageParameters(1.0f, 1, PAGE_ROTATION); // values scaling (1=100%). page number pdfDecoder.invalidate(); } catch (Exception e) { e.printStackTrace(); } final ViewerState viewerState = new ViewerState(pdfDecoder.getPageCount()); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); JToolBar toolbar = new JToolBar(); toolbar.setFloatable(false); panel.add(toolbar, BorderLayout.NORTH); JButton backButton = new JButton("<"); backButton.setToolTipText("Back One page"); toolbar.add(backButton); backButton.addActionListener(new BackButtonListener(pdfDecoder, viewerState)); JButton forwardButton = new JButton(">"); forwardButton.setToolTipText("Forward One page"); toolbar.add(forwardButton); forwardButton.addActionListener(new ForwardButtonListener(pdfDecoder, viewerState)); JButton zoomOutButton = new JButton("-"); zoomOutButton.setToolTipText("Zoom Out"); toolbar.add(zoomOutButton); zoomOutButton.addActionListener(new ZoomOutButtonListener(pdfDecoder, viewerState)); JButton zoomInButton = new JButton("+"); zoomInButton.setToolTipText("Zoom In"); toolbar.add(zoomInButton); zoomInButton.addActionListener(new ZoomInButtonListener(pdfDecoder, viewerState)); JScrollPane scrollPane = new JScrollPane(); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); scrollPane.setViewportView(pdfDecoder); panel.add(scrollPane, BorderLayout.CENTER); return panel; } // createScrolledPdfViewer
/** * Make the gui widget for setting the station model * * @return the widget */ private JComponent makeStationModelWidget() { JButton editButton = GuiUtils.getImageButton("/ucar/unidata/idv/images/edit.gif", getClass()); editButton.setToolTipText("Show the plot model editor"); editButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) {} }); label = new JLabel(" "); changeButton = GuiUtils.getImageButton("/auxdata/ui/icons/DownDown.gif", getClass()); changeButton.setToolTipText("Click to change plot model"); changeButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { StationModelManager smm = idv.getStationModelManager(); ObjectListener listener = new ObjectListener(null) { public void actionPerformed(ActionEvent ae) { Misc.run( new Runnable() { public void run() { idv.showWaitCursor(); try { plotModel = (StationModel) theObject; if (plotModel != null) { label.setText(plotModel.getDisplayName()); } method.invoke(plotModelListener, new Object[] {plotModel}); } catch (Exception exc) { idv.logException("Changing plot model", exc); } idv.showNormalCursor(); } }); } }; List items = StationModelCanvas.makeStationModelMenuItems(smm.getStationModels(), listener, smm); items.add(0, GuiUtils.MENU_SEPARATOR); if (addNone) { items.add(0, GuiUtils.makeMenuItem("None", PlotModelComponent.this, "setNone")); } items.add(0, GuiUtils.makeMenuItem("Edit", PlotModelComponent.this, "editPlotModel")); JPopupMenu popup = GuiUtils.makePopupMenu(items); popup.show( changeButton, changeButton.getSize().width / 2, changeButton.getSize().height); } }); return GuiUtils.centerRight(label, GuiUtils.inset(changeButton, new Insets(0, 4, 0, 0))); }
protected void initBtn() { bOk.setText("确定"); bOk.setToolTipText("确定"); bOk.setMargin(new Insets(0, 0, 0, 0)); bOk.setIcon(ExplorerIcons.getExplorerIcon("jprofiler/checkbox_16.png")); bOk.addActionListener(this); bExit.setText("取消"); bExit.setToolTipText("取消"); bExit.setMargin(new Insets(0, 0, 0, 0)); bExit.setIcon(ExplorerIcons.getExplorerIcon("jprofiler/delete.png")); bExit.addActionListener(this); }
/** * Cria e devolve o botão de comando btnLimpar. * * @return botão de comando btnLimpar */ private JButton criarBotaoLimpar() { JButton btn = new JButton("Limpar"); btn.setToolTipText("Limpa o contéudo dos campos de texto"); btn.setMnemonic(KeyEvent.VK_L); btn.addActionListener(trataEvento); return btn; }
/** * Installs a Tool in the Toolbar * * @param toolbar as JToolbar * @param tool, Tool to install */ public void installToolInToolBar(JToolBar toolbar, final Tool tool) { final JButton button; button = new JButton(); button.setMargin(new Insets(0, 0, 0, 0)); if (tool.getItemType() != null) { button.setIcon(tool.getItemType().getIcon()); button.setToolTipText(tool.getItemType().getDescription()); } else { button.setText("Tool"); // For Debugging } toolbar.add(button); toolButtons.add(button); button.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { WorkingView.this.setTool(tool, button); } }); button.setContentAreaFilled(false); button.setBorderPainted(false); button.addMouseListener( new MouseAdapter() { public void mouseEntered(MouseEvent e) { ((JButton) e.getSource()).setBorderPainted(true); } public void mouseExited(MouseEvent e) { ((JButton) e.getSource()).setBorderPainted(false); } }); }
/** * Create a button to go inside of the toolbar. By default this will load an image resource. The * image filename is relative to the classpath (including the '.' directory if its a part of the * classpath), and may either be in a JAR file or a separate file. * * @param key The key in the resource file to serve as the basis of lookups. */ protected JButton createToolbarButton(String key) { URL url = getResource(key + imageSuffix); JButton b = new JButton(new ImageIcon(url)) { @Override public float getAlignmentY() { return 0.5f; } }; b.setRequestFocusEnabled(false); b.setMargin(new Insets(1, 1, 1, 1)); String astr = getProperty(key + actionSuffix); if (astr == null) { astr = key; } Action a = getAction(astr); if (a != null) { b.setActionCommand(astr); b.addActionListener(a); } else { b.setEnabled(false); } String tip = getResourceString(key + tipSuffix); if (tip != null) { b.setToolTipText(tip); } return b; }
/** * Cria e devolve o botão de comando btnSair. * * @return botão de comando btnSair */ private JButton criarBotaoSair() { JButton btn = new JButton("Sair"); btn.setToolTipText("Fecha o programa"); btn.setMnemonic(KeyEvent.VK_S); btn.addActionListener(trataEvento); return btn; }
/** * Cria e devolve o botão de comando btnConverter. * * @return botão de comando btnConverter */ private JButton criarBotaoConverter() { JButton btn = new JButton("Converter"); btn.setMnemonic(KeyEvent.VK_C); btn.setToolTipText("Efectua a conversão centígrados->fahrnheit"); btn.addActionListener(trataEvento); return btn; }
private JButton makeToolbarButton(String name, String toolTipText, String action) { // Create and initialize the button. JButton button = new JButton(makeImageIcon(name)); button.setToolTipText(toolTipText); button.setActionCommand(action); button.addActionListener(this); return button; }
/** Simple convenience routine for adding a button/icon to a Toolbar */ public static JButton addTool(JToolBar toolBar, String name) { JButton b; b = new JButton(new ImageIcon("images/" + name + ".gif", name)); toolBar.add(b); b.setToolTipText(name); b.setMargin(new Insets(0, 0, 0, 0)); b.getAccessibleContext().setAccessibleName(name); return b; }
private void setupPanel() { tf.setEditable(false); BrowseAction browseA = new BrowseAction(tf, false); browse.addActionListener(browseA); DownloadAction da = new DownloadAction(tf); download.addActionListener(da); FormBuilder builder = FormBuilder.create() .layout( new FormLayout( "fill:pref:grow, 4dlu, fill:pref, 4dlu, fill:pref, 4dlu, fill:pref, 4dlu, fill:pref", "p")); builder.add(tf).xy(1, 1); builder.add(browse).xy(3, 1); builder.add(download).xy(5, 1); builder.add(view).xy(7, 1); builder.add(clear).xy(9, 1); pan = builder.getPanel(); view.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { JournalAbbreviationRepository abbr = new JournalAbbreviationRepository(); abbr.readJournalListFromFile(new File(tf.getText())); JTable table = new JTable(JournalAbbreviationsUtil.getTableModel(abbr)); JScrollPane pane = new JScrollPane(table); JOptionPane.showMessageDialog( null, pane, Localization.lang("Journal list preview"), JOptionPane.INFORMATION_MESSAGE); } catch (FileNotFoundException ex) { JOptionPane.showMessageDialog( null, Localization.lang("File '%0' not found", tf.getText()), Localization.lang("Error"), JOptionPane.ERROR_MESSAGE); } } }); clear.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { externals.remove(ExternalFileEntry.this); buildExternalsPanel(); } }); clear.setToolTipText(Localization.lang("Remove")); }
public ShowComp() throws InterruptedException, IOException { super("CONNECTED COMPUTERS"); int x = 0, d = 20; mb = new JMenuBar(); File = new JMenu("File"); mb.add(File); exit = new JMenuItem("Exit"); exit.addActionListener(this); File.add(exit); ta = new JTextArea(); ta.setBounds(20, 30, 315, 470); ta.setEditable(false); add(ta); setJMenuBar(mb); sel = new JLabel("The connected computers are.."); sel.setBounds(15, 5, 300, 30); add(sel); b1 = new JButton("<< BACK"); b1.setBounds(140, 510, 100, 30); b1.setToolTipText("Back to main page"); b1.addActionListener(this); add(b1); setLayout(null); while (x < 360) { x = x + d; setBounds(675, 50, x, 600); this.show(); } // setVisible(true); String s = "192.168.0.", temp = null; Printer printer = new Printer(); printer.start(); Connector connector = new Connector(printer); connector.start(); LinkedList targets = new LinkedList(); for (int i = 1; i <= 255; i++) { temp = s + Integer.toString(i); Target t = new Target(temp); targets.add(t); connector.add(t); } Thread.sleep(2000); connector.shutdown(); connector.join(); for (Iterator i = targets.iterator(); i.hasNext(); ) { Target t = (Target) i.next(); if (!t.shown) t.show(); } setDefaultCloseOperation(DISPOSE_ON_CLOSE); }
public void initComponents() { /** ******************** The main container *************************** */ Container container = this.getContentPane(); container.setLayout(new BorderLayout()); container.setBackground(Color.black); this.setSize(650, 600); this.addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) {} }); /** ************************* MAIN PANEL ******************************* */ mainPanel = new JPanel(); // If put to False: we see the container's background mainPanel.setOpaque(false); mainPanel.setLayout(new BorderLayout()); container.add(mainPanel, BorderLayout.CENTER); allmessagesTextArea = new TextArea(); allmessagesTextArea.setEditable(false); allmessagesTextArea.setFont(new Font("Dialog", 1, 12)); allmessagesTextArea.setForeground(Color.black); allmessagesTextArea.append("Select a session in the list to view its messages"); mainPanel.add(allmessagesTextArea, BorderLayout.CENTER); sessionsList = new List(); sessionsList.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { showMessages(e); } }); sessionsList.setForeground(Color.black); sessionsList.setFont(new Font("Dialog", 1, 14)); mainPanel.add(sessionsList, BorderLayout.WEST); okButton = new JButton(" OK "); okButton.setToolTipText("Returns to the main frame"); okButton.setFont(new Font("Dialog", 1, 16)); okButton.setFocusPainted(false); okButton.setBackground(Color.lightGray); okButton.setBorder(new BevelBorder(BevelBorder.RAISED)); okButton.setVerticalAlignment(SwingConstants.CENTER); okButton.setHorizontalAlignment(SwingConstants.CENTER); container.add(okButton, BorderLayout.SOUTH); okButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { setVisible(false); } }); }
protected JToolBar createToolBar() { JToolBar jtoolbar = new JToolBar(); jtoolbar.putClientProperty("JToolBar.isRollover", Boolean.TRUE); // --------------------------------------- JButton jbuttonClear = new JButton("Clear SQL Statement"); jbuttonClear.setToolTipText("Clear SQL Statement"); jbuttonClear.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionevent) { clear(); } }); // --------------------------------------- JButton jbuttonExecute = new JButton("Execute SQL Statement"); jbuttonExecute.setToolTipText("Execute SQL Statement"); jbuttonExecute.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionevent) { execute(); } }); jtoolbar.addSeparator(); jtoolbar.add(jbuttonClear); jtoolbar.addSeparator(); jtoolbar.add(jbuttonExecute); jtoolbar.addSeparator(); jbuttonClear.setAlignmentY(0.5F); jbuttonClear.setAlignmentX(0.5F); jbuttonExecute.setAlignmentY(0.5F); jbuttonExecute.setAlignmentX(0.5F); return jtoolbar; }
protected void addMyControls() { // add browser-style control buttons JButton home = new JButton(new ImageIcon("data/Home24.gif")); JButton back = new JButton(new ImageIcon("data/Back24.gif")); JButton fwd = new JButton(new ImageIcon("data/Forward24.gif")); home.setToolTipText("Home"); home.addActionListener(this); home.setActionCommand(homeCmd); back.setToolTipText("Back"); back.addActionListener(this); back.setActionCommand(backCmd); back.setEnabled(false); // initially disabled fwd.setToolTipText("Forward"); fwd.addActionListener(this); fwd.setActionCommand(forwardCmd); fwd.setEnabled(false); // initially disabled add(home); add(back); add(fwd); add(new JToolBar.Separator()); // set built-in index variables homeIndex = getComponentIndex(home); backIndex = getComponentIndex(back); forwardIndex = getComponentIndex(fwd); JComboBox comboBox = new JComboBox(); comboBox.setEditable(true); comboBox.addActionListener(this); comboBox.setActionCommand(comboCmd); comboBox.setMaximumRowCount(3); // don't let it get too long comboBox.insertItemAt(mainBrowserURL, 0); // don't start it out empty add(comboBox); comboBoxIndex = getComponentIndex(comboBox); }
/** * constructor - creates and displays a new dialog box to obtain each player's bet before the game * process actually begins * * @param parent - reference to the parent frame of this box * @param modal - whether or not this box should be made modal (whether it MUST be dealt with * before anything else) * @param turnIndex - number to which player is currently betting; used to set the button colors */ public BetInputDialog(BlackJackFrame parent, boolean modal, int turnIndex) { super(parent, modal); this.parent = parent; inputPanel = new JPanel(); buttonsPanel = new JPanel(); betField = new JTextField(10); enterButton = new JButton("Bet!"); enterButton.setToolTipText("Enter your bet for this hand."); skipHandButton = new JButton("Skip Hand"); skipHandButton.setToolTipText("Choose to sit out this hand."); enterButton.addActionListener(this); skipHandButton.addActionListener(this); inputPanel.add(betField); buttonsPanel.add(enterButton); buttonsPanel.add(skipHandButton); setButtonColors(turnIndex); setLayout(new GridLayout(2, 1)); add(inputPanel); add(buttonsPanel); getRootPane().setDefaultButton(enterButton); setTitle( "Starting Hand " + parent.getCurrentHandNumber() + ", " + parent.getCurrentPlayer().getName() + "\'s turn"); setSize(300, 100); setLocationRelativeTo(null); setResizable(false); setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); setVisible(true); }
public void setShowNames(boolean b) { if (shownames == b) return; shownames = b; Iterator it = buttons.keySet().iterator(); while (it.hasNext()) { String command = (String) it.next(); JButton button = (JButton) buttons.get(command); button.setText((shownames) ? command : ""); button.setToolTipText((!shownames) ? command : ""); } setButtonsSize(); }
public Panel_AjoutTour(Game jeu, EcouteurDePanelTerrain edpt, int largeur, int hauteur) { this.jeu = jeu; this.edpt = edpt; setBackground(LookInterface.COULEUR_DE_FOND_PRI); // --------------------- // -- panel des tours -- // --------------------- JPanel pTours = new JPanel(new GridLayout(2, 0)); pTours.setOpaque(false); pTours.setPreferredSize(new Dimension(largeur, hauteur)); String titrePrixAchat = Langue.getTexte(Langue.ID_TXT_PRIX_ACHAT); boutonsTours.add(bTourArcher); bTourArcher.setToolTipText(titrePrixAchat + " : " + Tower_Archer.PRIX_ACHAT); boutonsTours.add(bTourCanon); bTourCanon.setToolTipText(titrePrixAchat + " : " + Tower_Canon.PRIX_ACHAT); boutonsTours.add(bTourAntiAerienne); bTourAntiAerienne.setToolTipText(titrePrixAchat + " : " + Tower_AntiAerial.PRIX_ACHAT); boutonsTours.add(bTourDeGlace); bTourDeGlace.setToolTipText(titrePrixAchat + " : " + Tower_Ice.PRIX_ACHAT); boutonsTours.add(bTourElectrique); bTourElectrique.setToolTipText(titrePrixAchat + " : " + Tower_Electric.PRIX_ACHAT); boutonsTours.add(bTourDeFeu); bTourDeFeu.setToolTipText(titrePrixAchat + " : " + Tower_Fire.PRIX_ACHAT); boutonsTours.add(bTourDAir); bTourDAir.setToolTipText(titrePrixAchat + " : " + Tower_Air.PRIX_ACHAT); boutonsTours.add(bTourDeTerre); bTourDeTerre.setToolTipText(titrePrixAchat + " : " + Tower_Earth.PRIX_ACHAT); for (JButton bTour : boutonsTours) { bTour.addActionListener(this); bTour.setBorder(new EmptyBorder(5, 5, 5, 5)); ManageFonts.setStyle(bTour); pTours.add(bTour); } miseAJour(); add(pTours, BorderLayout.CENTER); }
public BorderedComponent(String text, JComponent comp, boolean collapsible) { super(null); this.comp = comp; // Only add border if text is not null if (text != null) { TitledBorder border; if (collapsible) { final JLabel textLabel = new JLabel(text); JPanel borderLabel = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 0)) { public int getBaseline(int w, int h) { Dimension dim = textLabel.getPreferredSize(); return textLabel.getBaseline(dim.width, dim.height) + textLabel.getY(); } }; borderLabel.add(textLabel); border = new LabeledBorder(borderLabel); textLabel.setForeground(border.getTitleColor()); if (IS_WIN) { collapseIcon = new ImageIcon(getImage("collapse-winlf")); expandIcon = new ImageIcon(getImage("expand-winlf")); } else { collapseIcon = new ArrowIcon(SOUTH, textLabel); expandIcon = new ArrowIcon(EAST, textLabel); } moreOrLessButton = new JButton(collapseIcon); moreOrLessButton.setContentAreaFilled(false); moreOrLessButton.setBorderPainted(false); moreOrLessButton.setMargin(new Insets(0, 0, 0, 0)); moreOrLessButton.addActionListener(this); String toolTip = Messages.BORDERED_COMPONENT_MORE_OR_LESS_BUTTON_TOOLTIP; moreOrLessButton.setToolTipText(toolTip); borderLabel.add(moreOrLessButton); borderLabel.setSize(borderLabel.getPreferredSize()); add(borderLabel); } else { border = new TitledBorder(text); } setBorder(new CompoundBorder(new FocusBorder(this), border)); } else { setBorder(new FocusBorder(this)); } if (comp != null) { add(comp); } }
private void jbInit() throws Exception { panel1.setLayout(borderLayout1); okButton.setText("OK"); okButton.addActionListener(new MimeTypeEditor_okButton_actionAdapter(this)); filtersTable.setRowSelectionAllowed(true); filtersTable.setPreferredSize(new Dimension(418, 200)); filtersTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); filtersTable.setCellSelectionEnabled(true); filtersTable.setColumnSelectionAllowed(false); filtersTable.setModel(m_model); addButton.setToolTipText( "Add a new " + mimeTypeEditorBuilder.getValueName() + " for a MIME type"); addButton.setText("Add"); addButton.addActionListener(new MimeTypeEditor_addButton_actionAdapter(this)); cancelButton.setText("Cancel"); cancelButton.addActionListener(new MimeTypeEditor_cancelButton_actionAdapter(this)); deleteButton.setToolTipText("Delete the currently selected item."); deleteButton.setText("Delete"); deleteButton.addActionListener(new MimeTypeEditor_deleteButton_actionAdapter(this)); upButton.setText("Up"); upButton.addActionListener(new MimeTypeEditor_upButton_actionAdapter(this)); dnButton.setText("Down"); dnButton.addActionListener(new MimeTypeEditor_dnButton_actionAdapter(this)); panel1.setPreferredSize(new Dimension(418, 200)); jScrollPane1.setMinimumSize(new Dimension(200, 80)); jScrollPane1.setOpaque(true); buttonPanel.add(dnButton, null); buttonPanel.add(upButton, null); buttonPanel.add(addButton, null); buttonPanel.add(deleteButton, null); buttonPanel.add(okButton, null); buttonPanel.add(cancelButton, null); getContentPane().add(panel1); panel1.add(buttonPanel, BorderLayout.SOUTH); panel1.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.getViewport().add(filtersTable, null); }
/** Make the button for navigating to the default folder. */ protected Component makeDefaultFolderNavigationButton() { final JButton goButton = new JButton("Default Folder"); goButton.setToolTipText("Navigate to the default folder."); goButton.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent event) { try { handleToDefaultFolderAction(); } catch (Exception exception) { reportException(exception); } } }); return goButton; }
private void jbInit() throws Exception { BnTest.setToolTipText("Test Button"); list.setDataTips(true); list.setBackgroundImage(image); list.setScrollableBackground(false); getContentPane().setLayout(new BorderLayout()); getContentPane().add(list, BorderLayout.CENTER); getContentPane().add(BnTest, BorderLayout.SOUTH); this.setTitle("SwingEx Test"); this.addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosing(WindowEvent e) { this_windowClosing(e); } }); }
private void buildInterface() { // Panel p to hold the label and text field JPanel panelInput = new JPanel(); panelInput.setLayout(new BorderLayout()); panelInput.add(buttonSelect, BorderLayout.EAST); panelInput.add(textFolder, BorderLayout.CENTER); textFolder.setEditable(false); textFolder.setText(System.getProperty("user.home") + "\\"); // Set default save location setLayout(new BorderLayout()); add(panelInput, BorderLayout.NORTH); add(new JScrollPane(textArea), BorderLayout.CENTER); textArea.setEditable(false); buttonSelect.setToolTipText(TOOL_TIP_SELECT_FOLDER); buttonSelect.addActionListener(new ButtonListener()); // Register listener }
public static Component getCopyButton(final String key, final KeyValuePairPanel p) { JButton button = ViewUtil.getTexturedButton( IconFactory.getInstance().getIcon(IconFactory.StandardIcon.COPY)); button.setToolTipText("Copy " + key); button.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { String selection = p.getValue(key); StringSelection data = new StringSelection(selection); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(data, data); DialogUtils.displayMessage("Copied \"" + selection + "\" to clipboard."); } }); return button; }
// Takes resource name and returns button public JButton createButton(String name, String toolTip) { // load the image String imagePath = "./resources/" + name + ".png"; ImageIcon iconRollover = new ImageIcon(imagePath); int w = iconRollover.getIconWidth(); int h = iconRollover.getIconHeight(); // get the cursor for this button Cursor cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR); // make translucent default image Image image = createCompatibleImage(w, h, Transparency.TRANSLUCENT); Graphics2D g = (Graphics2D) image.getGraphics(); Composite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .5f); g.setComposite(alpha); g.drawImage(iconRollover.getImage(), 0, 0, null); g.dispose(); ImageIcon iconDefault = new ImageIcon(image); // make a pressed image image = createCompatibleImage(w, h, Transparency.TRANSLUCENT); g = (Graphics2D) image.getGraphics(); g.drawImage(iconRollover.getImage(), 2, 2, null); g.dispose(); ImageIcon iconPressed = new ImageIcon(image); // create the button JButton button = new JButton(); button.addActionListener(this); button.setIgnoreRepaint(true); button.setFocusable(false); button.setToolTipText(toolTip); button.setBorder(null); button.setContentAreaFilled(false); button.setCursor(cursor); button.setIcon(iconDefault); button.setRolloverIcon(iconRollover); button.setPressedIcon(iconPressed); return button; }
private void initToolbar() { JToolBar tbTraceFilters = new JToolBar(); tbTraceFilters.setFloatable(false); tbTraceFilters.setRollover(true); tbTraceFilters.add(new JLabel("Min time:")); txtMinTime = new JTextField(4); tbTraceFilters.add(txtMinTime); JButton btnFilterByTime = new JButton(new FilterByTimeAction()); btnFilterByTime.setFocusable(false); btnFilterByTime.setToolTipText("Filter by trace execution time"); tbTraceFilters.add(btnFilterByTime); tbTraceFilters.addSeparator(); btnFilterErrors = new JToggleButton(new FilterByErrorAction()); btnFilterErrors.setFocusable(false); btnFilterErrors.setToolTipText("Show only traces with errors"); tbTraceFilters.add(btnFilterErrors); tbTraceFilters.addSeparator(); cmbTraceType = new JComboBox(); cmbTraceType.addItem("*"); cmbTraceType.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { String item = (String) e.getItem(); traceLabel = "*".equals(item) ? null : item; tbmTraces.setDataSet(dataSet, traceFilter); } } }); tbTraceFilters.add(cmbTraceType); add(tbTraceFilters, BorderLayout.NORTH); }