List of usage examples for javax.swing SwingUtilities windowForComponent
public static Window windowForComponent(Component c)
Window
ancestor of c
, or null if c
is not contained inside a Window
. From source file:Main.java
public Main() { comboBox = new JComboBox(new String[] { "Select Pet", "Bird", "Cat", "Dog", "Rabbit", "Pig", "Other" }); add(comboBox, BorderLayout.PAGE_START); JFrame frame = new JFrame("Main"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(comboBox);//from w w w . j ava2 s.c o m frame.pack(); frame.setVisible(true); comboBox.showPopup(); Object child = comboBox.getAccessibleContext().getAccessibleChild(0); BasicComboPopup popup = (BasicComboPopup) child; popup.setName("BasicComboPopup"); JList list = popup.getList(); Container c = SwingUtilities.getAncestorOfClass(JScrollPane.class, list); JScrollPane scrollPane = (JScrollPane) c; Window mainFrame = SwingUtilities.windowForComponent(comboBox); System.out.println(mainFrame.getName()); Window popupWindow = SwingUtilities.windowForComponent(popup); System.out.println(popupWindow); Window popupWindowa = SwingUtilities.windowForComponent(c); System.out.println(popupWindowa); Window mainFrame1 = SwingUtilities.getWindowAncestor(comboBox); System.out.println(mainFrame1); Window popupWindow1 = SwingUtilities.getWindowAncestor(popup); System.out.println(popupWindow1); Component mainFrame2 = SwingUtilities.getRoot(comboBox); System.out.println(mainFrame2.getName()); Component popupWindow2 = SwingUtilities.getRoot(popup); System.out.println(popupWindow2); if (popupWindow != mainFrame) { popupWindow.pack(); } }
From source file:Main.java
public Main() { label = new JLabel("Waiting..."); frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(label);//from w w w . j a v a 2 s .c o m frame.setSize(200, 200); frame.setVisible(true); Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { int count; @Override public void eventDispatched(AWTEvent event) { Object source = event.getSource(); if (source instanceof Component) { Component comp = (Component) source; Window win = null; if (comp instanceof Window) { win = (Window) comp; } else { win = SwingUtilities.windowForComponent(comp); } if (win == frame) { timer.restart(); label.setText("Interrupted..." + (++count)); } } } }, AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK); timer = new Timer(5000, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { frame.dispose(); } }); timer.start(); }
From source file:org.cds06.speleograph.graph.GraphEditor.java
/** * Creates a modal dialog by specifying the attached {@link GraphPanel}. * <p>Please look at {@link javax.swing.JDialog#JDialog()} to see defaults params applied to this Dialog.</p> *//* w w w. j a v a 2 s . com*/ public GraphEditor(GraphPanel panel) { super((Frame) SwingUtilities.windowForComponent(panel), true); Validate.notNull(panel); this.graphPanel = panel; KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); mainPanel.registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); setContentPane(mainPanel); mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); this.setTitle(I18nSupport.translate("menus.graph.graphEditor")); { // This section use FormLayout which is an external layout for Java, consult the doc before edit the // following lines ! final FormLayout layout = new FormLayout( "right:max(40dlu;p), 4dlu, p:grow, 4dlu, p, 4dlu, p:grow, 4dlu, p", //NON-NLS "p,4dlu,p,4dlu,p,4dlu,p,4dlu,p" //NON-NLS ); PanelBuilder builder = new PanelBuilder(layout); final JLabel colorLabel = new JLabel(); final JTextField titleForGraph = new JTextField( graphPanel.getChart().getTitle() != null ? graphPanel.getChart().getTitle().getText() : ""); final JLabel colorXYPlotLabel = new JLabel(); final JLabel colorGridLabel = new JLabel(); final JCheckBox showLegendCheckBox = new JCheckBox("Afficher la lgende", graphPanel.getChart().getLegend().isVisible()); { builder.addLabel("Titre :", "1,1"); builder.add(titleForGraph, "3,1,7,1"); } { builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.backgroundColor"), "1,3"); colorLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); colorLabel.setText(" "); colorLabel.setBackground((Color) graphPanel.getChart().getBackgroundPaint()); colorLabel.setOpaque(true); colorLabel.setEnabled(false); final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit")); edit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color c = JColorChooser.showDialog(GraphEditor.this, I18nSupport.translate("menus.graph.graphEditor.selectColor"), colorLabel.getBackground()); if (c != null) { colorLabel.setBackground(c); } } }); builder.add(colorLabel, "3,3,5,1"); builder.add(edit, "9,3"); } final XYPlot xyPlot = graphPanel.getChart().getXYPlot(); { builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.graphColor"), "1,5"); colorXYPlotLabel.setText(" "); colorXYPlotLabel.setOpaque(true); colorXYPlotLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); colorXYPlotLabel.setBackground((Color) xyPlot.getBackgroundPaint()); colorXYPlotLabel.setEnabled(false); final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit")); edit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color c = JColorChooser.showDialog(GraphEditor.this, I18nSupport.translate("menus.graph.graphEditor.selectColor"), colorXYPlotLabel.getBackground()); if (c != null) { colorXYPlotLabel.setBackground(c); } } }); builder.add(colorXYPlotLabel, "3,5,5,1"); builder.add(edit, "9,5"); } { builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.gridColor"), "1,7"); colorGridLabel.setOpaque(true); colorGridLabel.setText(" "); colorGridLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); colorGridLabel.setBackground((Color) xyPlot.getRangeGridlinePaint()); colorGridLabel.setEnabled(false); final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit")); edit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color c = JColorChooser.showDialog(GraphEditor.this, I18nSupport.translate("menus.graph.graphEditor.selectColor"), colorGridLabel.getBackground()); if (c != null) { colorGridLabel.setBackground(c); } } }); builder.add(colorGridLabel, "3,7,5,1"); builder.add(edit, "9,7"); } { builder.add(showLegendCheckBox, "1,9,9,1"); } mainPanel.add(builder.build(), BorderLayout.CENTER); ButtonBarBuilder buttonBarBuilder = new ButtonBarBuilder(); buttonBarBuilder.addGlue(); buttonBarBuilder.addButton(new AbstractAction() { { putValue(NAME, I18nSupport.translate("cancel")); } @Override public void actionPerformed(ActionEvent e) { GraphEditor.this.setVisible(false); } }); buttonBarBuilder.addButton(new AbstractAction() { { putValue(NAME, I18nSupport.translate("ok")); } @Override public void actionPerformed(ActionEvent e) { if (titleForGraph.getText().isEmpty()) graphPanel.getChart().setTitle((String) null); else graphPanel.getChart().setTitle(titleForGraph.getText()); { Color c = colorGridLabel.getBackground(); xyPlot.setRangeGridlinePaint(c); xyPlot.setRangeMinorGridlinePaint(c); xyPlot.setDomainGridlinePaint(c); xyPlot.setDomainMinorGridlinePaint(c); } graphPanel.getChart().setBackgroundPaint(colorLabel.getBackground()); xyPlot.setBackgroundPaint(colorXYPlotLabel.getBackground()); graphPanel.getChart().getLegend().setVisible(showLegendCheckBox.isSelected()); GraphEditor.this.setVisible(false); } }); mainPanel.add(buttonBarBuilder.build(), BorderLayout.SOUTH); } pack(); Dimension d = this.getPreferredSize(); this.setSize(new Dimension(d.width + 20, d.height)); setResizable(false); }
From source file:com.moss.appprocs.swing.ProgressDialog.java
private static JDialog makeDialogFor(Component c) { Window w = SwingUtilities.windowForComponent(c); if (w == null) { throw new RuntimeException( "The component heirarchy for the passed component does not end at a window:" + c); } else if (w instanceof Frame) { return new JDialog((Frame) w); } else if (w instanceof Dialog) { return new JDialog((Dialog) w); } else {// w w w. j a va2s . c o m throw new RuntimeException("Unsupported window type:" + w.getClass().getName()); } }
From source file:io.github.jeremgamer.editor.panels.Labels.java
public Labels(final JFrame frame, final LabelPanel lp, final PanelSave ps) { this.frame = frame; this.setBorder(BorderFactory.createTitledBorder("")); JButton add = null;/*from www. j a va 2 s . c o m*/ try { add = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png")))); } catch (IOException e) { e.printStackTrace(); } add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") String name = jop.showInputDialog((JFrame) SwingUtilities.windowForComponent(labelList), "Nommez le label :", "Crer un label", JOptionPane.QUESTION_MESSAGE); if (name != null) { for (int i = 0; i < data.getSize(); i++) { if (data.get(i).equals(name)) { name += "1"; } } data.addElement(name); new LabelSave(name); ActionPanel.updateLists(); OtherPanel.updateLists(); PanelsPanel.updateLists(); } } catch (IOException e) { e.printStackTrace(); } } }); JButton remove = null; try { remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e) { e.printStackTrace(); } remove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { if (labelList.getSelectedValue() != null) { File file = new File("projects/" + Editor.getProjectName() + "/labels/" + labelList.getSelectedValue() + ".rbd"); JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") int option = jop.showConfirmDialog((JFrame) SwingUtilities.windowForComponent(labelList), "tes-vous sr de vouloir supprimer ce label?", "Avertissement", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (option == JOptionPane.OK_OPTION) { File dir = new File("projects/" + Editor.getProjectName() + "/panels"); for (File f : FileUtils.listFilesAndDirs(dir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) { if (!f.isDirectory()) { try { ps.load(f); } catch (IOException e) { e.printStackTrace(); } for (String section : ps .getSectionsContaining(labelList.getSelectedValue() + " (Label)")) { ps.removeSection(section); try { ps.save(f); } catch (IOException e) { e.printStackTrace(); } } } } if (labelList.getSelectedValue().equals(lp.getFileName())) { lp.setFileName(""); } lp.hide(); file.delete(); data.remove(labelList.getSelectedIndex()); ActionPanel.updateLists(); OtherPanel.updateLists(); PanelsPanel.updateLists(); } } } catch (NullPointerException npe) { npe.printStackTrace(); } } }); JPanel buttons = new JPanel(); buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS)); buttons.add(add); buttons.add(remove); updateList(); labelList.addMouseListener(new MouseAdapter() { @SuppressWarnings("unchecked") public void mouseClicked(MouseEvent evt) { JList<String> list = (JList<String>) evt.getSource(); if (evt.getClickCount() == 2) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { lp.show(); lp.load(new File("projects/" + Editor.getProjectName() + "/labels/" + list.getModel().getElementAt(index) + ".rbd")); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { lp.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { lp.hideThenShow(); previousSelection = list.getSelectedValue(); lp.load(new File("projects/" + Editor.getProjectName() + "/labels/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { lp.hide(); list.clearSelection(); } } } else if (evt.getClickCount() == 3) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { lp.show(); lp.load(new File("projects/" + Editor.getProjectName() + "/labels/" + list.getModel().getElementAt(index) + ".rbd")); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { lp.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { lp.hideThenShow(); previousSelection = list.getSelectedValue(); lp.load(new File("projects/" + Editor.getProjectName() + "/labels/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { lp.hide(); list.clearSelection(); } } } } }); JScrollPane listPane = new JScrollPane(labelList); listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.add(buttons); this.add(listPane); }
From source file:io.github.jeremgamer.editor.panels.Panels.java
public Panels(final JFrame frame, final PanelsPanel pp) { this.setBorder(BorderFactory.createTitledBorder("")); JButton add = null;//from w w w. j a va2 s.com try { add = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png")))); } catch (IOException e) { e.printStackTrace(); } add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") String name = jop.showInputDialog((JFrame) SwingUtilities.windowForComponent(panelList), "Nommez le panneau :", "Crer un panneau", JOptionPane.QUESTION_MESSAGE); if (name != null) { for (int i = 0; i < data.getSize(); i++) { if (data.get(i).equals(name)) { name += "1"; } } data.addElement(name); new PanelSave(name); PanelsPanel.updateLists(); mainPanel.addItem(name); } } catch (IOException e) { e.printStackTrace(); } } }); JButton remove = null; try { remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e) { e.printStackTrace(); } remove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { if (panelList.getSelectedValue() != null) { File file = new File("projects/" + Editor.getProjectName() + "/panels/" + panelList.getSelectedValue() + "/" + panelList.getSelectedValue() + ".rbd"); JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") int option = jop.showConfirmDialog((JFrame) SwingUtilities.windowForComponent(panelList), "tes-vous sr de vouloir supprimer ce panneau?", "Avertissement", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (option == JOptionPane.OK_OPTION) { if (panelList.getSelectedValue().equals(pp.getFileName())) { pp.setFileName(""); } pp.hide(); file.delete(); File parent = new File(file.getParent()); for (File img : FileUtils.listFiles(parent, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) { img.delete(); } parent.delete(); mainPanel.removeItem(panelList.getSelectedValue()); data.remove(panelList.getSelectedIndex()); ActionPanel.updateLists(); PanelsPanel.updateLists(); } } } catch (NullPointerException npe) { npe.printStackTrace(); } } }); JPanel buttons = new JPanel(); buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS)); buttons.add(add); buttons.add(remove); mainPanel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) event.getSource(); GeneralSave gs = new GeneralSave(); try { gs.load(new File("projects/" + Editor.getProjectName() + "/general.rbd")); gs.set("mainPanel", combo.getSelectedItem()); } catch (IOException e) { e.printStackTrace(); } } }); updateList(); panelList.addMouseListener(new MouseAdapter() { @SuppressWarnings("unchecked") public void mouseClicked(MouseEvent evt) { JList<String> list = (JList<String>) evt.getSource(); if (evt.getClickCount() == 2) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { pp.load(new File("projects/" + Editor.getProjectName() + "/panels/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); PanelsPanel.updateLists(); pp.show(); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { pp.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { pp.hideThenShow(); previousSelection = list.getSelectedValue(); pp.load(new File("projects/" + Editor.getProjectName() + "/panels/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); PanelsPanel.updateLists(); } } catch (NullPointerException npe) { pp.hide(); list.clearSelection(); } } } else if (evt.getClickCount() == 3) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { pp.load(new File("projects/" + Editor.getProjectName() + "/panels/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); PanelsPanel.updateLists(); pp.show(); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { pp.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { pp.hideThenShow(); previousSelection = list.getSelectedValue(); pp.load(new File("projects/" + Editor.getProjectName() + "/panels/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); PanelsPanel.updateLists(); } } catch (NullPointerException npe) { pp.hide(); list.clearSelection(); } } } } }); JScrollPane listPane = new JScrollPane(panelList); listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.add(buttons); this.add(listPane); JPanel mainPanelInput = new JPanel(); mainPanelInput.setPreferredSize(new Dimension(280, 35)); mainPanelInput.setMaximumSize(new Dimension(280, 35)); mainPanelInput.add(new JLabel("Panneau principal:")); mainPanel.setPreferredSize(new Dimension(150, 27)); mainPanelInput.add(mainPanel); this.add(mainPanelInput); }
From source file:io.github.jeremgamer.editor.panels.Others.java
public Others(final JFrame frame, final OtherPanel op, final PanelSave ps) { this.frame = frame; this.setBorder(BorderFactory.createTitledBorder("")); JButton add = null;/*from w w w . j a v a2s .co m*/ try { add = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png")))); } catch (IOException e) { e.printStackTrace(); } add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") String name = jop.showInputDialog((JFrame) SwingUtilities.windowForComponent(otherList), "Nommez le composant :", "Crer un composant", JOptionPane.QUESTION_MESSAGE); if (name != null) { for (int i = 0; i < data.getSize(); i++) { if (data.get(i).equals(name)) { name += "1"; } } data.addElement(name); new OtherSave(name); ActionPanel.updateLists(); PanelsPanel.updateLists(); } } catch (IOException e) { e.printStackTrace(); } } }); JButton remove = null; try { remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e) { e.printStackTrace(); } remove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { if (otherList.getSelectedValue() != null) { File file = new File("projects/" + Editor.getProjectName() + "/others/" + otherList.getSelectedValue() + ".rbd"); JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") int option = jop.showConfirmDialog((JFrame) SwingUtilities.windowForComponent(otherList), "tes-vous sr de vouloir supprimer ce composant?", "Avertissement", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (option == JOptionPane.OK_OPTION) { File dir = new File("projects/" + Editor.getProjectName() + "/panels"); for (File f : FileUtils.listFilesAndDirs(dir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) { if (!f.isDirectory()) { try { ps.load(f); } catch (IOException e) { e.printStackTrace(); } OtherSave os = new OtherSave(); try { os.load(file); } catch (IOException e1) { e1.printStackTrace(); } String type = null; switch (os.getInt("type")) { case 0: type = "Zone de saisie"; break; case 1: type = "Zone de saisie de mot de passe"; break; case 2: type = "Zone de saisie (Grande)"; break; case 3: type = "Case cocher"; break; case 4: type = "Menu droulant"; break; case 5: type = "Barre de progression"; break; case 6: type = "Slider"; break; case 7: type = "Spinner"; break; } for (String section : ps.getSectionsContaining( otherList.getSelectedValue() + " (" + type + ")")) { ps.removeSection(section); try { ps.save(f); } catch (IOException e) { e.printStackTrace(); } } } } if (otherList.getSelectedValue().equals(op.getFileName())) { op.setFileName(""); } op.hide(); file.delete(); data.remove(otherList.getSelectedIndex()); ActionPanel.updateLists(); OtherPanel.updateLists(); PanelsPanel.updateLists(); } } } catch (NullPointerException npe) { npe.printStackTrace(); } } }); JPanel buttons = new JPanel(); buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS)); buttons.add(add); buttons.add(remove); updateList(); otherList.addMouseListener(new MouseAdapter() { @SuppressWarnings("unchecked") public void mouseClicked(MouseEvent evt) { JList<String> list = (JList<String>) evt.getSource(); if (evt.getClickCount() == 2) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { op.show(); op.load(new File("projects/" + Editor.getProjectName() + "/others/" + list.getModel().getElementAt(index) + ".rbd")); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { op.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { op.hideThenShow(); previousSelection = list.getSelectedValue(); op.load(new File("projects/" + Editor.getProjectName() + "/others/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { op.hide(); list.clearSelection(); } } } else if (evt.getClickCount() == 3) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { op.show(); op.load(new File("projects/" + Editor.getProjectName() + "/others/" + list.getModel().getElementAt(index) + ".rbd")); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { op.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { op.hideThenShow(); previousSelection = list.getSelectedValue(); op.load(new File("projects/" + Editor.getProjectName() + "/others/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { op.hide(); list.clearSelection(); } } } } }); JScrollPane listPane = new JScrollPane(otherList); listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.add(buttons); this.add(listPane); OtherPanel.updateLists(); }
From source file:com.vgi.mafscaling.LogPlay.java
private void initialize() { lastRow = logDataTable.getRowCount() - 1; playNext = new AtomicInteger(1); playIcon = new ImageIcon(getClass().getResource("/play.png")); pauseIcon = new ImageIcon(getClass().getResource("/pause.png")); zeroInsets.put("Button.contentMargins", insets0); timer = new Timer(timerDelay, new ActionListener() { public void actionPerformed(ActionEvent e) { progressBar.setValue(progressBar.getValue() + playNext.get()); }//from w ww .ja v a 2 s .c o m }); JPanel dataPanel = new JPanel(); GridBagLayout gbl_dataPanel = new GridBagLayout(); gbl_dataPanel.columnWidths = new int[] { 0 }; gbl_dataPanel.rowHeights = new int[] { 0, 1 }; gbl_dataPanel.columnWeights = new double[] { 1.0 }; gbl_dataPanel.rowWeights = new double[] { 0.0, 1.0 }; dataPanel.setLayout(gbl_dataPanel); getContentPane().add(dataPanel); createSelectionPanel(dataPanel); createPlayer(dataPanel); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { timer.stop(); synchronized (lock) { for (TableHolder t : tables) t.table.dispose(); tables.clear(); } logView.disposeLogView(); } }); pack(); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setIconImage((new ImageIcon(getClass().getResource("/player.png"))).getImage()); setResizable(false); setLocationRelativeTo(SwingUtilities.windowForComponent(logView)); setVisible(true); }
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 .ja v a 2 s.com 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); }
From source file:io.github.jeremgamer.editor.panels.GeneralSettings.java
public GeneralSettings() { this.setBorder(BorderFactory.createTitledBorder("")); JPanel namePanel = new JPanel(); JLabel nameLabel = new JLabel("Nom :"); namePanel.add(nameLabel);/*w w w. ja va2 s . c o m*/ name.setPreferredSize(new Dimension(220, 30)); namePanel.add(name); CaretListener caretUpdateName = new CaretListener() { public void caretUpdate(javax.swing.event.CaretEvent e) { JTextField text = (JTextField) e.getSource(); gs.set("name", text.getText()); } }; name.addCaretListener(caretUpdateName); this.add(namePanel); adress.setEditable(false); CaretListener caretUpdateAdress = new CaretListener() { public void caretUpdate(javax.swing.event.CaretEvent e) { JTextField text = (JTextField) e.getSource(); gs.set("adress", text.getText()); } }; adress.addCaretListener(caretUpdateAdress); JPanel subTypePanel = new JPanel(); JLabel typeLabel = new JLabel("Type :"); subTypePanel.add(typeLabel); type.setPreferredSize(new Dimension(220, 30)); type.addItem("Minecraft classique"); type.addItem("Minecraft personnalis"); if (new File("projects/" + Editor.getProjectName() + "/data.zip").exists()) { type.setSelectedIndex(1); browse.setEnabled(true); browse.setText("Supprimer l'import"); } else { browse.setEnabled(false); } type.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) event.getSource(); if (combo.getSelectedIndex() == 1) { browse.setEnabled(true); adress.setEnabled(true); adress.setEditable(true); } else { browse.setEnabled(false); adress.setEnabled(false); adress.setEditable(false); } gs.set("type", combo.getSelectedIndex()); } }); subTypePanel.add(type); JPanel typePanel = new JPanel(); typePanel.setLayout(new BoxLayout(typePanel, BoxLayout.PAGE_AXIS)); typePanel.add(subTypePanel); JPanel browsePanel = new JPanel(); browsePanel.add(browse); JPanel adressPanel = new JPanel(); adressPanel.setLayout(new BoxLayout(adressPanel, BoxLayout.PAGE_AXIS)); JLabel adressLabel = new JLabel("Adresse de tlchargement :"); adressPanel.setPreferredSize(new Dimension(0, 47)); adress.setPreferredSize(new Dimension(0, 30)); adressPanel.add(adressLabel); adressPanel.add(adress); typePanel.add(adressPanel); this.add(typePanel); closeOnStart.setSelected(true); closeOnStart.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (closeOnStart.isSelected()) { gs.set("close", true); } else { gs.set("close", false); } } }); this.add(closeOnStart); JPanel look = new JPanel(); look.setBorder(BorderFactory.createTitledBorder("Apparence")); look.setPreferredSize(new Dimension(290, 340)); JPanel colors = new JPanel(); cDark.setSelected(true); bg.add(cLight); bg.add(cDark); colors.add(cLight); colors.add(cDark); cLight.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { gs.set("color", 0); } }); cDark.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { gs.set("color", 1); } }); look.add(colors); JPanel checks = new JPanel(); checks.setLayout(new BoxLayout(checks, BoxLayout.PAGE_AXIS)); borders.setSelected(true); borders.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (borders.isSelected()) { gs.set("borders", true); } else { gs.set("borders", false); } } }); resize.setSelected(true); resize.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (resize.isSelected()) { gs.set("resizable", true); } else { gs.set("resizable", false); } } }); alwaysOnTop.setSelected(false); alwaysOnTop.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (alwaysOnTop.isSelected()) { gs.set("top", true); } else { gs.set("top", false); } } }); checks.add(borders); checks.add(resize); checks.add(alwaysOnTop); checks.setPreferredSize(new Dimension(270, 60)); JPanel size = new JPanel(); width.setPreferredSize(new Dimension(57, 30)); widthMin.setPreferredSize(new Dimension(57, 30)); widthMax.setPreferredSize(new Dimension(57, 30)); height.setPreferredSize(new Dimension(57, 30)); heightMin.setPreferredSize(new Dimension(57, 30)); heightMax.setPreferredSize(new Dimension(57, 30)); JPanel widthPanel = new JPanel(); widthPanel.setPreferredSize(new Dimension(130, 150)); widthPanel.setBorder(BorderFactory.createTitledBorder("Largeur")); widthPanel.setLayout(new BoxLayout(widthPanel, BoxLayout.PAGE_AXIS)); JPanel widthPanelBase = new JPanel(); widthPanelBase.add(new JLabel("Base :")); widthPanelBase.add(width); JPanel widthPanelMin = new JPanel(); widthPanelMin.add(new JLabel("Min :")); widthPanelMin.add(Box.createRigidArea(new Dimension(5, 1))); widthPanelMin.add(widthMin); JPanel widthPanelMax = new JPanel(); widthPanelMax.add(new JLabel("Max :")); widthPanelMax.add(Box.createRigidArea(new Dimension(3, 1))); widthPanelMax.add(widthMax); widthPanel.add(widthPanelBase); widthPanel.add(widthPanelMin); widthPanel.add(widthPanelMax); JPanel heightPanel = new JPanel(); heightPanel.setPreferredSize(new Dimension(130, 150)); heightPanel.setBorder(BorderFactory.createTitledBorder("Hauteur")); heightPanel.setLayout(new BoxLayout(heightPanel, BoxLayout.PAGE_AXIS)); JPanel heightPanelBase = new JPanel(); heightPanelBase.add(new JLabel("Base :")); heightPanelBase.add(height); JPanel heightPanelMin = new JPanel(); heightPanelMin.add(new JLabel("Min :")); heightPanelMin.add(Box.createRigidArea(new Dimension(5, 1))); heightPanelMin.add(heightMin); JPanel heightPanelMax = new JPanel(); heightPanelMax.add(new JLabel("Max :")); heightPanelMax.add(Box.createRigidArea(new Dimension(3, 1))); heightPanelMax.add(heightMax); heightPanel.add(heightPanelBase); heightPanel.add(heightPanelMin); heightPanel.add(heightPanelMax); size.add(widthPanel); size.add(heightPanel); width.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); gs.set("width", spinner.getValue()); } }); widthMin.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); gs.set("widthMin", spinner.getValue()); } }); widthMax.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); ; gs.set("widthMax", spinner.getValue()); } }); height.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); gs.set("height", spinner.getValue()); } }); heightMin.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); gs.set("heightMin", spinner.getValue()); } }); heightMax.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); ; gs.set("heightMax", spinner.getValue()); } }); look.add(checks); look.add(size); JPanel bottom = new JPanel(); bottom.setLayout(new BoxLayout(bottom, BoxLayout.LINE_AXIS)); JButton music = new JButton("Ajouter de la musique"); music.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { new MusicFrame((JFrame) SwingUtilities.windowForComponent(adress), gs); } }); bottom.add(music); JButton icons = new JButton("Icnes"); icons.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { new IconFrame((JFrame) SwingUtilities.windowForComponent(adress)); } }); bottom.add(icons); look.add(bottom); this.add(look); load(); }