List of usage examples for javax.swing JPanel setMaximumSize
@BeanProperty(description = "The maximum size of the component.") public void setMaximumSize(Dimension maximumSize)
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS)); JPanel a = new JPanel(); a.setAlignmentX(Component.CENTER_ALIGNMENT); a.setPreferredSize(new Dimension(100, 100)); a.setMaximumSize(new Dimension(100, 100)); // set max = pref a.setBorder(BorderFactory.createTitledBorder("aa")); JPanel b = new JPanel(); b.setAlignmentX(Component.CENTER_ALIGNMENT); b.setPreferredSize(new Dimension(50, 50)); b.setMaximumSize(new Dimension(50, 50)); // set max = pref b.setBorder(BorderFactory.createTitledBorder("bb")); frame.getContentPane().add(a);/*from w w w . ja v a 2s .c o m*/ frame.getContentPane().add(b); frame.pack(); frame.setVisible(true); }
From source file:net.chunkyhosting.Roe.computer.CHGManager.gui.dialogs.DownloadNotice.java
public DownloadNotice(HashMap<JSONObject, URL> downloads) { this.setDownloads(downloads); JPanel basic = new JPanel(); basic.setLayout(new BoxLayout(basic, BoxLayout.Y_AXIS)); add(basic);/*from w w w.j av a 2 s . c om*/ JPanel topPanel = new JPanel(new BorderLayout(0, 0)); topPanel.setMaximumSize(new Dimension(450, 0)); JLabel hint = new JLabel("CHGManager Download Manager"); hint.setBorder(BorderFactory.createEmptyBorder(0, 25, 0, 0)); topPanel.add(hint); JSeparator separator = new JSeparator(); separator.setForeground(Color.gray); topPanel.add(separator, BorderLayout.SOUTH); basic.add(topPanel); JPanel textPanel = new JPanel(new BorderLayout()); textPanel.setBorder(BorderFactory.createEmptyBorder(15, 25, 15, 25)); this.setTextPanel(new JTextPane()); this.getTextPanel().setContentType("text/html"); String text = "<p><b>Some files are missing from your CHGManager install. Don't worry. We're trying to download them. Please don't close this panel!</b></p>"; this.getText().add(text); this.getTextPanel().setText(text); this.getTextPanel().setEditable(false); JScrollPane sp = new JScrollPane(); sp.setSize(this.getTextPanel().getSize()); basic.add(sp); //basic.add(textPanel); JPanel boxPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 20, 0)); basic.add(boxPanel); JPanel bottom = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton close = new JButton("Close"); bottom.add(close); basic.add(bottom); bottom.setMaximumSize(new Dimension(450, 0)); this.setTitle("CHGManager Download Manager"); this.setResizable(false); this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); this.setLocationRelativeTo(null); this.setVisible(true); try { Thread.sleep(2000); } catch (InterruptedException e) { } this.startDownload(); }
From source file:gui.images.CodebookVectorProfilePanel.java
/** * Sets the data to be shown.//from w w w .j a v a 2 s .c om * * @param occurrenceProfile Double array that is the neighbor occurrence * profile of this visual word. * @param codebookIndex Integer that is the index of this visual word. * @param classColors Color[] of class colors. * @param classNames String[] of class names. */ public void setResults(double[] occurrenceProfile, int codebookIndex, Color[] classColors, String[] classNames) { int numClasses = Math.min(classNames.length, occurrenceProfile.length); this.codebookIndex = codebookIndex; this.occurrenceProfile = occurrenceProfile; DefaultPieDataset pieData = new DefaultPieDataset(); for (int cIndex = 0; cIndex < numClasses; cIndex++) { pieData.setValue(classNames[cIndex], occurrenceProfile[cIndex]); } JFreeChart chart = ChartFactory.createPieChart3D("codebook vect " + codebookIndex, pieData, true, true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); PieRenderer prend = new PieRenderer(classColors); prend.setColor(plot, pieData); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(140, 140)); chartPanel.setVisible(true); chartPanel.revalidate(); chartPanel.repaint(); JPanel jp = new JPanel(); jp.setPreferredSize(new Dimension(140, 140)); jp.setMinimumSize(new Dimension(140, 140)); jp.setMaximumSize(new Dimension(140, 140)); jp.setSize(new Dimension(140, 140)); jp.setLayout(new FlowLayout()); jp.add(chartPanel); jp.setVisible(true); jp.validate(); jp.repaint(); JFrame frame = new JFrame(); frame.setBackground(Color.WHITE); frame.setUndecorated(true); frame.getContentPane().add(jp); frame.pack(); BufferedImage bi = new BufferedImage(jp.getWidth(), jp.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = bi.createGraphics(); jp.print(graphics); graphics.dispose(); frame.dispose(); imPanel.removeAll(); imPanel.setImage(bi); imPanel.setVisible(true); imPanel.revalidate(); imPanel.repaint(); }
From source file:be.ac.ua.comp.scarletnebula.gui.TaggingPanel.java
public TaggingPanel(final Collection<String> initialTags) { super(new BorderLayout()); for (final String tag : initialTags) { taglist.addTag(new TagItem(tag)); }// w w w . ja va 2 s . c om final BetterTextField inputField = new BetterTextField(); addTagActionListener = new AddTagActionListener(inputField); inputField.addActionListener(addTagActionListener); final String hint = "Type a tag and press enter"; inputField.setPlaceHolder(hint); inputField.setToolTipText(hint); inputField.setInputVerifier(new TagInputVerifier(inputField)); inputField.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0), BorderFactory.createBevelBorder(BevelBorder.LOWERED))); taglist.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); final JScrollPane tagScrollPane = new JScrollPane(taglist); tagScrollPane.setBorder(null); final JPanel centerPanel = new JPanel(new BorderLayout()); centerPanel.add(inputField, BorderLayout.NORTH); centerPanel.add(tagScrollPane, BorderLayout.CENTER); centerPanel.setMaximumSize(new Dimension(250, 500)); centerPanel.setPreferredSize(new Dimension(200, 200)); setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); add(Box.createHorizontalGlue()); add(centerPanel); add(Box.createHorizontalGlue()); }
From source file:net.sf.firemox.ui.wizard.About.java
/** * Creates a new instance of About <br> * //from ww w. j a va 2 s .co m * @param parent */ public About(JFrame parent) { super(LanguageManager.getString("wiz_about.title"), LanguageManager.getString("wiz_about.description"), "mp64.gif", LanguageManager.getString("close"), 420, 620); JPanel thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setMaximumSize(new Dimension(32767, 26)); thanksPanel.setOpaque(false); JLabel jLabel5 = new JLabel(LanguageManager.getString("version") + " : "); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.RIGHT); jLabel5.setMaximumSize(new Dimension(100, 16)); jLabel5.setMinimumSize(new Dimension(100, 16)); jLabel5.setPreferredSize(new Dimension(100, 16)); thanksPanel.add(jLabel5); jLabel5 = new JLabel(IdConst.VERSION); thanksPanel.add(jLabel5); gameParamPanel.add(thanksPanel); thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setOpaque(false); JPanel thanksPanelLeft = new JPanel(new FlowLayout(FlowLayout.LEADING)); thanksPanelLeft.setLayout(new BoxLayout(thanksPanelLeft, BoxLayout.Y_AXIS)); thanksPanelLeft.setMaximumSize(new Dimension(100, 2000)); thanksPanelLeft.setMinimumSize(new Dimension(100, 16)); jLabel5 = new JLabel(LanguageManager.getString("thanks") + " : "); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.RIGHT); jLabel5.setMaximumSize(new Dimension(100, 16)); jLabel5.setMinimumSize(new Dimension(100, 16)); jLabel5.setPreferredSize(new Dimension(100, 16)); thanksPanelLeft.add(jLabel5); thanksPanel.add(thanksPanelLeft); thanksPanelLeft = new JPanel(); thanksPanelLeft.setLayout(new BoxLayout(thanksPanelLeft, BoxLayout.Y_AXIS)); StringBuilder contributors = new StringBuilder(); addContributor(contributors, "Fabrice Daugan", "developper", "france"); addContributor(contributors, "Hoani Cross", "developper", "frenchpolynesia"); addContributor(contributors, "nico100", "graphist", "france"); addContributor(contributors, "seingalt_tm", "graphist", "france"); addContributor(contributors, "surtur2", "tester", null); addContributor(contributors, "Jan Blaha", "developper", "cz"); addContributor(contributors, "Tureba", "developper", "brazil"); addContributor(contributors, "hakvf", "tester", "france"); addContributor(contributors, "Stefano \"Kismet\" Lenzi", "developper", "italian"); jLabel5 = new JLabel(contributors.toString()); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.LEFT); thanksPanelLeft.add(jLabel5); jLabel5 = new JLink("http://obsidiurne.free.fr", "morgil has designed the splash screen"); jLabel5.setFont(MToolKit.defaultFont); thanksPanelLeft.add(jLabel5); thanksPanel.add(thanksPanelLeft); gameParamPanel.add(thanksPanel); thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setMaximumSize(new Dimension(32767, 26)); thanksPanel.setOpaque(false); JLabel blanklbl = new JLabel(); blanklbl.setHorizontalAlignment(SwingConstants.RIGHT); blanklbl.setMaximumSize(new Dimension(100, 16)); blanklbl.setMinimumSize(new Dimension(100, 16)); blanklbl.setPreferredSize(new Dimension(100, 16)); thanksPanel.add(blanklbl); jLabel5 = new JLink( "http://sourceforge.net/tracker/?func=add&group_id=" + IdConst.PROJECT_ID + "&atid=601043", LanguageManager.getString("joindev")); jLabel5.setFont(MToolKit.defaultFont); thanksPanel.add(jLabel5); gameParamPanel.add(thanksPanel); thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setOpaque(false); jLabel5 = new JLabel(LanguageManager.getString("projecthome") + " : "); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.RIGHT); jLabel5.setMaximumSize(new Dimension(100, 16)); jLabel5.setMinimumSize(new Dimension(100, 16)); jLabel5.setPreferredSize(new Dimension(100, 16)); thanksPanel.add(jLabel5); jLabel5 = new JLink(IdConst.MAIN_PAGE, IdConst.MAIN_PAGE); jLabel5.setFont(MToolKit.defaultFont); thanksPanel.add(jLabel5); gameParamPanel.add(thanksPanel); // forum francais thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setOpaque(false); jLabel5 = new JLabel(LanguageManager.getString("othersites") + " : "); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.RIGHT); jLabel5.setMaximumSize(new Dimension(100, 16)); jLabel5.setMinimumSize(new Dimension(100, 16)); jLabel5.setPreferredSize(new Dimension(100, 16)); thanksPanel.add(jLabel5); jLabel5 = new JLink("http://www.Firemox.fr.st", UIHelper.getIcon("mpfrsml.gif"), SwingConstants.LEFT); jLabel5.setToolTipText(LanguageManager.getString("frenchforum.tooltip")); thanksPanel.add(jLabel5); jLabel5 = new JLabel(); jLabel5.setMaximumSize(new Dimension(1000, 16)); thanksPanel.add(jLabel5); gameParamPanel.add(thanksPanel); JTextArea disclaimer = new JTextArea(); disclaimer.setEditable(false); disclaimer.setLineWrap(true); disclaimer.setWrapStyleWord(true); disclaimer.setAutoscrolls(true); disclaimer.setTabSize(2); disclaimer.setFont(new Font("Arial", 0, 10)); // Then try and read it locally BufferedReader inGPL = null; try { inGPL = new BufferedReader(new InputStreamReader(MToolKit.getResourceAsStream(IdConst.FILE_LICENSE))); disclaimer.read(inGPL, ""); } catch (IOException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(inGPL); } JScrollPane disclaimerSPanel = new JScrollPane(); disclaimerSPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); MToolKit.addOverlay(disclaimerSPanel); disclaimerSPanel.setViewportView(disclaimer); gameParamPanel.add(disclaimerSPanel); }
From source file:com.opendoorlogistics.components.reports.ReporterPanel.java
public ReporterPanel(final ComponentConfigurationEditorAPI api, final ReporterConfig config) { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // setAlignmentX(LEFT_ALIGNMENT); // add config panel ReporterConfigPanel configPanel = new ReporterConfigPanel(config); configPanel.setBorder(createBorder("Export and processing options")); add(configPanel);//from w w w . ja va 2s. com // add gap add(Box.createRigidArea(new Dimension(1, 10))); // add tools panel JPanel toolContainer = new JPanel(); toolContainer.setLayout(new BorderLayout()); toolContainer.setBorder(createBorder("Tools")); add(toolContainer); JPanel tools = new JPanel(); toolContainer.add(tools, BorderLayout.NORTH); toolContainer.setMaximumSize(new Dimension(Integer.MAX_VALUE, api.isInstruction() ? 120 : 80)); // tools.setLayout(new BoxLayout(tools, BoxLayout.X_AXIS)); tools.setLayout(new GridLayout(api == null || api.isInstruction() ? 2 : 1, 3)); JButton compileButton = new JButton("Compile .jrxml file"); compileButton.setToolTipText("Compile a JasperReports .jrxml file"); compileButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { File file = ReporterTools.chooseJRXMLFile(api.getComponentPreferences(), LAST_JRXML_TO_COMPILE, ReporterPanel.this); if (file == null) { return; } final ExecutionReport report = api.getApi().uiFactory().createExecutionReport(); try { JasperDesign design = JRXmlLoader.load(file); if (design == null) { throw new RuntimeException("File to load jrxml: " + file.getAbsolutePath()); } String filename = FilenameUtils.removeExtension(file.getAbsolutePath()) + ".jasper"; JasperCompileManager.compileReportToFile(design, filename); } catch (Throwable e2) { report.setFailed(e2); report.setFailed("Failed to compile file " + file.getAbsolutePath()); } finally { if (report.isFailed()) { Window window = SwingUtilities.getWindowAncestor(ReporterPanel.this); api.getApi().uiFactory() .createExecutionReportDialog( JFrame.class.isInstance(window) ? (JFrame) window : null, "Compiling jrxml file", report, true) .setVisible(true); } else { JOptionPane.showMessageDialog(ReporterPanel.this, "Compiled jxrml successfully: " + file.getAbsolutePath()); } } } }); tools.add(compileButton); for (final OrientationEnum orientation : new OrientationEnum[] { OrientationEnum.LANDSCAPE, OrientationEnum.PORTRAIT }) { // create export button JButton button = new JButton("Export " + orientation.getName().toLowerCase() + " template"); button.setToolTipText( "Export template (editable .jrxml and compiled .jasper) based on the input tables (" + orientation.getName().toLowerCase() + ")"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ReporterTools.exportReportTemplate(api, config, orientation, ReporterPanel.this); } }); tools.add(button); // create view button if (api.isInstruction()) { final String title = "View basic " + orientation.getName().toLowerCase() + " report"; button = new JButton(title); button.setToolTipText("View basic report based on the input tables (" + orientation.getName().toLowerCase() + ")"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (api != null) { api.executeInPlace(title, orientation == OrientationEnum.LANDSCAPE ? ReporterComponent.VIEW_BASIC_LANDSCAPE : ReporterComponent.VIEW_BASIC_PORTRAIT); } } }); tools.add(button); } } }
From source file:mergedoc.ui.PreferencePanel.java
/** * ??????//ww w . ja v a 2 s .c o m * @return ?? * @throws MergeDocException ???????? */ private JComponent createLowerPanel() throws MergeDocException { // ??? JPanel checkPanel = new JPanel(); checkPanel.setLayout(new BoxLayout(checkPanel, BoxLayout.Y_AXIS)); List<ReplaceEntry> list = ConfigManager.getInstance().getGlobalEntries(); for (ReplaceEntry entry : list) { EntryCheckBox cb = new EntryCheckBox(entry); cb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { previewScrollPane.updatePreview(entryCheckList); } }); checkPanel.add(cb); entryCheckList.add(cb); } JScrollPane checkScrollPane = ComponentFactory.createScrollPane(checkPanel); checkScrollPane.getVerticalScrollBar().setUnitIncrement(10); // ? previewScrollPane = new PreviewScrollPane(); // ?? splitPane.setBorder(BorderFactory.createEmptyBorder()); splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); splitPane.setContinuousLayout(true); splitPane.setTopComponent(checkScrollPane); splitPane.setBottomComponent(previewScrollPane); JPanel splitPanel = new JPanel(); splitPanel.setLayout(new BoxLayout(splitPanel, BoxLayout.X_AXIS)); splitPanel.add(splitPane); // ?? JPanel panel = new TitledPanel(""); panel.setMaximumSize(ComponentFactory.createMaxDimension()); panel.add(splitPanel); // ??? Persister psst = Persister.getInstance(); int loc = psst.getInt(Persister.DETAIL_PANEL_HEIGHT, 88); splitPane.setDividerLocation(loc); // ??? String[] pDescs = psst.getStrings(Persister.REPLACE_DESCRIPTION_ARRAY); for (EntryCheckBox ecb : entryCheckList) { ReplaceEntry entry = ecb.getReplaceEntry(); String desc = entry.getDescription(); for (String pDesc : pDescs) { if (desc.equals(pDesc)) { ecb.setSelected(true); break; } } } previewScrollPane.updatePreview(entryCheckList); return panel; }
From source file:com.opendoorlogistics.studio.scripts.list.ScriptsPanel.java
/** * Create the panel.//from w w w.j av a 2 s . c o m */ public ScriptsPanel(ODLApi api, File directory, ScriptUIManager launchScriptEditor) { this.scriptUIManager = launchScriptEditor; this.api = api; // find a sensible directory if (directory == null) { directory = new File(ScriptConstants.DIRECTORY); if (!directory.exists()) { directory = new File(""); } } this.directory = directory; setLayout(new BorderLayout(0, 0)); // Add directory browser and label at the top in their own panel. // Label is wrapped in a panel because alignment is being ignored and this at least makes it properly centred. // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4275005 boolean lockedDir = scriptUIManager.getAppPermissions().isScriptDirectoryLocked(); if (!lockedDir) { JLabel lblLabel = new JLabel("Scripts directory"); JPanel labelPanel = new JPanel(new BorderLayout()); labelPanel.add(lblLabel, BorderLayout.CENTER); labelPanel.setMaximumSize(lblLabel.getMinimumSize()); dirChooser = new FileBrowserPanel(directory.getAbsolutePath(), new FilenameChangeListener() { @Override public void filenameChanged(String newFilename) { ScriptsPanel.this.directory = new File(newFilename); onDirectoryChanged(ScriptsPanel.this.directory); } }, true, "Select"); JPanel topPanel = LayoutUtils.createVerticalBoxLayout(labelPanel, dirChooser); add(topPanel, BorderLayout.NORTH); } else { dirChooser = null; } // add toolbar at the bottom JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); add(toolBar, BorderLayout.SOUTH); // create all actions and add as buttons and menu items popup = new JPopupMenu(); actions = createActions(launchScriptEditor.getAppPermissions()); for (Action action : actions) { toolBar.add(action); popup.add(action); } // add list in the centre scriptsTree = new ScriptsTree(scriptUIManager, popup); scriptsTree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { ScriptsPanel.this.updateAppearance(); } }); add(scriptsTree.getScrollPane(), BorderLayout.CENTER); // // create selection changed listener on the list // listControl.addListSelectionListener(new ListSelectionListener() { // // @Override // public void valueChanged(ListSelectionEvent e) { // updateAppearance(); // } // }); // finally file the list onDirectoryChanged(directory); }
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;// ww w .ja v a 2s . c om 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:com.eviware.soapui.impl.rest.panels.request.RestRequestDesktopPanel.java
private JPanel addMethodCombo() { JPanel methodPanel = new JPanel(new BorderLayout()); JComboBox methodComboBox = new JComboBox(new RestRequestMethodModel(getRequest())); methodComboBox.setSelectedItem(getRequest().getMethod()); JLabel methodLabel = new JLabel("Method"); methodPanel.add(methodLabel, BorderLayout.NORTH); methodPanel.add(methodComboBox, BorderLayout.SOUTH); methodPanel.setMinimumSize(new Dimension(75, STANDARD_TOOLBAR_HEIGHT)); methodPanel.setMaximumSize(new Dimension(75, STANDARD_TOOLBAR_HEIGHT + 10)); return methodPanel; }