List of usage examples for java.awt Font getName
public String getName()
From source file:com.eviware.soapui.support.components.SimpleForm.java
/** * Appends a heading with bold text that streches from the default label column to the end of the form * * @param text The text of the heading/*from www. j av a 2s . co m*/ */ public void appendHeading(String text) { JLabel label = new JLabel(text); Font font = label.getFont(); Font fontBold = new Font(font.getName(), Font.BOLD, font.getSize()); label.setFont(fontBold); append(null, null, label, null, DEFAULT_LABEL_COLUMN, getColumnSpanToTheEnd(DEFAULT_LABEL_COLUMN)); }
From source file:com.eviware.soapui.support.components.SimpleForm.java
public void appendHeadingAndHelpButton(String text, String helpUrl) { JLabel label = new JLabel(text); Font font = label.getFont(); Font fontBold = new Font(font.getName(), Font.BOLD, font.getSize()); label.setFont(fontBold);// w w w .ja v a 2s. c om JPanel innerPanel = new JPanel(); innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.X_AXIS)); innerPanel.add(label); innerPanel.add(Box.createHorizontalGlue()); innerPanel.add(UISupport.createFormButton(new ShowOnlineHelpAction(helpUrl))); append(null, null, innerPanel, null, DEFAULT_LABEL_COLUMN, getColumnSpanToTheEnd(DEFAULT_LABEL_COLUMN)); }
From source file:org.apache.pdfbox.pdmodel.font.PDCIDFontType2Font.java
/** * {@inheritDoc}/*from w w w.j a v a2 s .c om*/ */ public Font getawtFont() throws IOException { Font awtFont = null; PDFontDescriptorDictionary fd = (PDFontDescriptorDictionary) getFontDescriptor(); PDStream ff2Stream = fd.getFontFile2(); if (ff2Stream != null) { try { // create a font with the embedded data awtFont = Font.createFont(Font.TRUETYPE_FONT, ff2Stream.createInputStream()); } catch (FontFormatException f) { LOG.info("Can't read the embedded font " + fd.getFontName()); } if (awtFont == null) { awtFont = FontManager.getAwtFont(fd.getFontName()); if (awtFont != null) { LOG.info("Using font " + awtFont.getName() + " instead"); } setIsFontSubstituted(true); } } // TODO FontFile3 return awtFont; }
From source file:com.github.benchdoos.weblocopener.updater.gui.UpdateDialog.java
/** * @noinspection ALL// w ww . j a va2s. com */ private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { if (currentFont == null) return null; String resultName; if (fontName == null) { resultName = currentFont.getName(); } else { Font testFont = new Font(fontName, Font.PLAIN, 10); if (testFont.canDisplay('a') && testFont.canDisplay('1')) { resultName = fontName; } else { resultName = currentFont.getName(); } } return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); }
From source file:nz.govt.natlib.ndha.manualdeposit.dialogs.ApplicationProperties.java
private void setupForm(final String settingsPath) { this.setTitle("System Properties"); try {//from ww w . j ava 2 s. co m theFormControl = new FormControl(this, settingsPath); } catch (Exception ex) { LOG.error("Error loading form parameters", ex); } // Set fonts isSystemChange = true; final GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); final Font[] fonts = env.getAllFonts(); DefaultListModel model = new DefaultListModel(); for (int i = 0; i < fonts.length; i++) { final Font font = fonts[i]; model.add(i, font.getName()); } lstFont.setModel(model); // Set styles model = new DefaultListModel(); model.addElement("Plain"); model.addElement("Bold"); model.addElement("Italic"); model.addElement("Bold Italic"); lstStyle.setModel(model); // Set sizes model = new DefaultListModel(); model.addElement("8"); model.addElement("10"); model.addElement("12"); model.addElement("14"); model.addElement("18"); model.addElement("20"); model.addElement("22"); model.addElement("24"); lstSize.setModel(model); txtFontSize.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(final DocumentEvent e) { updateFontSize(); } public void removeUpdate(final DocumentEvent e) { updateFontSize(); } public void insertUpdate(final DocumentEvent e) { updateFontSize(); } }); model = new DefaultListModel(); for (String favourite : personalSettings.getFavourites()) { model.addElement(favourite); } lstFavourites.setModel(model); model = new DefaultListModel(); for (PersonalSettings.FileDescriptions descriptions : personalSettings.getFilesToIgnore()) { model.addElement(descriptions); } lstFilesToIgnore.setModel(model); final DefaultComboBoxModel cmbModel = new DefaultComboBoxModel(); for (PersonalSettings.TextPosition position : PersonalSettings.TextPosition.values()) { cmbModel.addElement(position); } cmbTextPosition.setModel(cmbModel); chkSortRunning.setSelected(personalSettings.isSortRunningAscending()); chkSortPending.setSelected(personalSettings.isSortPendingAscending()); chkSortFailed.setSelected(personalSettings.isSortFailedAscending()); chkSortDeposited.setSelected(personalSettings.isSortDepositedAscending()); chkSortComplete.setSelected(personalSettings.isSortCompleteAscending()); txtNoOfRetries.setText(String.format("%d", personalSettings.getNoOfRetries())); isSystemChange = false; }
From source file:com.isencia.passerelle.hmi.generic.GenericHMI.java
private JPanel createTitlePanel(final String name) { final JPanel result = new JPanel(new BorderLayout()); final ImageIcon icon = new ImageIcon(Toolkit.getDefaultToolkit() .getImage(getClass().getResource("/com/isencia/passerelle/hmi/resources/param.gif"))); final JLabel startLabel = new JLabel(icon); result.add(startLabel, BorderLayout.LINE_START); final JLabel nameLabel = new JLabel(name); final Font f = nameLabel.getFont(); nameLabel.setFont(new Font(f.getName(), f.getStyle(), f.getSize() + 2)); nameLabel.setForeground(new Color(49, 106, 196)); result.add(nameLabel);//from w w w . j a va2 s. c o m return result; }
From source file:com.aurel.track.report.gantt.data.TrackGanttRenderer.java
/** Prints the specified labelstring. If neccessary it reduces the * font size that the label fits in the specified space. * The x coordinate specifies the startposition. * The y coordinate specifies the lower startposition of the label. * If alignRight is true, this method subtracts the length of the * labelstring and 3 pixels from the x coordinate. * Otherwise it adds 3 pixels to the x coordinate. *//*from w w w . j ava 2 s .co m*/ private void drawLabel(String s, Graphics2D g2, int _x, int _y, Font f, boolean alignRight, int space) { g2.setPaint(Color.black); g2.setFont(f); int x = 0; if (alignRight) { // subtract the length neede to print the label from the x coordinate x = _x - g2.getFontMetrics().stringWidth(s) - 3; } else { while (g2.getFontMetrics().stringWidth(s) > space - 4) { log.debug("Reducing Font size for label " + s); f = new Font(f.getName(), f.getStyle(), f.getSize() - 1); g2.setFont(f); } x = _x + 2; } g2.drawString(s, x, _y); }
From source file:com.isencia.passerelle.hmi.generic.GenericHMI.java
private JPanel createCompositePanel(final JPanel b, final JComponent c, final String name) { final JPanel compositeBox = new JPanel(new VerticalLayout(5)); int r = b.getBackground().getRed() - 20; if (r < 1) { r = 0;//w w w. j a va2s .c o m } if (r > 254) { r = 255; } int g = b.getBackground().getGreen() - 20; if (g < 1) { g = 0; } if (g > 254) { g = 255; } int bl = b.getBackground().getBlue() - 20; if (bl < 1) { bl = 0; } if (bl > 254) { bl = 255; } compositeBox.setBackground(new Color(r, g, bl)); final JPanel title = new JPanel(new BorderLayout()); title.setBackground(new Color(r, g, bl)); /* * ImageIcon icon = new ImageIcon( Toolkit .getDefaultToolkit() * .getImage( (getClass() * .getResource("/com/isencia/passerelle/hmi/resources/composite.gif" * )))); JLabel lab = new JLabel(icon); * * title.add(lab, BorderLayout.LINE_START); */ final JLabel lab2 = new JLabel(name); final Font f = lab2.getFont(); lab2.setFont(new Font(f.getName(), f.getStyle(), f.getSize() + 6)); lab2.setForeground(new Color(49, 106, 196)); title.add(lab2); compositeBox.add(title); final Border loweredbevel = BorderFactory.createLoweredBevelBorder(); final TitledBorder border = BorderFactory.createTitledBorder(loweredbevel); compositeBox.setBorder(border); compositeBox.setName(name); c.setBackground(new Color(r, g, bl)); compositeBox.add(c); return compositeBox; }
From source file:userinterface.graph.AxisSettings.java
public void save(Element axis) throws SettingException { axis.setAttribute("heading", getHeading()); Font headingFont = getHeadingFont().f; axis.setAttribute("headingFontName", headingFont.getName()); axis.setAttribute("headingFontSize", "" + headingFont.getSize()); axis.setAttribute("headingFontStyle", "" + headingFont.getStyle()); Color headingFontColor = getHeadingFont().c; axis.setAttribute("headingFontColourR", "" + headingFontColor.getRed()); axis.setAttribute("headingFontColourG", "" + headingFontColor.getGreen()); axis.setAttribute("headingFontColourB", "" + headingFontColor.getBlue()); Font numberFont = getNumberFont().f; axis.setAttribute("numberFontName", numberFont.getName()); axis.setAttribute("numberFontSize", "" + numberFont.getSize()); axis.setAttribute("numberFontStyle", "" + numberFont.getStyle()); Color numberFontColor = getHeadingFont().c; axis.setAttribute("numberFontColourR", "" + numberFontColor.getRed()); axis.setAttribute("numberFontColourG", "" + numberFontColor.getGreen()); axis.setAttribute("numberFontColourB", "" + numberFontColor.getBlue()); axis.setAttribute("showMajor", showGrid() ? "true" : "false"); Color gridColor = gridColour.getColorValue(); axis.setAttribute("majorColourR", "" + gridColor.getRed()); axis.setAttribute("majorColourG", "" + gridColor.getGreen()); axis.setAttribute("majorColourB", "" + gridColor.getBlue()); axis.setAttribute("logarithmic", isLogarithmic() ? "true" : "false"); axis.setAttribute("minValue", "" + getMinValue()); axis.setAttribute("maxValue", "" + getMaxValue()); axis.setAttribute("majorGridInterval", "" + getGridInterval()); axis.setAttribute("logBase", "" + getLogBase()); axis.setAttribute("logStyle", "" + getLogStyle()); axis.setAttribute("minimumPower", "" + getMinimumPower()); axis.setAttribute("maximumPower", "" + getMaximumPower()); axis.setAttribute("autoscale", isAutoScale() ? "true" : "false"); }
From source file:io.github.jeremgamer.editor.panels.components.ButtonPanel.java
public ButtonPanel(JFrame frame) { this.frame = frame; this.setSize(new Dimension(395, frame.getHeight() - 27 - 23)); this.setLocation(300, 0); this.setBorder(BorderFactory.createTitledBorder("Edition du bouton")); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); JLabel nameLabel = new JLabel("Nom : "); name.setPreferredSize(new Dimension(this.getWidth() - 285, 30)); name.setEditable(false);/*w w w .j av a2 s . co m*/ JPanel namePanel = new JPanel(); namePanel.add(nameLabel); namePanel.add(name); JPanel textPanel = new JPanel(); JPanel nameAndTextPanel = new JPanel(); JLabel textLabel = new JLabel("Texte :"); CaretListener caretUpdateText = new CaretListener() { public void caretUpdate(javax.swing.event.CaretEvent e) { JTextField text = (JTextField) e.getSource(); bs.set("text", text.getText()); preview.setText(text.getText()); preview2.setText(text.getText()); } }; text.addCaretListener(caretUpdateText); text.setPreferredSize(new Dimension(this.getWidth() - 283, 30)); textPanel.add(textLabel); textPanel.add(text); nameAndTextPanel.setLayout(new BoxLayout(nameAndTextPanel, BoxLayout.PAGE_AXIS)); nameAndTextPanel.add(namePanel); nameAndTextPanel.add(textPanel); JPanel policePanel = new JPanel(); JLabel policeLabel = new JLabel("Police : "); police.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) e.getSource(); fontStyle = (String) combo.getSelectedItem(); preview.setFont(new Font(fontStyle, Font.PLAIN, fontSize)); preview2.setFont(new Font(fontStyle, Font.PLAIN, fontSize)); bs.set("police", fontStyle); } }); police.setPreferredSize(new Dimension(105, 30)); GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] fonts = e.getAllFonts(); for (Font f : fonts) { police.addItem(f.getName()); } police.setSelectedItem("Arial"); policePanel.add(policeLabel); policePanel.add(police); JPanel sizePanel = new JPanel(); size.setPreferredSize(new Dimension(60, 25)); JLabel sizeLabel = new JLabel("Taille : "); sizePanel.add(sizeLabel); sizePanel.add(size); JButton colorButton = new JButton("Couleur"); colorButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { colorFrame.setModal(false); JButton finish = new JButton("Terminer"); finish.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { colorFrame.dispose(); } }); colorFrame.setLayout(new BorderLayout()); colorFrame.add(color, BorderLayout.CENTER); colorFrame.add(finish, BorderLayout.SOUTH); colorFrame.pack(); colorFrame.setLocation(SwingUtilities.windowForComponent(imagedButton).getX() + 325, SwingUtilities.windowForComponent(imagedButton).getY() - colorFrame.getHeight() + 40); colorFrame.setVisible(true); } }); sizePanel.add(colorButton); size.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); fontSize = (int) spinner.getValue(); preview.setFont(new Font(fontStyle, Font.PLAIN, fontSize)); preview2.setFont(new Font(fontStyle, Font.PLAIN, fontSize)); bs.set("size", fontSize); } }); JPanel policeAndSize = new JPanel(); policeAndSize.setLayout(new BoxLayout(policeAndSize, BoxLayout.PAGE_AXIS)); policeAndSize.add(policePanel); policeAndSize.add(sizePanel); JPanel top = new JPanel(); top.add(nameAndTextPanel); top.add(policeAndSize); top.setPreferredSize(new Dimension(395, 20)); this.add(top); JPanel images = new JPanel(); images.setBorder(BorderFactory.createTitledBorder("Images")); images.setLayout(new GridLayout(2, 3)); images.setPreferredSize(new Dimension(395, this.getHeight() - 320)); JPanel imaged = new JPanel(); imaged.setLayout(new BorderLayout()); imaged.setBorder(BorderFactory.createTitledBorder("Icne interne")); imagedButton.setSelected(true); imagedButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { if (ev.getStateChange() == ItemEvent.SELECTED) { bs.set("strings", true); preview.setBorderPainted(true); } else if (ev.getStateChange() == ItemEvent.DESELECTED) { bs.set("strings", false); preview.setBorderPainted(false); } } }); JButton browseInternal = new JButton("Parcourir"); browseInternal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { String path = null; JFileChooser chooser = new JFileChooser(Editor.lastPath); FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg", "bmp"); chooser.setFileFilter(filter); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int option = chooser.showOpenDialog(null); if (option == JFileChooser.APPROVE_OPTION) { path = chooser.getSelectedFile().getAbsolutePath(); Editor.lastPath = chooser.getSelectedFile().getParent(); copyImage(new File(path), "internal.png"); nameInternal.setText(new File(path).getName()); nameInternal.setPreferredSize(new Dimension(imgBasic.getWidth() - 10, 30)); preview.setIcon(new ImageIcon(path)); preview.repaint(); bs.set("imageInternal", new File(path).getName()); } } }); JPanel northImaged = new JPanel(); northImaged.setLayout(new BorderLayout()); northImaged.add(imagedButton, BorderLayout.NORTH); northImaged.add(browseInternal, BorderLayout.SOUTH); imaged.add(northImaged, BorderLayout.NORTH); imaged.add(nameInternal, BorderLayout.CENTER); JButton removeInternal = null; try { removeInternal = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e1) { e1.printStackTrace(); } removeInternal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { File file = new File( "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/internal.png"); file.delete(); nameInternal.setText(""); bs.set("imageInternal", ""); preview.setIcon(null); } }); imaged.add(removeInternal, BorderLayout.SOUTH); images.add(imaged); imgBasic.setBorder(BorderFactory.createTitledBorder("Base")); JButton browseBasic = new JButton("Parcourir"); browseBasic.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { String path = null; JFileChooser chooser = new JFileChooser(Editor.lastPath); FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg", "bmp"); chooser.setFileFilter(filter); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int option = chooser.showOpenDialog(null); if (option == JFileChooser.APPROVE_OPTION) { path = chooser.getSelectedFile().getAbsolutePath(); Editor.lastPath = chooser.getSelectedFile().getParent(); copyImage(new File(path), "basic.png"); nameBasic.setText(new File(path).getName()); nameBasic.setPreferredSize(new Dimension(imgBasic.getWidth() - 10, 30)); previewPanel.remove(preview); previewPanel.remove(preview2); previewPanel.add(preview2); color.changePreview(preview2); bs.set("imageBasic", new File(path).getName()); preview2.update(); previewPanel.repaint(); } } }); imgBasic.setLayout(new BorderLayout()); imgBasic.add(browseBasic, BorderLayout.NORTH); imgBasic.add(nameBasic, BorderLayout.CENTER); JButton removeBasic = null; try { removeBasic = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e1) { e1.printStackTrace(); } removeBasic.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { File file = new File( "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/basic.png"); file.delete(); nameBasic.setText(""); bs.set("imageBasic", ""); preview2.update(); previewPanel.repaint(); if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("") && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("") && bs.getString("imageReleased").equals("")) { previewPanel.remove(preview2); previewPanel.add(preview); } } }); imgBasic.add(removeBasic, BorderLayout.SOUTH); images.add(imgBasic); imgEntered.setBorder(BorderFactory.createTitledBorder("Survol")); JButton browseEntered = new JButton("Parcourir"); browseEntered.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { String path = null; JFileChooser chooser = new JFileChooser(Editor.lastPath); FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg", "bmp"); chooser.setFileFilter(filter); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int option = chooser.showOpenDialog(null); if (option == JFileChooser.APPROVE_OPTION) { path = chooser.getSelectedFile().getAbsolutePath(); Editor.lastPath = chooser.getSelectedFile().getParent(); copyImage(new File(path), "entered.png"); nameEntered.setText(new File(path).getName()); nameEntered.setPreferredSize(new Dimension(imgEntered.getWidth() - 10, 30)); bs.set("imageEntered", new File(path).getName()); preview2.update(); previewPanel.repaint(); } } }); imgEntered.setLayout(new BorderLayout()); imgEntered.add(browseEntered, BorderLayout.NORTH); imgEntered.add(nameEntered, BorderLayout.CENTER); JButton removeEntered = null; try { removeEntered = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e1) { e1.printStackTrace(); } removeEntered.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { File file = new File( "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/entered.png"); file.delete(); nameEntered.setText(""); bs.set("imageEntered", ""); preview2.update(); previewPanel.repaint(); if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("") && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("") && bs.getString("imageReleased").equals("")) { previewPanel.remove(preview2); previewPanel.add(preview); } } }); imgEntered.add(removeEntered, BorderLayout.SOUTH); images.add(imgEntered); imgExited.setBorder(BorderFactory.createTitledBorder("Sortie")); JButton browseExited = new JButton("Parcourir"); browseExited.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { String path = null; JFileChooser chooser = new JFileChooser(Editor.lastPath); FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg", "bmp"); chooser.setFileFilter(filter); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int option = chooser.showOpenDialog(null); if (option == JFileChooser.APPROVE_OPTION) { path = chooser.getSelectedFile().getAbsolutePath(); Editor.lastPath = chooser.getSelectedFile().getParent(); copyImage(new File(path), "exited.png"); nameExited.setText(new File(path).getName()); nameExited.setPreferredSize(new Dimension(imgExited.getWidth() - 10, 30)); bs.set("imageExited", new File(path).getName()); preview2.update(); previewPanel.repaint(); } } }); imgExited.setLayout(new BorderLayout()); imgExited.add(browseExited, BorderLayout.NORTH); imgExited.add(nameExited, BorderLayout.CENTER); JButton removeExited = null; try { removeExited = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e1) { e1.printStackTrace(); } removeExited.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { File file = new File( "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/exited.png"); file.delete(); nameExited.setText(""); bs.set("imageExited", ""); preview2.update(); previewPanel.repaint(); if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("") && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("") && bs.getString("imageReleased").equals("")) { previewPanel.remove(preview2); previewPanel.add(preview); } } }); imgExited.add(removeExited, BorderLayout.SOUTH); images.add(imgExited); imgPressed.setBorder(BorderFactory.createTitledBorder("Clic")); JButton browsePressed = new JButton("Parcourir"); browsePressed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { String path = null; JFileChooser chooser = new JFileChooser(Editor.lastPath); FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg", "bmp"); chooser.setFileFilter(filter); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int option = chooser.showOpenDialog(null); if (option == JFileChooser.APPROVE_OPTION) { path = chooser.getSelectedFile().getAbsolutePath(); Editor.lastPath = chooser.getSelectedFile().getParent(); copyImage(new File(path), "pressed.png"); namePressed.setText(new File(path).getName()); namePressed.setPreferredSize(new Dimension(imgPressed.getWidth() - 10, 30)); bs.set("imagePressed", new File(path).getName()); preview2.update(); previewPanel.repaint(); } } }); imgPressed.setLayout(new BorderLayout()); imgPressed.add(browsePressed, BorderLayout.NORTH); imgPressed.add(namePressed, BorderLayout.CENTER); JButton removePressed = null; try { removePressed = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e1) { e1.printStackTrace(); } removePressed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { File file = new File( "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/pressed.png"); file.delete(); namePressed.setText(""); bs.set("imagePressed", ""); preview2.update(); previewPanel.repaint(); if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("") && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("") && bs.getString("imageReleased").equals("")) { previewPanel.remove(preview2); previewPanel.add(preview); } } }); imgPressed.add(removePressed, BorderLayout.SOUTH); images.add(imgPressed); imgReleased.setBorder(BorderFactory.createTitledBorder("Relachement")); JButton browseReleased = new JButton("Parcourir"); browseReleased.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { String path = null; JFileChooser chooser = new JFileChooser(Editor.lastPath); FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg", "bmp"); chooser.setFileFilter(filter); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int option = chooser.showOpenDialog(null); if (option == JFileChooser.APPROVE_OPTION) { path = chooser.getSelectedFile().getAbsolutePath(); Editor.lastPath = chooser.getSelectedFile().getParent(); copyImage(new File(path), "released.png"); nameReleased.setText(new File(path).getName()); nameReleased.setPreferredSize(new Dimension(imgReleased.getWidth() - 10, 30)); bs.set("imageReleased", new File(path).getName()); preview2.update(); previewPanel.repaint(); } } }); imgReleased.setLayout(new BorderLayout()); imgReleased.add(browseReleased, BorderLayout.NORTH); imgReleased.add(nameReleased, BorderLayout.CENTER); JButton removeReleased = null; try { removeReleased = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e1) { e1.printStackTrace(); } removeReleased.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { File file = new File( "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/released.png"); file.delete(); nameReleased.setText(""); bs.set("imageReleased", ""); preview2.update(); previewPanel.repaint(); if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("") && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("") && bs.getString("imageReleased").equals("")) { previewPanel.remove(preview2); previewPanel.add(preview); } } }); imgReleased.add(removeReleased, BorderLayout.SOUTH); images.add(imgReleased); this.add(images); JPanel action = new JPanel(); action.setPreferredSize(new Dimension(395, -20)); JLabel labelAction = new JLabel("Action : "); action.add(labelAction); actionList.removeAllItems(); actionList.addItem("Aucune"); for (String s : Actions.getActions()) { actionList.addItem(s); } actionList.setPreferredSize(new Dimension(this.getWidth() - 100, 30)); actionList.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) event.getSource(); bs.set("action", combo.getSelectedItem()); } }); action.add(actionList); this.add(action); JScrollPane previewScroll = new JScrollPane(previewPanel); previewScroll.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); previewPanel.setBorder(BorderFactory.createTitledBorder("Aperu")); previewPanel.add(preview); previewScroll.setPreferredSize(new Dimension(395, 40)); previewScroll.setBorder(null); this.add(previewScroll); }