List of usage examples for javax.swing BoxLayout PAGE_AXIS
int PAGE_AXIS
To view the source code for javax.swing BoxLayout PAGE_AXIS.
Click Source Link
From source file:DialogDemo.java
/** * Used by createSimpleDialogBox and createFeatureDialogBox to create a pane * containing a description, a single column of radio buttons, and the Show * it! button.//from ww w . j ava2s. co m */ private JPanel createPane(String description, JRadioButton[] radioButtons, JButton showButton) { int numChoices = radioButtons.length; JPanel box = new JPanel(); JLabel label = new JLabel(description); box.setLayout(new BoxLayout(box, BoxLayout.PAGE_AXIS)); box.add(label); for (int i = 0; i < numChoices; i++) { box.add(radioButtons[i]); } JPanel pane = new JPanel(new BorderLayout()); pane.add(box, BorderLayout.PAGE_START); pane.add(showButton, BorderLayout.PAGE_END); return pane; }
From source file:com.tascape.qa.th.android.driver.App.java
/** * The method starts a GUI to let an user inspect element tree and take screenshot when the user is interacting * with the app-under-test manually. Please make sure to set timeout long enough for manual interaction. * * @param timeoutMinutes timeout in minutes to fail the manual steps * * @throws Exception if case of error//ww w .ja v a2s . c om */ public void interactManually(int timeoutMinutes) throws Exception { LOG.info("Start manual UI interaction"); long end = System.currentTimeMillis() + timeoutMinutes * 60000L; AtomicBoolean visible = new AtomicBoolean(true); AtomicBoolean pass = new AtomicBoolean(false); String tName = Thread.currentThread().getName() + "m"; SwingUtilities.invokeLater(() -> { JDialog jd = new JDialog((JFrame) null, "Manual Device UI Interaction - " + device.getProductDetail()); jd.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); JPanel jpContent = new JPanel(new BorderLayout()); jd.setContentPane(jpContent); jpContent.setPreferredSize(new Dimension(1088, 828)); jpContent.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JPanel jpInfo = new JPanel(); jpContent.add(jpInfo, BorderLayout.PAGE_START); jpInfo.setLayout(new BorderLayout()); { JButton jb = new JButton("PASS"); jb.setForeground(Color.green.darker()); jb.setFont(jb.getFont().deriveFont(Font.BOLD)); jpInfo.add(jb, BorderLayout.LINE_START); jb.addActionListener(event -> { pass.set(true); jd.dispose(); visible.set(false); }); } { JButton jb = new JButton("FAIL"); jb.setForeground(Color.red); jb.setFont(jb.getFont().deriveFont(Font.BOLD)); jpInfo.add(jb, BorderLayout.LINE_END); jb.addActionListener(event -> { pass.set(false); jd.dispose(); visible.set(false); }); } JLabel jlTimeout = new JLabel("xxx seconds left", SwingConstants.CENTER); jpInfo.add(jlTimeout, BorderLayout.CENTER); jpInfo.add(jlTimeout, BorderLayout.CENTER); new SwingWorker<Long, Long>() { @Override protected Long doInBackground() throws Exception { while (System.currentTimeMillis() < end) { Thread.sleep(1000); long left = (end - System.currentTimeMillis()) / 1000; this.publish(left); } return 0L; } @Override protected void process(List<Long> chunks) { Long l = chunks.get(chunks.size() - 1); jlTimeout.setText(l + " seconds left"); if (l < 850) { jlTimeout.setForeground(Color.red); } } }.execute(); JPanel jpResponse = new JPanel(new BorderLayout()); JPanel jpProgress = new JPanel(new BorderLayout()); jpResponse.add(jpProgress, BorderLayout.PAGE_START); JTextArea jtaJson = new JTextArea(); jtaJson.setEditable(false); jtaJson.setTabSize(4); Font font = jtaJson.getFont(); jtaJson.setFont(new Font("Courier New", font.getStyle(), font.getSize())); JTree jtView = new JTree(); JTabbedPane jtp = new JTabbedPane(); jtp.add("tree", new JScrollPane(jtView)); jtp.add("json", new JScrollPane(jtaJson)); jpResponse.add(jtp, BorderLayout.CENTER); JPanel jpScreen = new JPanel(); jpScreen.setMinimumSize(new Dimension(200, 200)); jpScreen.setLayout(new BoxLayout(jpScreen, BoxLayout.PAGE_AXIS)); JScrollPane jsp1 = new JScrollPane(jpScreen); jpResponse.add(jsp1, BorderLayout.LINE_START); JPanel jpJs = new JPanel(new BorderLayout()); JTextArea jtaJs = new JTextArea(); jpJs.add(new JScrollPane(jtaJs), BorderLayout.CENTER); JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jpResponse, jpJs); jSplitPane.setResizeWeight(0.88); jpContent.add(jSplitPane, BorderLayout.CENTER); JPanel jpLog = new JPanel(); jpLog.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); jpLog.setLayout(new BoxLayout(jpLog, BoxLayout.LINE_AXIS)); JCheckBox jcbTap = new JCheckBox("Enable Click", null, false); jpLog.add(jcbTap); jpLog.add(Box.createHorizontalStrut(8)); JButton jbLogUi = new JButton("Log Screen"); jpResponse.add(jpLog, BorderLayout.PAGE_END); { jpLog.add(jbLogUi); jbLogUi.addActionListener((ActionEvent event) -> { jtaJson.setText("waiting for screenshot..."); Thread t = new Thread(tName) { @Override public void run() { LOG.debug("\n\n"); try { WindowHierarchy wh = device.loadWindowHierarchy(); jtView.setModel(getModel(wh)); jtaJson.setText(""); jtaJson.append(wh.root.toJson().toString(2)); jtaJson.append("\n"); File png = device.takeDeviceScreenshot(); BufferedImage image = ImageIO.read(png); int w = device.getDisplayWidth(); int h = device.getDisplayHeight(); BufferedImage resizedImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = resizedImg.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); g2.drawImage(image, 0, 0, w, h, null); g2.dispose(); JLabel jLabel = new JLabel(new ImageIcon(resizedImg)); jpScreen.removeAll(); jsp1.setPreferredSize(new Dimension(w + 30, h)); jpScreen.add(jLabel); jLabel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { LOG.debug("clicked at {},{}", e.getPoint().getX(), e.getPoint().getY()); if (jcbTap.isSelected()) { device.click(e.getPoint().x, e.getPoint().y); device.waitForIdle(); jbLogUi.doClick(); } } }); } catch (Exception ex) { LOG.error("Cannot log screen", ex); jtaJson.append("Cannot log screen"); } jtaJson.append("\n\n\n"); LOG.debug("\n\n"); jd.setSize(jd.getBounds().width + 1, jd.getBounds().height + 1); jd.setSize(jd.getBounds().width - 1, jd.getBounds().height - 1); } }; t.start(); }); } jpLog.add(Box.createHorizontalStrut(38)); { JButton jbLogMsg = new JButton("Log Message"); jpLog.add(jbLogMsg); JTextField jtMsg = new JTextField(10); jpLog.add(jtMsg); jtMsg.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent pE) { } @Override public void focusGained(final FocusEvent pE) { jtMsg.selectAll(); } }); jtMsg.addKeyListener(new KeyAdapter() { @Override public void keyPressed(java.awt.event.KeyEvent e) { if (e.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER) { jbLogMsg.doClick(); } } }); jbLogMsg.addActionListener(event -> { Thread t = new Thread(tName) { @Override public void run() { String msg = jtMsg.getText(); if (StringUtils.isNotBlank(msg)) { LOG.info("{}", msg); jtMsg.selectAll(); } } }; t.start(); try { t.join(); } catch (InterruptedException ex) { LOG.error("Cannot take screenshot", ex); } jtMsg.requestFocus(); }); } jpLog.add(Box.createHorizontalStrut(38)); { JButton jbClear = new JButton("Clear"); jpLog.add(jbClear); jbClear.addActionListener(event -> { jtaJson.setText(""); }); } JPanel jpAction = new JPanel(); jpContent.add(jpAction, BorderLayout.PAGE_END); jpAction.setLayout(new BoxLayout(jpAction, BoxLayout.LINE_AXIS)); jpJs.add(jpAction, BorderLayout.PAGE_END); jd.pack(); jd.setVisible(true); jd.setLocationRelativeTo(null); jbLogUi.doClick(); }); while (visible.get()) { if (System.currentTimeMillis() > end) { LOG.error("Manual UI interaction timeout"); break; } Thread.sleep(500); } if (pass.get()) { LOG.info("Manual UI Interaction returns PASS"); } else { Assert.fail("Manual UI Interaction returns FAIL"); } }
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;// w w w .j av a2 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:eu.apenet.dpt.standalone.gui.APETabbedPane.java
private JComponent makeTextPanel(int tab) { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS)); if (tab == TAB_VALIDATION) { p.add(validationPane);// w ww. j a va 2s .c o m } else if (tab == TAB_CONVERSION) { p.add(conversionPane); } else if (tab == TAB_EDM) { p.add(edmConversionPane); } else if (tab == TAB_EDITION) { p.add(editionPane); } return p; }
From source file:org.isatools.isacreator.wizard.GeneralCreationAlgorithm.java
public JPanel instantiatePanel() { final JPanel generalQuestionCont = new JPanel(); generalQuestionCont.setLayout(new BoxLayout(generalQuestionCont, BoxLayout.PAGE_AXIS)); generalQuestionCont.setBackground(UIHelper.BG_COLOR); JLabel info = new JLabel("<html><b>" + assay.getMeasurementEndpoint() + "</b> using <b>" + assay.getTechnologyType() + "</b></html>", JLabel.LEFT); UIHelper.renderComponent(info, UIHelper.VER_12_PLAIN, UIHelper.GREY_COLOR, false); if (assay.getTechnologyType().equals("")) { info.setText("<html><b>" + assay.getMeasurementEndpoint() + "</html>"); }//from w w w . j av a 2 s. c om info.setPreferredSize(new Dimension(300, 40)); JPanel infoPanel = new JPanel(new GridLayout(1, 1)); infoPanel.setBackground(UIHelper.BG_COLOR); infoPanel.add(info); generalQuestionCont.add(infoPanel); JPanel labelPanel = new JPanel(new GridLayout(1, 2)); labelPanel.setBackground(UIHelper.BG_COLOR); labelCapture = new LabelCapture("Label"); labelCapture.setVisible(false); labelUsed = new JCheckBox("Label used?", false); UIHelper.renderComponent(labelUsed, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, UIHelper.BG_COLOR); labelUsed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { labelCapture.setVisible(labelUsed.isSelected()); } }); labelPanel.add(labelUsed); labelPanel.add(labelCapture); generalQuestionCont.add(labelPanel); final JPanel extractPanel = new JPanel(new GridLayout(2, 2)); extractPanel.setBackground(UIHelper.BG_COLOR); extractDetails.clear(); JLabel extractsUsedLab = UIHelper.createLabel("Sample(s) used *"); extractsUsedLab.setHorizontalAlignment(JLabel.LEFT); extractsUsedLab.setVerticalAlignment(JLabel.TOP); final JPanel extractNameContainer = new JPanel(); extractNameContainer.setLayout(new BoxLayout(extractNameContainer, BoxLayout.PAGE_AXIS)); extractNameContainer.setBackground(UIHelper.BG_COLOR); extract = new ExtractDetailsCapture("Sample " + (extractDetails.size() + 1), ApplicationManager.getUserInterfaceForISASection(study).getDataEntryEnvironment()); extractDetails.add(extract); extractNameContainer.add(extract); JLabel addButton = new JLabel("add sample", addRecordIcon, JLabel.RIGHT); UIHelper.renderComponent(addButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false); addButton.setVerticalAlignment(JLabel.TOP); addButton.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { extract = new ExtractDetailsCapture("Sample " + (extractDetails.size() + 1), ApplicationManager.getUserInterfaceForISASection(study).getDataEntryEnvironment()); extractDetails.add(extract); extractNameContainer.add(extract); extractNameContainer.revalidate(); generalQuestionCont.revalidate(); } }); addButton.setToolTipText( "<html><b>add new sample</b><p>add another sample (e.g. Liver, Heart, Urine, Blood)</p></html>"); JLabel removeButton = new JLabel("remove sample", removeIcon, JLabel.RIGHT); removeButton.setVerticalAlignment(JLabel.TOP); UIHelper.renderComponent(removeButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false); removeButton.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { if (extractDetails.size() > 1) { extract = extractDetails.get(extractDetails.size() - 1); extractDetails.remove(extract); extractNameContainer.remove(extract); generalQuestionCont.revalidate(); } } }); removeButton.setToolTipText( "<html><b>remove previously added sample</b><p>remove the sample field last added</p></html>"); extractPanel.add(extractsUsedLab); extractPanel.add(extractNameContainer); JPanel buttonContainer = new JPanel(new GridLayout(1, 2)); buttonContainer.setBackground(UIHelper.BG_COLOR); buttonContainer.add(addButton); buttonContainer.add(removeButton); extractPanel.add(new JLabel()); extractPanel.add(buttonContainer); generalQuestionCont.add(extractPanel); generalQuestionCont.add(Box.createVerticalStrut(5)); generalQuestionCont.add(Box.createHorizontalGlue()); generalQuestionCont.setBorder(new TitledBorder(new RoundedBorder(UIHelper.DARK_GREEN_COLOR, 9), assay.getAssayReference(), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR)); return generalQuestionCont; }
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 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(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:BasicDnD.java
protected JPanel createVerticalBoxPanel() { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS)); p.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); return p;//from w w w . j a v a2 s . c o m }
From source file:DialogDemo.java
/** * Like createPane, but creates a pane with 2 columns of radio buttons. The * number of buttons passed in *must* be even. *//* ww w .j a v a2 s . c o m*/ private JPanel create2ColPane(String description, JRadioButton[] radioButtons, JButton showButton) { JLabel label = new JLabel(description); int numPerColumn = radioButtons.length / 2; JPanel grid = new JPanel(new GridLayout(0, 2)); for (int i = 0; i < numPerColumn; i++) { grid.add(radioButtons[i]); grid.add(radioButtons[i + numPerColumn]); } JPanel box = new JPanel(); box.setLayout(new BoxLayout(box, BoxLayout.PAGE_AXIS)); box.add(label); grid.setAlignmentX(0.0f); box.add(grid); JPanel pane = new JPanel(new BorderLayout()); pane.add(box, BorderLayout.PAGE_START); pane.add(showButton, BorderLayout.PAGE_END); return pane; }
From source file:eu.apenet.dpt.standalone.gui.APETabbedPane.java
private JComponent makeTextPanelSummary() { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS)); JPanel summaryItems = new JPanel(); summaryItems.setLayout(new BoxLayout(summaryItems, BoxLayout.PAGE_AXIS)); summaryItems.add(makeButtons());/* ww w. j ava 2 s . c om*/ summaryItems.add(makeCheckboxes()); summaryItems.add(makeCheckboxesXsd()); summaryItems.add(makeResultsPanel()); JScrollPane summaryPane = new JScrollPane(summaryItems); p.add(summaryPane); return p; }
From source file:io.github.jeremgamer.editor.panels.Buttons.java
public Buttons(final JFrame frame, final ButtonPanel be, final PanelSave ps) { this.setBorder(BorderFactory.createTitledBorder("")); this.frame = frame; JButton add = null;//from w w w.j a va2 s.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(null, "Nommez le bouton :", "Crer un bouton", 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 ButtonSave(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 (buttonList.getSelectedValue() != null) { File file = new File("projects/" + Editor.getProjectName() + "/buttons/" + buttonList.getSelectedValue() + "/" + buttonList.getSelectedValue() + ".rbd"); JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") int option = jop.showConfirmDialog(null, "tes-vous sr de vouloir supprimer ce bouton?", "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(buttonList.getSelectedValue() + " (Bouton)")) { ps.removeSection(section); try { ps.save(f); } catch (IOException e) { e.printStackTrace(); } } } } if (buttonList.getSelectedValue().equals(be.getFileName())) { be.setFileName(""); } be.hide(); file.delete(); File parent = new File(file.getParent()); for (File img : FileUtils.listFiles(parent, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) { img.delete(); } parent.delete(); data.remove(buttonList.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(); buttonList.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) { be.load(new File("projects/" + Editor.getProjectName() + "/buttons/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); be.show(); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { be.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { be.hideThenShow(); previousSelection = list.getSelectedValue(); be.load(new File("projects/" + Editor.getProjectName() + "/buttons/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { be.hide(); list.clearSelection(); } } } else if (evt.getClickCount() == 3) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { be.load(new File("projects/" + Editor.getProjectName() + "/buttons/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); be.show(); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { be.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { be.hideThenShow(); previousSelection = list.getSelectedValue(); be.load(new File("projects/" + Editor.getProjectName() + "/buttons/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { be.hide(); list.clearSelection(); } } } } }); JScrollPane listPane = new JScrollPane(buttonList); listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.add(buttons); this.add(listPane); }