/** * Reset the image rollover icon as enabled/disabled. * * @param enabled, the status to draw the image rollover icon for. */ public void updateImageRollover(boolean enabled) { if (enabled) { pbImageRollover.setIcon(UIImages.get(IMAGE_ROLLOVER_ICON)); } else { pbImageRollover.setIcon(UIImages.get(IMAGE_ROLLOVEROFF_ICON)); } }
public void evaluate() { try { // clear problems and console messages problemsView.setText(""); consoleView.setText(""); // update status view statusView.setText(" Parsing ..."); tabbedPane.setSelectedIndex(0); LispExpr root = Parser.parse(textView.getText()); statusView.setText(" Running ..."); tabbedPane.setSelectedIndex(1); // update run button runButton.setIcon(stopImage); runButton.setActionCommand("Stop"); // start run thread runThread = new RunThread(root); runThread.start(); } catch (SyntaxError e) { tabbedPane.setSelectedIndex(0); System.err.println( "Syntax Error at " + e.getLine() + ", " + e.getColumn() + " : " + e.getMessage()); } catch (Error e) { // parsing error System.err.println(e.getMessage()); statusView.setText(" Errors."); } }
/** * 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); } }); }
/** Shuffle the numbers on the buttons */ private void shuffle() { // Randomize the order if (solution) solution = false; else Collections.shuffle(current); // Reset the stats moves = 0; solved = false; // Reset each of the buttons to reflect the randomized // order for (int i = 0; i < buttons.size(); i++) { JButton b = (JButton) buttons.get(i); String value = (String) current.get(i); int val = Integer.parseInt(value) - 1; b.setText(value); b.setBackground(java.awt.Color.orange); b.setIcon(icons[val]); if (value.equals("16")) { b.setVisible(false); hiddenIndex = i; } else { b.setVisible(true); } } // Reset the status line getStatusLabel().setText("Number of moves: " + moves); }
public void createColorPanel() { JPanel colorPanel = new JPanel(new GridLayout(0, 1)); int curRow = 0; for (int i = 0; i < colorString.length / 5; i++) { JPanel row = new JPanel(new GridLayout(1, 0, 2, 1)); row.setBorder(new EmptyBorder(2, 2, 2, 2)); for (int j = curRow; j < curRow + 5; j++) { final JLabel colorLabel = new JLabel(null, new ColoredIcon(color[j], 14, 14), JLabel.CENTER); colorLabel.setOpaque(true); final Border emb = BorderFactory.createEmptyBorder(2, 1, 2, 1); final Border lnb = BorderFactory.createLineBorder(Color.black); final Border cmb = BorderFactory.createCompoundBorder(lnb, emb); colorLabel.setBorder(emb); colorLabel.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { JButton btn = (JButton) getTarget(); Color selColor = ((ColoredIcon) colorLabel.getIcon()).getCurrentColor(); btn.setIcon(new ColoredIcon(selColor)); setVisible(false); btn.doClick(); oldLabel.setBackground(null); colorLabel.setBackground(new Color(150, 150, 200)); colorLabel.setBorder(emb); oldLabel = colorLabel; } public void mouseEntered(MouseEvent e) { colorLabel.setBorder(cmb); colorLabel.setBackground(new Color(150, 150, 200)); } public void mouseExited(MouseEvent e) { colorLabel.setBorder(emb); colorLabel.setBackground(null); } }); row.add(colorLabel); } colorPanel.add(row); curRow += row.getComponentCount(); // System.out.println(curRow); } add(colorPanel, BorderLayout.CENTER); // More Colors Button moreColors = new JButton(new ColorChooserAction((JButton) target)); moreColors.setText("More Colors..."); moreColors.setIcon(null); moreColors.setFont(new Font("Verdana", Font.PLAIN, 10)); // JPanel c = new JPanel(new FlowLayout(FlowLayout.CENTER)); c.add(moreColors); add(c, BorderLayout.SOUTH); }
public void setIcon(String command, ImageIcon icon) { JButton b = (JButton) buttons.get(command); if (b != null) { b.setIcon(icon); b.revalidate(); setButtonsSize(); } }
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(); }
/** * React to the pushing of the given button * * @param index The number of the button pushed */ private void slide(int index) { // Don't do anything if the puzzle is solved if (solved) return; // if not a valid click return if (!check(index)) { return; } // swap positions current.set(index, current.set(hiddenIndex, current.get(index))); // swap strings JButton b = (JButton) buttons.get(index); b.setText((String) current.get(index)); b.setIcon(icons[Integer.parseInt(current.get(index)) - 1]); b.setVisible(false); b = (JButton) buttons.get(hiddenIndex); b.setText((String) current.get(hiddenIndex)); b.setIcon(icons[Integer.parseInt(current.get(hiddenIndex)) - 1]); b.setVisible(true); // update the position of the blanked spot hiddenIndex = index; // Increment the number of moves and update status moves++; getStatusLabel().setText("Number of moves: " + moves); // if you've won if (current.equals(correct)) { solved = true; getStatusLabel().setText("Solved the game in " + moves + " moves."); // Change the buttons colors to green Iterator itr = buttons.iterator(); while (itr.hasNext()) { ((JButton) itr.next()).setBackground(java.awt.Color.green); } } }
public void runFinished() { // program execution finished so update // status and run button accordingly if (runThread == null) { // _runThread = null only if // execution stopped by user via // run button statusView.setText(" Stopped."); } else { statusView.setText(" Done."); } runButton.setActionCommand("Run"); runButton.setIcon(runImage); }
/** * <code>guiInit()</code> defined for component initialization and setting up actions and models * of each component */ private void guiInit() { setTitle(props.getProperty("page.name")); ButtonGroup typeButtonGroup = new ButtonGroup(); typeButtonGroup.add(rdoCopyrightReq); typeButtonGroup.add(rdoDepositReq); ButtonGroup isAnsweredButtonGroup = new ButtonGroup(); isAnsweredButtonGroup.add(rdoAnswerReq); isAnsweredButtonGroup.add(rdoNoAnswerReq); ButtonGroup hasNumberButtonGroup = new ButtonGroup(); hasNumberButtonGroup.add(rdoHasNumber); hasNumberButtonGroup.add(rdoNoNumber); lblNumberSufix.setText( StringConsts.LRM + String.valueOf('\u062D') + " " + StringConsts.LRM + WorkflowConstants.NO_DATA); ConstantTableDefinition docType = ConstantPool.getInstance().findConstantTableByName(ConstantTables.COPYRIGHT_NONE_BOOK_TYPE); cmbDocType = ComponentFactory.createConstantTableCombo( docType, new Dimension(150, 16), true, screenLocale); cmbDocType.setSelectedIndex(0); componentsInit(); btnSelectUser.setIcon(WorkflowUiUtils.SELECT_USER_ICON); btnSelectUser.setBorder(null); setGridColumns(); setGridActions(); }
private void jbInit() throws Exception { titledBorder1 = new TitledBorder(""); this.setLayout(baseLayout); double[][] lower_size = { {TableLayout.PREFERRED, TableLayout.FILL, 25}, {25, 25, TableLayout.FILL} }; mLowerPanelLayout = new TableLayout(lower_size); mLowerPanel.setLayout(mLowerPanelLayout); double[][] dir_size = { {TableLayout.FILL, TableLayout.PREFERRED}, {TableLayout.PREFERRED, TableLayout.FILL} }; mDirectionsPanelLayout = new TableLayout(dir_size); mDirectionsPanel.setLayout(mDirectionsPanelLayout); // Try to get icons for the toolbar buttons try { ClassLoader loader = getClass().getClassLoader(); mAddIcon = new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/add.gif")); mRemoveIcon = new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/remove.gif")); mDisabledRemoveIcon = new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/remove_disabled.gif")); mAddNodeBtn.setIcon(mAddIcon); mRemoveNodeBtn.setIcon(mRemoveIcon); mRemoveNodeBtn.setDisabledIcon(mDisabledRemoveIcon); } catch (Exception e) { // Ack! No icons. Use text labels instead mAddNodeBtn.setText("Add"); mRemoveNodeBtn.setText("Remove"); } /* mAddNodeBtn.setMaximumSize(new Dimension(130, 33)); mAddNodeBtn.setMinimumSize(new Dimension(130, 33)); mAddNodeBtn.setPreferredSize(new Dimension(130, 33)); mAddNodeBtn.setText("Add Node"); */ mAddNodeBtn.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { mAddNodeBtn_actionPerformed(e); } }); /* mRemoveNodeBtn.setMaximumSize(new Dimension(130, 33)); mRemoveNodeBtn.setMinimumSize(new Dimension(130, 33)); mRemoveNodeBtn.setPreferredSize(new Dimension(130, 33)); mRemoveNodeBtn.setText("Remove Node"); */ mRemoveNodeBtn.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { mRemoveNode(); } }); mHostnameLabel.setHorizontalAlignment(SwingConstants.TRAILING); mHostnameLabel.setLabelFor(mHostnameField); mHostnameLabel.setText("Hostname:"); mHostnameField.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { mAddNodeBtn_actionPerformed(e); } }); mDirectionsPanel.setBorder(BorderFactory.createEtchedBorder()); mTitleLabel.setFont(new java.awt.Font("Serif", 1, 20)); mTitleLabel.setHorizontalAlignment(SwingConstants.CENTER); mTitleLabel.setText("Add Cluster Nodes"); mDirectionsLabel.setText("Click on the add button to add nodes to your cluster configuration."); mDirectionsLabel.setLineWrap(true); mDirectionsLabel.setEditable(false); mDirectionsLabel.setBackground(mTitleLabel.getBackground()); baseLayout.setHgap(5); baseLayout.setVgap(5); mLowerPanel.add( mHostnameLabel, new TableLayoutConstraints(0, 0, 0, 0, TableLayout.FULL, TableLayout.FULL)); mLowerPanel.add( mHostnameField, new TableLayoutConstraints(1, 0, 1, 0, TableLayout.FULL, TableLayout.FULL)); mLowerPanel.add( mListScrollPane1, new TableLayoutConstraints(0, 1, 1, 2, TableLayout.FULL, TableLayout.FULL)); mLowerPanel.add( mAddNodeBtn, new TableLayoutConstraints(2, 0, 2, 0, TableLayout.FULL, TableLayout.FULL)); mLowerPanel.add( mRemoveNodeBtn, new TableLayoutConstraints(2, 1, 2, 1, TableLayout.FULL, TableLayout.FULL)); this.add(mLowerPanel, BorderLayout.CENTER); mListScrollPane1.getViewport().add(lstNodes, null); mDirectionsPanel.add( mTitleLabel, new TableLayoutConstraints(0, 0, 0, 0, TableLayout.FULL, TableLayout.FULL)); mDirectionsPanel.add( mDirectionsLabel, new TableLayoutConstraints(0, 1, 0, 1, TableLayout.FULL, TableLayout.FULL)); mDirectionsPanel.add( mIconLabel, new TableLayoutConstraints(1, 0, 1, 1, TableLayout.FULL, TableLayout.FULL)); this.add(mDirectionsPanel, BorderLayout.NORTH); }
/** Update the look and feel of the toolbar. */ public void updateLAF() { if (pbOpen != null) { pbOpen.setIcon(UIImages.get(OPEN_ICON)); } if (pbClose != null) { pbClose.setIcon(UIImages.get(CLOSE_ICON)); } pbCut.setIcon(UIImages.get(CUT_ICON)); pbCopy.setIcon(UIImages.get(COPY_ICON)); pbPaste.setIcon(UIImages.get(PASTE_ICON)); pbDelete.setIcon(UIImages.get(DELETE_ICON)); pbUndo.setIcon(UIImages.get(UNDO_ICON)); pbRedo.setIcon(UIImages.get(REDO_ICON)); pbShowBackHistory.setIcon(UIImages.get(PREVIOUS_ICON)); pbBack.setIcon(UIImages.get(BACK_ICON)); pbForward.setIcon(UIImages.get(FORWARD_ICON)); pbShowForwardHistory.setIcon(UIImages.get(NEXT_ICON)); pbSearch.setIcon(UIImages.get(SEARCH_ICON)); pbHelp.setIcon(UIImages.get(HELP_ICON)); if (FormatProperties.imageRollover) { pbImageRollover.setIcon(UIImages.get(IMAGE_ROLLOVER_ICON)); } else { pbImageRollover.setIcon(UIImages.get(IMAGE_ROLLOVEROFF_ICON)); } if (tbrToolBar != null) SwingUtilities.updateComponentTreeUI(tbrToolBar); }
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"); } }
public SmartToolBar(RuntimeConfigFrame fr) { frame = fr; setFloatable(true); treeCombo = new TreeCombo(frame.model); treeCombo.addActionListener(new ComboListener()); treeCombo.setPreferredSize(new Dimension(210, 25)); treeCombo.setMinimumSize(new Dimension(210, 25)); treeCombo.setMaximumSize(new Dimension(210, 25)); add(treeCombo); addSeparator(); addSeparator(); addSeparator(); ToolBarAction toolBarAction = new ToolBarAction(); JButton saveAsButton = add(toolBarAction); ImageIcon icon = frame .getCommonBuilderUIImpl() .getScaledImage("file.png", "images/runtimeadmin", 28, 28, Image.SCALE_DEFAULT); saveAsButton.setPreferredSize(new Dimension(28, 28)); saveAsButton.setMinimumSize(new Dimension(28, 28)); saveAsButton.setMaximumSize(new Dimension(28, 28)); saveAsButton.setBorderPainted(false); saveAsButton.setIcon(icon); icon = frame .getCommonBuilderUIImpl() .getScaledImage("file_mo.png", "images/runtimeadmin", 28, 28, Image.SCALE_DEFAULT); saveAsButton.setRolloverIcon(icon); saveAsButton.setActionCommand("Apply To Server"); saveAsButton.setToolTipText(RuntimeConfigFrame.getString("Apply To Server")); addSeparator(); JButton close = add(toolBarAction); icon = frame .getCommonBuilderUIImpl() .getScaledImage("exit.png", "images/", 28, 28, Image.SCALE_DEFAULT); close.setPreferredSize(new Dimension(28, 28)); close.setMinimumSize(new Dimension(28, 28)); close.setMaximumSize(new Dimension(28, 28)); close.setIcon(icon); close.setBorderPainted(false); icon = frame .getCommonBuilderUIImpl() .getScaledImage("exit_mo.png", "images/", 28, 28, Image.SCALE_DEFAULT); close.setRolloverIcon(icon); close.setActionCommand("Close"); close.setToolTipText(RuntimeConfigFrame.getString("Close")); addSeparator(); JButton help = add(toolBarAction); icon = frame .getCommonBuilderUIImpl() .getScaledImage("toolhelp.png", "images/", 28, 28, Image.SCALE_DEFAULT); help.setPreferredSize(new Dimension(28, 28)); help.setMinimumSize(new Dimension(28, 28)); help.setMaximumSize(new Dimension(28, 28)); help.setBorderPainted(false); help.setIcon(icon); icon = frame .getCommonBuilderUIImpl() .getScaledImage("toolhelp_mo.png", "images/", 28, 28, Image.SCALE_DEFAULT); help.setRolloverIcon(icon); help.setActionCommand("Help Contents"); help.setToolTipText(RuntimeConfigFrame.getString("Help")); // addSeparator(); }
public void setSelectedColor(Color color) { selectedColor = new ColoredIcon(color); back.setIcon(selectedColor); }
/** * Constructs a new {@link FileLoadingPanel} object containing: * * <ul> * <li>loadButton- clicking opens Cytoscape's FileChooser to choose a data file * <li>label - displays the path of the chosen file * <li>textField - can be edited such that an abbreviation for the data set can be given * <li>removeButton - removes this object from the GUI * </ul> * * @param dataPanel - The {@link DataPanel} which created this {@link FileLoadingPanel}. */ public KPMFileLoadingPanel(KPMDataTab dataPanel) { this.dataPanel = dataPanel; fileChooserFilter = new FileChooserFilter("*.csv,*.txt,*.dat", DATA_EXTENSIONS); filterList = new ArrayList<FileChooserFilter>(1); filterList.add(fileChooserFilter); loadButton = new JButton("Load"); loadButton.setToolTipText(LOADBUTTONTIP); JPanel loadButtonPanel = new JPanel(); loadButtonPanel.add(loadButton); loadButtonPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); label = new JLabel(PATHLABELDEFAULT); label.setToolTipText(PATHLABELTIP); textField = new JTextField(ABBREVIATIONFIELDDEFAULT, 20); textField.setToolTipText(TEXTFIELDTIP); nodesCountLabel = new JLabel(""); nodesCountLabel.setToolTipText( "Number of entities in the dataset, for instance genes or proteins."); samplesCountLabel = new JLabel(""); removeButton = new JButton(); JPanel removeButtonPanel = new JPanel(); removeButtonPanel.add(removeButton); removeButtonPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); removeIcon = new ImageIcon(this.getClass().getResource("/minus.png"), "Remove"); removeButton.setIcon(removeIcon); removeButton.setToolTipText(REMOVEBUTTONTIP); id = NOOFPANELS++; addLoadButtonListener(); addRemoveButtonListener(); addTextFieldListener(); setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 0; c.gridheight = 3; add(loadButtonPanel, c); c.gridx = 1; c.gridy = 0; c.weightx = .5; c.gridheight = 1; c.gridwidth = 3; add(label, c); c.gridwidth = 1; c.gridx = 1; c.gridy = 2; add(nodesCountLabel, c); c.gridx = 2; c.gridy = 2; add(samplesCountLabel, c); c.gridx = 1; c.gridy = 1; c.gridwidth = 3; add(textField, c); c.gridx = 4; c.gridy = 0; c.weightx = 0; c.gridheight = 3; c.gridwidth = 1; add(removeButtonPanel, c); // setMaximumSize(new Dimension(Integer.MAX_VALUE, // 3 * removeIcon.getIconHeight())); // Add a border. Border border = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); this.setBorder(border); }