/** Process the action event from the open button */ public void actionPerformed(ActionEvent evt) { if (openDialog == null) openDialog = new JFileChooser(); int ret_val = openDialog.showOpenDialog(this); if (ret_val != JFileChooser.APPROVE_OPTION) return; File file = openDialog.getSelectedFile(); try { System.out.println("Loading external file: " + file); FileInputStream is = new FileInputStream(file); BufferedInputStream stream = new BufferedInputStream(is); BufferedImage img = ImageIO.read(stream); if (img == null) { System.out.println("Image load barfed"); return; } srcIcon.setImage(img); srcLabel.setIcon(srcIcon); BufferedImage map_img = textureUtils.createNormalMap(img, null); mapIcon.setImage(map_img); mapLabel.setIcon(mapIcon); } catch (IOException ioe) { System.out.println("crashed " + ioe.getMessage()); ioe.printStackTrace(); } }
/** ************** Display result of processed Image *********** */ void imageResultDisplay(int width, int height, int pix[]) { img_temp = createImage(new MemoryImageSource(width, height, pix, 0, width)); ImageIcon imgIcon = new ImageIcon(); imgIcon.setImage(img_temp); lbl_res.setIcon(imgIcon); }
/** ****************** Display Gray Scale version of image opened *************** */ void grayImageDisplay(int width, int height, int pix[]) { img_temp = createImage(new MemoryImageSource(width, height, pix, 0, width)); ImageIcon imgI = new ImageIcon(); imgI.setImage(img_temp); lbl_gray.setIcon(imgI); }
private void updateGraph() { if (sourceIdentifier != null && selectedGraph >= 0 && selectedGraph < graphImageFactories.length) { GraphImageProducer graphImageFactory = graphImageFactories[selectedGraph]; imageToggle[imageIndex] = graphImageFactory.createGraphImage( Util.getTime(), sourceIdentifier, imageToggle[imageIndex], showMaxCheckBox.isSelected()); if (imageToggle[imageIndex] != null) { ImageIcon graphImageIcon = new ImageIcon(); graphImageIcon.setImage(imageToggle[imageIndex]); graphLabel.setIcon(graphImageIcon); graphLabel.setText(""); } else { graphLabel.setIcon(null); graphLabel.setText("Couldn't create graph image!"); } if (imageIndex == 0) { imageIndex = 1; } else { imageIndex = 0; } graphLabel.repaint(); } }
public Abschluss(String wahl, Sudoku s, Sudoku2 s2) { super("Sudoku-Abschluss"); this.setSize(270, 135); this.setLocation(250, 300); this.setLayout(null); this.setAlwaysOnTop(true); this.setResizable(false); this.setUndecorated(true); if (s == null) this.setLocationRelativeTo(s2); else this.setLocationRelativeTo(s); su = s; su2 = s2; w = wahl; ImageIcon icon = new ImageIcon("files/minigames/Sudoku/beispiel2.jpg"); icon.setImage(icon.getImage().getScaledInstance(290, 135, Image.SCALE_DEFAULT)); lab = new JLabel(icon); lab.setSize(270, 135); lab.setLocation(0, 0); this.add(lab); text = new JLabel(); text.setSize(250, 20); text.setLocation(10, 10); text.setForeground(Color.white); text.setHorizontalAlignment(0); lab.add(text); text2 = new JLabel(); text2.setSize(270, 20); text2.setLocation(10, 30); text2.setForeground(Color.white); lab.add(text2); ok = new JButton("OK"); ok.setSize(90, 30); ok.setLocation(80, 50); ok.setBorderPainted(false); ok.setBackground(Color.lightGray); ok.setForeground(Color.lightGray); ok.setOpaque(false); ok.setFont(new Font("Arial Black", 4, 20)); ok.setContentAreaFilled(false); ok.setFocusPainted(false); ok.addActionListener(this); ok.addMouseListener(this); lab.add(ok); textWahl(wahl); this.setVisible(true); }
public static ImageIcon AboutImage() { ImageIcon image = null; String imagename = Settings().getAboutImage(); if ((imagename != null) && "".compareTo(imagename) != 0) { image = new ImageIcon(); try { image.setImage(ImageIO.read(Settings().getResourceAsStream(imagename))); } catch (Exception e) { Logger().warning("About image not found " + imagename + ": " + e.getMessage()); } } return image; }
// populate version for corrections public void showCorrectionTileUpgrades() { // deactivate correctionTokenMode and tokenmode correctionTokenMode = false; tokenMode = false; // activate upgrade panel upgradePanel.removeAll(); GridLayout panelLayout = (GridLayout) upgradePanel.getLayout(); List<TileI> tiles = orUIManager.tileUpgrades; if (tiles == null || tiles.size() == 0) { // reset to the number of elements panelLayout.setRows(defaultNbPanelElements); // set to position 0 scrollPane.getVerticalScrollBar().setValue(0); } else { // set to the max of available or the default number of elements panelLayout.setRows(Math.max(tiles.size() + 2, defaultNbPanelElements)); for (TileI tile : tiles) { BufferedImage hexImage = getHexImage(tile.getId()); ImageIcon hexIcon = new ImageIcon(hexImage); // Cheap n' Easy rescaling. hexIcon.setImage( hexIcon .getImage() .getScaledInstance( (int) (hexIcon.getIconWidth() * GUIHex.NORMAL_SCALE * 0.8), (int) (hexIcon.getIconHeight() * GUIHex.NORMAL_SCALE * 0.8), Image.SCALE_SMOOTH)); HexLabel hexLabel = new HexLabel(hexIcon, tile.getId()); hexLabel.setName(tile.getName()); hexLabel.setTextFromTile(tile); hexLabel.setOpaque(true); hexLabel.setVisible(true); hexLabel.setBorder(border); hexLabel.addMouseListener(this); upgradePanel.add(hexLabel); } } upgradePanel.add(doneButton); upgradePanel.add(cancelButton); // repaint(); revalidate(); }
void displayWifiPassword() { Config config = Config.instance(); config.setEmail(emailField.getText()); config.setRememberPassword(rememberPasswordCheckbox.getState()); config.setPassword(passField.getText()); config.updateConfig(); if (Config.instance().getQRImage() == null || Config.instance().getWifiPassword().isEmpty()) { if (Config.instance().getWifiPassword().isEmpty()) { wifiPasswordField.setText(""); } hintLabel.setText("QRCode has not been generated"); qrCodeLabel.setIcon(idleIcon); return; } try { wifiPasswordField.setText(Config.instance().getWifiPassword()); BufferedImage qrImage = Config.instance().getQRImage(); int width = qrCodeLabel.getWidth(); int height = qrCodeLabel.getHeight(); // make a square image int length = width < height ? width : height; ImageIcon imgIcon = new ImageIcon(); imgIcon.setImage(qrImage.getScaledInstance(length, length, Image.SCALE_AREA_AVERAGING)); hintLabel.setText("Scan QRCode with mobile client to login clear-guest!"); wifiPasswordField.setText(Config.instance().getWifiPassword()); qrCodeLabel.setIcon(imgIcon); } catch (Exception e) { JOptionPane.showMessageDialog( mainPanel, "Failed to generate QR Image, please try again", "QRCode Generation Failed", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } }
public void paintComponent(Graphics g) { super.paintComponent(g); if (placer != null && index >= 0) { Dimension dim = placer.getModel().getSizeOf(index); ImageIcon icon, scaled_icon; // XXX: Come up with a cleaner way to do this. if (((ConfigElement) placer.getModel().getElement(index)) .getDefinition() .getToken() .equals(SURFACE_VIEWPORT_TYPE)) { icon = surfaceIcon; scaled_icon = scaledSurfaceIcon; } else { icon = simIcon; scaled_icon = scaledSimIcon; } // Check if we need to update the scaled image Image img = scaled_icon.getImage(); if ((scaled_icon.getIconWidth() != dim.width) || (scaled_icon.getIconHeight() != dim.height)) { img = icon.getImage().getScaledInstance(dim.width, dim.height, Image.SCALE_DEFAULT); scaled_icon.setImage(img); } // Sanity check in case our scale failed if (img != null) { g.drawImage(img, 0, 0, null); } // Highlight the window nicely if (selected) { g.setColor(getBackground()); } else { g.setColor(Color.white); } g.drawRect(0, 0, dim.width - 1, dim.height - 1); g.fillRect(0, 0, dim.width, 3); } }
private void updateColors() { ImageIcon icon; if (selected) { panelMain.setBackground(activeBackgroundColor); pnlBottom.setBackground(new Color(0xccd1d7)); icon = UnitUtilWrapper.BitcoinUnitWrapper.getWrapper(UnitUtil.BitcoinUnit.BTC).getBmpSlim(); } else { panelMain.setBackground(inactiveBackGroundColor); pnlBottom.setBackground(new Color(0xeeeeee)); icon = UnitUtilWrapper.BitcoinUnitWrapper.getWrapper(UnitUtil.BitcoinUnit.BTC).getBmpBlack(); } float width = icon.getIconWidth(); float height = icon.getIconHeight(); float scale = (float) 1.0f; icon.setImage( icon.getImage() .getScaledInstance((int) (width * scale), (int) (height * scale), Image.SCALE_SMOOTH)); }
public void showUpgrades() { upgradePanel.removeAll(); // reset to the number of elements GridLayout panelLayout = (GridLayout) upgradePanel.getLayout(); panelLayout.setRows(defaultNbPanelElements); if (tokenMode && possibleTokenLays != null && possibleTokenLays.size() > 0) { Color fgColour = null; Color bgColour = null; String text = null; String description = null; TokenIcon icon; ActionLabel tokenLabel; tokenLabels = new ArrayList<ActionLabel>(); for (LayToken action : possibleTokenLays) { if (action instanceof LayBaseToken) { PublicCompanyI comp = ((LayBaseToken) action).getCompany(); fgColour = comp.getFgColour(); bgColour = comp.getBgColour(); description = text = comp.getName(); if (action.getSpecialProperty() != null) { description += " (" + action.getSpecialProperty().getOriginalCompany().getName() + ")"; } } else if (action instanceof LayBonusToken) { fgColour = Color.BLACK; bgColour = Color.WHITE; BonusToken token = (BonusToken) action.getSpecialProperty().getToken(); description = token.getName(); text = "+" + token.getValue(); } icon = new TokenIcon(25, fgColour, bgColour, text); tokenLabel = new ActionLabel(icon); tokenLabel.setName(description); tokenLabel.setText(description); tokenLabel.setBackground(defaultLabelBgColour); tokenLabel.setOpaque(true); tokenLabel.setVisible(true); tokenLabel.setBorder(border); tokenLabel.addMouseListener(this); tokenLabel.addPossibleAction(action); tokenLabels.add(tokenLabel); upgradePanel.add(tokenLabel); } setSelectedToken(); } else if (orUIManager.tileUpgrades == null) {; } else if (orUIManager.tileUpgrades.size() == 0) { orUIManager.setMessage(LocalText.getText("NoTiles")); } else { for (TileI tile : orUIManager.tileUpgrades) { BufferedImage hexImage = getHexImage(tile.getPictureId()); ImageIcon hexIcon = new ImageIcon(hexImage); // Cheap n' Easy rescaling. hexIcon.setImage( hexIcon .getImage() .getScaledInstance( (int) (hexIcon.getIconWidth() * GUIHex.NORMAL_SCALE * 0.8), (int) (hexIcon.getIconHeight() * GUIHex.NORMAL_SCALE * 0.8), Image.SCALE_SMOOTH)); HexLabel hexLabel = new HexLabel(hexIcon, tile.getId()); hexLabel.setName(tile.getName()); hexLabel.setTextFromTile(tile); hexLabel.setOpaque(true); hexLabel.setVisible(true); hexLabel.setBorder(border); hexLabel.addMouseListener(this); upgradePanel.add(hexLabel); } } upgradePanel.add(doneButton); upgradePanel.add(cancelButton); // repaint(); revalidate(); }
private void setContent() { String iconPath = "/images/address_type_hdm.png"; ImageIcon icon = ImageLoader.createImageIcon(iconPath); icon.setImage(icon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH)); lblType.setIcon(icon); }
/** * Returns this panel that has been configured to display the meta contact and meta contact group * cells. * * @param tree the source tree * @param value the tree node * @param selected indicates if the node is selected * @param expanded indicates if the node is expanded * @param leaf indicates if the node is a leaf * @param row indicates the row number of the node * @param hasFocus indicates if the node has the focus * @return this panel */ public Component getTreeCellRendererComponent( JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { this.treeContactList = (TreeContactList) tree; this.row = row; this.isSelected = selected; this.treeNode = (TreeNode) value; this.rightLabel.setIcon(null); DefaultTreeContactList contactList = (DefaultTreeContactList) tree; setBorder(); addLabels(1); // Set background color. if (contactList instanceof TreeContactList) { ContactListFilter filter = ((TreeContactList) contactList).getCurrentFilter(); if (filter != null && filter.equals(TreeContactList.historyFilter) && value instanceof ContactNode && row % 2 == 0) { setBackground(Constants.CALL_HISTORY_EVEN_ROW_COLOR); } else { setBackground(Color.WHITE); } } // Make appropriate adjustments for contact nodes and group nodes. if (value instanceof ContactNode) { UIContactImpl contact = ((ContactNode) value).getContactDescriptor(); String displayName = contact.getDisplayName(); if ((displayName == null || displayName.trim().length() < 1) && !(contact instanceof ShowMoreContact)) { displayName = GuiActivator.getResources().getI18NString("service.gui.UNKNOWN"); } this.nameLabel.setText(displayName); if (statusIcon != null && contactList.isContactActive(contact) && statusIcon instanceof ImageIcon) ((ImageIcon) statusIcon).setImage(msgReceivedImage); else statusIcon = contact.getStatusIcon(); this.statusLabel.setIcon(statusIcon); this.nameLabel.setFont(this.getFont().deriveFont(Font.PLAIN)); if (contactForegroundColor != null) nameLabel.setForeground(contactForegroundColor); // Initializes status message components if the given meta contact // contains a status message. this.initDisplayDetails(contact.getDisplayDetails()); if (this.treeContactList.isContactButtonsVisible()) this.initButtonsPanel(contact); int avatarWidth, avatarHeight; if (isSelected && treeContactList.isContactButtonsVisible()) { avatarWidth = EXTENDED_AVATAR_WIDTH; avatarHeight = EXTENDED_AVATAR_HEIGHT; } else { avatarWidth = AVATAR_WIDTH; avatarHeight = AVATAR_HEIGHT; } Icon avatar = contact.getAvatar(isSelected, avatarWidth, avatarHeight); if (avatar != null) { this.rightLabel.setIcon(avatar); } if (contact instanceof ShowMoreContact) { rightLabel.setFont(rightLabel.getFont().deriveFont(12f)); rightLabel.setForeground(Color.GRAY); rightLabel.setText((String) contact.getDescriptor()); } else { rightLabel.setFont(rightLabel.getFont().deriveFont(9f)); rightLabel.setText(""); } this.setToolTipText(contact.getDescriptor().toString()); } else if (value instanceof GroupNode) { UIGroupImpl groupItem = ((GroupNode) value).getGroupDescriptor(); this.nameLabel.setText(groupItem.getDisplayName()); this.nameLabel.setFont(this.getFont().deriveFont(Font.BOLD)); if (groupForegroundColor != null) this.nameLabel.setForeground(groupForegroundColor); this.remove(displayDetailsLabel); this.remove(callButton); this.remove(callVideoButton); this.remove(desktopSharingButton); this.remove(chatButton); this.remove(addContactButton); clearCustomActionButtons(); statusIcon = expanded ? openedGroupIcon : closedGroupIcon; this.statusLabel.setIcon(expanded ? openedGroupIcon : closedGroupIcon); // We have no photo icon for groups. this.rightLabel.setIcon(null); this.rightLabel.setText(""); if (groupItem.countChildContacts() >= 0) { rightLabel.setFont(rightLabel.getFont().deriveFont(9f)); this.rightLabel.setForeground(Color.BLACK); this.rightLabel.setText( groupItem.countOnlineChildContacts() + "/" + groupItem.countChildContacts()); } this.initDisplayDetails(groupItem.getDisplayDetails()); this.initButtonsPanel(groupItem); this.setToolTipText(groupItem.getDescriptor().toString()); } return this; }
@Override public void actionPerformed(ActionEvent ae) { if (ae.getSource() == jbtnCargarI) { try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception ex) { System.err.println(ex); } // Creamos un nuevo cuadro de diálogo para seleccionar imagen JFileChooser selector = new JFileChooser(); // Le damos un título selector.setDialogTitle("Seleccione una imagen"); // Filtramos los tipos de archivos FileNameExtensionFilter filtroImagen = new FileNameExtensionFilter("JPG & PNG", "jpg", "png"); selector.setFileFilter(filtroImagen); // Abrimos el cuadro de diálog int flag = selector.showOpenDialog(null); // Comprobamos que pulse en aceptar if (flag == JFileChooser.APPROVE_OPTION) { try { // Devuelve el fichero seleccionado File imagenSeleccionada = selector.getSelectedFile(); // sacamos el nombre de la imagen x = imagenSeleccionada.getName(); // Asignamos a la variable bmp la imagen leida bmp = ImageIO.read(imagenSeleccionada); } catch (Exception e) { System.out.print("El error es: " + e); } image.setImage(bmp); jlbimage.setIcon( new ImageIcon(image.getImage().getScaledInstance(150, 150, Image.SCALE_DEFAULT))); nombre.setText(x); } try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (Exception ex) { ex.printStackTrace(); } } if (ae.getSource() == jbtnGuardar) { UsuarioEnt usuarioE = new UsuarioEnt(); UsuarioNg usuarioN = new UsuarioNg(); usuarioE.setDocumento(correo); usuarioE.setImage(bmp); boolean respuesta = usuarioN.modificarImagen(usuarioE); if (respuesta) { nombre.setText("Ninguna imagen seleccionada"); JOptionPane.showMessageDialog( null, "Se guardo la imagen", "Airline Travel", JOptionPane.INFORMATION_MESSAGE); } } if (ae.getSource() == jbtnQuitarI) { jlbimage.setIcon(new ImageIcon(getClass().getResource("/Imagenes/defecto.png"))); bmp = null; nombre.setText("Ninguna imagen seleccionada"); x = null; } }