public static void scaleIcon(JButton button) { if (isScaleImages() && button != null && button.getIcon() != null && button.getIcon() instanceof ImageIcon) { button.setIcon(getScaledIcon((ImageIcon) button.getIcon())); } }
public void run() { for (int j = 0; j < 20; j++) butI[j].removeActionListener(this); Wait.manySec(10); if (but.getIcon() == butn.getIcon()) { but.setVisible(false); butn.setVisible(false); } else { but.setIcon(iconOrg); butn.setIcon(iconOrg); } isVisibl(); for (int j = 0; j < 20; j++) butI[j].addActionListener(this); }
/** * Move images so the one the user entered is moved to the only other empty one. * * <p>Just something else to do while wasting your time.... * * @param entered the JButton user moved mouse into. */ private void rotateImages(JButton entered) { // find Empty one. JButton buttons[] = {getNwButton(), getNeButton(), getSeButton(), getSwButton()}; javax.swing.Icon selectedIcon = null; JButton emptyButton = null; // which one was empty. for (int i = 0; i < buttons.length; i++) { // button that mouse entered into; grab its image if (buttons[i] == entered) { selectedIcon = entered.getIcon(); } if (buttons[i].getIcon() == null) { emptyButton = buttons[i]; } } // if we get here, and emptyButton is one we entered, do nothing if (emptyButton == entered) { return; } // aha! Now swap entered one with the empty one. emptyButton.setIcon(selectedIcon); entered.setIcon(null); // clear away. }
public void actionPerformed(ActionEvent e) { if (cChooser == null) { cChooser = new JColorChooser(); } Color color = cChooser.showDialog( target, "Available Colors", ((ColoredIcon) target.getIcon()).getCurrentColor()); target.setIcon(new ColoredIcon(color)); target.doClick(); }
@Override public void paint(Graphics g, JComponent c) { JButton button = (JButton) c; String text = button.getText(); Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon(); if ((icon == null) && (text == null)) { return; } FontMetrics fm = g.getFontMetrics(); paintViewInsets = c.getInsets(paintViewInsets); paintViewR.x = paintViewInsets.left; paintViewR.y = paintViewInsets.top; // Use inverted height & width paintViewR.height = c.getWidth() - (paintViewInsets.left + paintViewInsets.right); paintViewR.width = c.getHeight() - (paintViewInsets.top + paintViewInsets.bottom); paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0; paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0; Graphics2D g2 = (Graphics2D) g; AffineTransform tr = g2.getTransform(); if (angle == 90) { g2.rotate(Math.PI / 2); g2.translate(0, -c.getWidth()); paintViewR.x = c.getHeight() / 2 - (int) fm.getStringBounds(text, g).getWidth() / 2; paintViewR.y = c.getWidth() / 2 - (int) fm.getStringBounds(text, g).getHeight() / 2; } else if (angle == 270) { g2.rotate(-Math.PI / 2); g2.translate(-c.getHeight(), 0); paintViewR.x = c.getHeight() / 2 - (int) fm.getStringBounds(text, g).getWidth() / 2; paintViewR.y = c.getWidth() / 2 - (int) fm.getStringBounds(text, g).getHeight() / 2; } if (icon != null) { icon.paintIcon(c, g, paintIconR.x, paintIconR.y); } if (text != null) { int textX = paintTextR.x; int textY = paintTextR.y + fm.getAscent(); if (button.isEnabled()) { paintText(g, c, new Rectangle(paintViewR.x, paintViewR.y, textX, textY), text); } else { paintText(g, c, new Rectangle(paintViewR.x, paintViewR.y, textX, textY), text); } } g2.setTransform(tr); }
public SplashScreen(Image image) { this.icon = new ImageIcon(image); Container container = getContentPane(); container.setLayout(null); // Redraw the image to fix the alpha channel BufferedImage alphaImage = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g = alphaImage.createGraphics(); g.drawImage(image, 0, 0, icon.getIconWidth(), icon.getIconHeight(), null); g.dispose(); // Draw the image JButton background = new JButton(new ImageIcon(alphaImage)); background.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight()); background.setRolloverEnabled(true); background.setRolloverIcon(background.getIcon()); background.setSelectedIcon(background.getIcon()); background.setDisabledIcon(background.getIcon()); background.setPressedIcon(background.getIcon()); background.setFocusable(false); background.setContentAreaFilled(false); background.setBorderPainted(false); background.setOpaque(false); container.add(background); // Finalize setSize(icon.getIconWidth(), icon.getIconHeight() + 20); try { // Not always supported... this.setBackground(new Color(0, 0, 0, 0)); } catch (UnsupportedOperationException e) { this.setBackground(new Color(0, 0, 0)); } setLocationRelativeTo(null); }
private void updateToggleStyleBarButtons() { if (toggleStyleBarButton != null) { if (showStyleBar) { toggleStyleBarButton.setIcon(app.getScaledIcon("triangle_down.png")); // toggleStyleBarButton.setRolloverIcon(app.getScaledIcon("triangle-down-rollover.png")); } else { toggleStyleBarButton.setIcon(app.getScaledIcon("triangle_right.png")); // toggleStyleBarButton.setRolloverIcon(app.getScaledIcon("triangle-right-rollover.png")); } } if (toggleStyleBarButton2 != null) { toggleStyleBarButton2.setIcon(toggleStyleBarButton.getIcon()); // toggleStyleBarButton2.setRolloverIcon(toggleStyleBarButton.getRolloverIcon()); } }
public RevisionAnalysisTopComponent(WorkspaceItem<RevisionAnalysisDocument> item) { super(item); setName(getDocument().getDisplayName()); setToolTipText(Bundle.HINT_RevisionAnalysisTopComponent()); toolBarRepresentation = NbComponents.newInnerToolbar(); toolBarRepresentation.setFloatable(false); toolBarRepresentation.add(Box.createRigidArea(new Dimension(5, 0))); runButton = toolBarRepresentation.add( new AbstractAction("", DemetraUiIcon.COMPILE_16) { @Override public void actionPerformed(ActionEvent e) { start(); } }); runButton.setDisabledIcon(ImageUtilities.createDisabledIcon(runButton.getIcon())); runButton.setEnabled(false); addPropertyChangeListener( new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals(STATE_PROPERTY)) { onStateChange(); } } }); toolBarRepresentation.addSeparator(); itemsLabel = (JLabel) toolBarRepresentation.add(new JLabel("No items")); inputList = new JTsList(); inputList.addPropertyChangeListener( new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { switch (evt.getPropertyName()) { case JTsList.COLLECTION_PROPERTY: onCollectionChange(); break; } } }); toolBarRepresentation.addSeparator(); JPopupMenu specPopup = new JPopupMenu(); final JButton specButton = (JButton) toolBarRepresentation.add( DropDownButtonFactory.createDropDownButton( ImageUtilities.loadImageIcon("ec/nbdemetra/sa/blog_16x16.png", false), specPopup)); specButton.setFocusPainted(false); specPopup .add(new ec.nbdemetra.ws.ui.SpecSelectionComponent()) .addPropertyChangeListener( new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { String p = evt.getPropertyName(); if (p.equals(ec.nbdemetra.ws.ui.SpecSelectionComponent.SPECIFICATION_PROPERTY) && evt.getNewValue() != null) { ISaSpecification spec = (ISaSpecification) evt.getNewValue(); curSpec.setSaSpecification(spec); defSpecLabel.setText(spec == null ? "" : spec.toLongString()); } else if (p.equals(ec.nbdemetra.ws.ui.SpecSelectionComponent.ICON_PROPERTY) && evt.getNewValue() != null) { specButton.setIcon(ImageUtilities.image2Icon((Image) evt.getNewValue())); } } }); specPopup.addPopupMenuListener( new PopupMenuAdapter() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { ((ec.nbdemetra.ws.ui.SpecSelectionComponent) ((JPopupMenu) e.getSource()).getComponent(0)) .setSpecification((ISaSpecification) curSpec.getSaSpecification()); } }); raView = new RevisionAnalysisTopComponent.RevisionAnalysisDocumentView(); raView.setDocument(getDocument().getElement()); loadingPanel = new LoadingPanel(raView); curSpec = getDocument().getElement().getSpecification().clone(); defSpecLabel = (JLabel) toolBarRepresentation.add(new JLabel()); defSpecLabel.setText( curSpec.getSaSpecification() == null ? "" : ((ISaSpecification) curSpec.getSaSpecification()).toLongString()); visualRepresentation = NbComponents.newJSplitPane(JSplitPane.VERTICAL_SPLIT, inputList, loadingPanel); visualRepresentation.setOneTouchExpandable(true); inputList.setTsCollection(getDocument().getElement().getInput()); setLayout(new BorderLayout()); add(toolBarRepresentation, BorderLayout.NORTH); add(visualRepresentation, BorderLayout.CENTER); refreshNode(); }
public SearchManager2(JabRefFrame frame, SidePaneManager manager) { super(manager, GUIGlobals.getIconUrl("search"), Globals.lang("Search")); this.frame = frame; incSearcher = new IncrementalSearcher(Globals.prefs); // setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.magenta)); searchReq = new JCheckBoxMenuItem( Globals.lang("Search required fields"), Globals.prefs.getBoolean(JabRefPreferences.SEARCH_REQ)); searchOpt = new JCheckBoxMenuItem( Globals.lang("Search optional fields"), Globals.prefs.getBoolean(JabRefPreferences.SEARCH_OPT)); searchGen = new JCheckBoxMenuItem( Globals.lang("Search general fields"), Globals.prefs.getBoolean(JabRefPreferences.SEARCH_GEN)); searchAll = new JCheckBoxMenuItem( Globals.lang("Search all fields"), Globals.prefs.getBoolean(JabRefPreferences.SEARCH_ALL)); regExpSearch = new JCheckBoxMenuItem( Globals.lang("Use regular expressions"), Globals.prefs.getBoolean(JabRefPreferences.REG_EXP_SEARCH)); increment = new JRadioButton(Globals.lang("Incremental"), false); floatSearch = new JRadioButton(Globals.lang("Float"), true); hideSearch = new JRadioButton(Globals.lang("Filter"), true); showResultsInDialog = new JRadioButton(Globals.lang("Show results in dialog"), true); searchAllBases = new JRadioButton( Globals.lang("Global search"), Globals.prefs.getBoolean(JabRefPreferences.SEARCH_ALL_BASES)); ButtonGroup types = new ButtonGroup(); types.add(increment); types.add(floatSearch); types.add(hideSearch); types.add(showResultsInDialog); types.add(searchAllBases); select = new JCheckBoxMenuItem(Globals.lang("Select matches"), false); increment.setToolTipText(Globals.lang("Incremental search")); floatSearch.setToolTipText(Globals.lang("Gray out non-matching entries")); hideSearch.setToolTipText(Globals.lang("Hide non-matching entries")); showResultsInDialog.setToolTipText(Globals.lang("Show search results in a window")); // Add an item listener that makes sure we only listen for key events // when incremental search is turned on. increment.addItemListener(this); floatSearch.addItemListener(this); hideSearch.addItemListener(this); showResultsInDialog.addItemListener(this); // Add the global focus listener, so a menu item can see if this field was focused when // an action was called. searchField.addFocusListener(Globals.focusListener); if (searchAll.isSelected()) { searchReq.setEnabled(false); searchOpt.setEnabled(false); searchGen.setEnabled(false); } searchAll.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { boolean state = !searchAll.isSelected(); searchReq.setEnabled(state); searchOpt.setEnabled(state); searchGen.setEnabled(state); } }); caseSensitive = new JCheckBoxMenuItem( Globals.lang("Case sensitive"), Globals.prefs.getBoolean(JabRefPreferences.CASE_SENSITIVE_SEARCH)); highLightWords = new JCheckBoxMenuItem( Globals.lang("Highlight Words"), Globals.prefs.getBoolean(JabRefPreferences.HIGH_LIGHT_WORDS)); searchAutoComplete = new JCheckBoxMenuItem( Globals.lang("Autocomplete names"), Globals.prefs.getBoolean(JabRefPreferences.SEARCH_AUTO_COMPLETE)); settings.add(select); // 2005.03.29, trying to remove field category searches, to simplify // search usability. // settings.addSeparator(); // settings.add(searchReq); // settings.add(searchOpt); // settings.add(searchGen); // settings.addSeparator(); // settings.add(searchAll); // --------------------------------------------------------------- settings.addSeparator(); settings.add(caseSensitive); settings.add(regExpSearch); settings.addSeparator(); settings.add(highLightWords); settings.addSeparator(); settings.add(searchAutoComplete); searchField.addActionListener(this); searchField.addCaretListener(this); search.addActionListener(this); searchField.addFocusListener( new FocusAdapter() { @Override public void focusGained(FocusEvent e) { if (increment.isSelected()) { searchField.setText(""); } } @Override public void focusLost(FocusEvent e) { incSearch = false; incSearchPos = -1; // Reset incremental // search. This makes the // incremental search reset // once the user moves focus to // somewhere else. if (increment.isSelected()) { // searchField.setText(""); // System.out.println("focuslistener"); } } }); escape.addActionListener(this); escape.setEnabled(false); // enabled after searching openset.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (settings.isVisible()) { // System.out.println("oee"); // settings.setVisible(false); } else { JButton src = (JButton) e.getSource(); settings.show(src, 0, openset.getHeight()); } } }); searchAutoComplete.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { Globals.prefs.putBoolean( JabRefPreferences.SEARCH_AUTO_COMPLETE, searchAutoComplete.isSelected()); if (SearchManager2.this.frame.basePanel() != null) { SearchManager2.this.frame.basePanel().updateSearchManager(); } } }); Insets margin = new Insets(0, 2, 0, 2); // search.setMargin(margin); escape.setMargin(margin); openset.setMargin(margin); JButton help = new JButton(GUIGlobals.getImage("help")); int butSize = help.getIcon().getIconHeight() + 5; Dimension butDim = new Dimension(butSize, butSize); help.setPreferredSize(butDim); help.setMinimumSize(butDim); help.setMargin(margin); help.addActionListener(new HelpAction(Globals.helpDiag, GUIGlobals.searchHelp, "Help")); // Select the last used mode of search: if (Globals.prefs.getBoolean(JabRefPreferences.INCREMENT_S)) { increment.setSelected(true); } else if (Globals.prefs.getBoolean(JabRefPreferences.FLOAT_SEARCH)) { floatSearch.setSelected(true); } else if (Globals.prefs.getBoolean(JabRefPreferences.SHOW_SEARCH_IN_DIALOG)) { showResultsInDialog.setSelected(true); } else if (Globals.prefs.getBoolean(JabRefPreferences.SEARCH_ALL_BASES)) { searchAllBases.setSelected(true); } else { hideSearch.setSelected(true); } JPanel main = new JPanel(); GridBagLayout gbl = new GridBagLayout(); main.setLayout(gbl); GridBagConstraints con = new GridBagConstraints(); con.gridwidth = GridBagConstraints.REMAINDER; con.fill = GridBagConstraints.BOTH; con.weightx = 1; gbl.setConstraints(searchField, con); main.add(searchField); // con.gridwidth = 1; gbl.setConstraints(search, con); main.add(search); con.gridwidth = GridBagConstraints.REMAINDER; gbl.setConstraints(escape, con); main.add(escape); con.insets = new Insets(0, 2, 0, 0); gbl.setConstraints(increment, con); main.add(increment); gbl.setConstraints(floatSearch, con); main.add(floatSearch); gbl.setConstraints(hideSearch, con); main.add(hideSearch); gbl.setConstraints(showResultsInDialog, con); main.add(showResultsInDialog); gbl.setConstraints(searchAllBases, con); main.add(searchAllBases); con.insets = new Insets(0, 0, 0, 0); JPanel pan = new JPanel(); GridBagLayout gb = new GridBagLayout(); gbl.setConstraints(pan, con); pan.setLayout(gb); con.weightx = 1; con.gridwidth = 1; gb.setConstraints(openset, con); pan.add(openset); con.weightx = 0; gb.setConstraints(help, con); pan.add(help); main.add(pan); main.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); setContentContainer(main); searchField.getInputMap().put(Globals.prefs.getKey("Repeat incremental search"), "repeat"); searchField .getActionMap() .put( "repeat", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (increment.isSelected()) { repeatIncremental(); } } }); searchField.getInputMap().put(Globals.prefs.getKey("Clear search"), "escape"); searchField .getActionMap() .put( "escape", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { hideAway(); // SearchManager2.this.actionPerformed(new ActionEvent(escape, 0, "")); } }); setSearchButtonSizes(); updateSearchButtonText(); }
public void actionPerformed(ActionEvent event) { if (posicion == -2) posicion = indexaux; // Abrir nueva imagen if (event.getSource() == carpeta) { siguiente.setEnabled(true); atras.setEnabled(true); presentacion.setEnabled(true); grid.setEnabled(true); bcomentario.setEnabled(true); zoom.setEnabled(true); imagenesbean.clear(); if (imagenes != null) { imagenes.clear(); } returnChooser = chooser.showOpenDialog(ArcViewer.this); imagenes = lista.Miranda(chooser, returnChooser); for (int asd1 = 0; asd1 < imagenes.size(); asd1++) { imagenesbean.add(new ImagenBean(imagenes.get(asd1), 0, 0)); } String getImgSelected = chooser.getSelectedFile().getPath(); for (int index = 0; index < imagenesbean.size(); index++) { if (getImgSelected.equals(imagenesbean.get(index).getIcon())) { imagen.setIcon(new ImageIcon(imagenesbean.get(index).getIcon())); indexaux = index; } } } // Imagen siguiente if (event.getSource() == siguiente) { posicion++; if (posicion >= imagenesbean.size()) { posicion = 0; } imagen.setIcon( ajustar.ajusteImg( new ImageIcon(imagenesbean.get(posicion).getIcon()), imagenesbean.get(posicion).getAncho(), imagenesbean.get(posicion).getAlto(), areaventana.getWidth() - 50, areaventana.getHeight())); } // Imagen anterior if (event.getSource() == atras) { posicion--; if (posicion == -1) { posicion = imagenesbean.size() - 1; } imagen.setIcon( ajustar.ajusteImg( new ImageIcon(imagenesbean.get(posicion).getIcon()), imagenesbean.get(posicion).getAncho(), imagenesbean.get(posicion).getAlto(), areaventana.getWidth() - 50, areaventana.getHeight())); } // Presentacion iniciar/detener if (event.getSource() == presentacion) { if (isPresentacion == false) { grid.setVisible(false); atras.setVisible(false); siguiente.setVisible(false); carpeta.setVisible(false); bcomentario.setVisible(false); zoom.setVisible(false); ptiempo.setVisible(true); } if (isPresentacion == true) { grid.setVisible(true); atras.setVisible(true); siguiente.setVisible(true); carpeta.setVisible(true); bcomentario.setVisible(true); zoom.setVisible(true); ptiempo.setVisible(false); } if (presentacion.getIcon() == imgPausa) { slide.detener(); posicion = slide.getPosicion(); presentacion.setIcon(imgPlay); isPresentacion = false; return; } if (presentacion.getIcon() == imgPlay) { slide.setTodo(posicion, imagen, imagenesbean, areaventana, ptiempo); new Thread(slide, "prueba").start(); presentacion.setIcon(imgPausa); isPresentacion = true; return; } } // Modo rejilla if (event.getSource() == grid) { imagen.setVisible(false); siguiente.setVisible(false); atras.setVisible(false); presentacion.setVisible(false); grid.setVisible(false); bcomentario.setVisible(false); zoom.setVisible(false); carpeta.setVisible(false); ptiempo.setVisible(false); // desplazamiento.setVisible(true); if (corrobora == true) { for (int celular = 0; celular < imgButtonArray.length; celular++) { imgButtonArray[celular].setVisible(true); } } if (corrobora == false) { imgButtonArray = new JButton[imagenesbean.size()]; for (int goku = 0; goku < imagenesbean.size(); goku++) { areaventana.add(imgButtonArray[goku] = new JButton()); imgButtonArray[goku].setPreferredSize(new Dimension(200, 200)); imgButtonArray[goku].addActionListener(this); imgButtonArray[goku].setBackground(colorGris); imgButtonArray[goku].setIcon( ajustar.ajusteCuadrado(new ImageIcon(imagenesbean.get(goku).getIcon()))); corrobora = true; } } } // Comentario if (event.getSource() == bcomentario) { new Comentario(imagenesbean.get(posicion), posicion); } // Cuando se apreta un boton de la rejilla if (corrobora == true) { for (int alice = 0; alice < imgButtonArray.length; alice++) { if (event.getSource() == imgButtonArray[alice]) { for (int wonderland = 0; wonderland < imgButtonArray.length; wonderland++) { imgButtonArray[wonderland].setVisible(false); } posicion = alice; imagen.setIcon( ajustar.ajusteImg( new ImageIcon(imagenesbean.get(posicion).getIcon()), imagenesbean.get(posicion).getAncho(), imagenesbean.get(posicion).getAlto(), areaventana.getWidth() - 50, areaventana.getHeight())); imagen.setVisible(true); siguiente.setVisible(true); atras.setVisible(true); presentacion.setVisible(true); grid.setVisible(true); bcomentario.setVisible(true); zoom.setVisible(true); carpeta.setVisible(true); } } } if (event.getSource() == zoom) { System.out.println("Haciendo un ZOOOOOOOOOOOOM"); } }
ColorChooserAction(JButton target) { super(null, target.getIcon()); this.target = target; }