/** OptionPaneDemo Constructor */ public OptionPaneDemo(SwingSet2 swingset) { // Set the title for this demo, and an icon used to represent this // demo inside the SwingSet2 app. super(swingset, "OptionPaneDemo", "toolbar/JOptionPane.gif"); JPanel demo = getDemoPanel(); demo.setLayout(new BoxLayout(demo, BoxLayout.X_AXIS)); JPanel bp = new JPanel() { public Dimension getMaximumSize() { return new Dimension(getPreferredSize().width, super.getMaximumSize().height); } }; bp.setLayout(new BoxLayout(bp, BoxLayout.Y_AXIS)); bp.add(Box.createRigidArea(VGAP30)); bp.add(Box.createRigidArea(VGAP30)); bp.add(createInputDialogButton()); bp.add(Box.createRigidArea(VGAP15)); bp.add(createWarningDialogButton()); bp.add(Box.createRigidArea(VGAP15)); bp.add(createMessageDialogButton()); bp.add(Box.createRigidArea(VGAP15)); bp.add(createComponentDialogButton()); bp.add(Box.createRigidArea(VGAP15)); bp.add(createConfirmDialogButton()); bp.add(Box.createVerticalGlue()); demo.add(Box.createHorizontalGlue()); demo.add(bp); demo.add(Box.createHorizontalGlue()); }
public HelpUI(Frame parent, String title) { sidebar = new Sidebar(); sidebar.setBorder(new EmptyBorder(10, 10, 10, 10)); infoView = new JTextPane(); Dimension d1 = sidebar.getPreferredSize(); infoView.setPreferredSize(new Dimension(d1.width * 3, d1.height - 5)); infoView.setEditable(false); MouseAdapter ma = new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { SidebarOption sopt = (SidebarOption) me.getComponent(); if (sel != null) { sel.setSelected(false); sel.repaint(); } sel = sopt; sel.setSelected(true); sel.repaint(); renderInfo(); } }; general = new SidebarOption("General Info", HELP_GENERAL_LOC); general.addMouseListener(ma); sidebar.add(general); sidebar.add(Box.createVerticalStrut(scy(10))); artifact = new SidebarOption("Artifacts", HELP_ARTIFACTS_LOC); artifact.addMouseListener(ma); sidebar.add(artifact); sidebar.add(Box.createVerticalStrut(scy(10))); net = new SidebarOption("Networking", HELP_NET_LOC); net.addMouseListener(ma); sidebar.add(net); sidebar.add(Box.createVerticalStrut(scy(10))); gpl = new SidebarOption("License", HELP_GPL_LOC); gpl.addMouseListener(ma); sidebar.add(gpl); general.setSelected(true); sel = general; sidebar.add(Box.createVerticalGlue()); add(BorderLayout.WEST, sidebar); add(BorderLayout.CENTER, new JScrollPane(infoView)); setResizable(false); pack(); setLocationRelativeTo(parent); setTitle(title); renderInfo(); }
public void createFileChooserDemo() { theImage = new JLabel(""); jpgIcon = createImageIcon("filechooser/jpgIcon.jpg", "jpg image"); gifIcon = createImageIcon("filechooser/gifIcon.gif", "gif image"); JPanel demoPanel = getDemoPanel(); demoPanel.setLayout(new BoxLayout(demoPanel, BoxLayout.Y_AXIS)); JPanel innerPanel = new JPanel(); innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.X_AXIS)); demoPanel.add(Box.createRigidArea(VGAP20)); demoPanel.add(innerPanel); demoPanel.add(Box.createRigidArea(VGAP20)); innerPanel.add(Box.createRigidArea(HGAP20)); // Create a panel to hold buttons JPanel buttonPanel = new JPanel() { public Dimension getMaximumSize() { return new Dimension(getPreferredSize().width, super.getMaximumSize().height); } }; buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.Y_AXIS)); buttonPanel.add(Box.createRigidArea(VGAP15)); buttonPanel.add(createPlainFileChooserButton()); buttonPanel.add(Box.createRigidArea(VGAP15)); buttonPanel.add(createPreviewFileChooserButton()); buttonPanel.add(Box.createRigidArea(VGAP15)); buttonPanel.add(createCustomFileChooserButton()); buttonPanel.add(Box.createVerticalGlue()); // Create a panel to hold the image JPanel imagePanel = new JPanel(); imagePanel.setLayout(new BorderLayout()); imagePanel.setBorder(new BevelBorder(BevelBorder.LOWERED)); JScrollPane scroller = new JScrollPane(theImage); scroller.getVerticalScrollBar().setUnitIncrement(10); scroller.getHorizontalScrollBar().setUnitIncrement(10); imagePanel.add(scroller, BorderLayout.CENTER); // add buttons and image panels to inner panel innerPanel.add(buttonPanel); innerPanel.add(Box.createRigidArea(HGAP30)); innerPanel.add(imagePanel); innerPanel.add(Box.createRigidArea(HGAP20)); }
public GuideCertInstallPane() { super(); setLayout(new GridBagLayout()); ResourceSet resource = KeyCertUtility.getKeyCertWizardResourceSet(); setBorder( new TitledBorder( new CompoundBorder( new EtchedBorder(), new EmptyBorder( COMPONENT_SPACE, COMPONENT_SPACE, COMPONENT_SPACE, COMPONENT_SPACE)), resource.getString("GuideCertInstallPane", "title"))); int y = 0; GridBagUtil.constrain( this, new MultilineLabel(resource.getString("GuideCertInstallPane", "explain")), 0, ++y, 1, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.BOTH, 0, 0, SEPARATED_COMPONENT_SPACE, 0); GridBagUtil.constrain( this, Box.createVerticalGlue(), 0, ++y, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH, GridBagConstraints.BOTH, 0, 0, 0, 0); GridBagUtil.constrain( this, new JLabel(resource.getString(null, "clickNextToContinue")), 0, ++y, 1, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.BOTH, 0, 0, 0, 0); }
public WizardStep getStage(String stage) { final WhatsNew _this = this; WizardStep ws = new WizardStep(); int ind = stage.indexOf(":"); Version v = new Version(stage.substring(0, ind)); int lind = Integer.parseInt(stage.substring(ind + 1)); java.util.List<WhatsNewItem> its = this.items.get(v); if (its == null) { return null; } WhatsNewItem item = its.get(lind); if (item == null) { return null; } ws.title = item.title; ws.helpText = this.getFirstHelpText(); if ((item.description != null) || (item.component != null)) { final Box b = new Box(BoxLayout.Y_AXIS); if (item.description != null) { JTextPane hp = UIUtils.createHelpTextPane(item.description, this.projectViewer); hp.setBorder(null); hp.setSize(new Dimension(UIUtils.getPopupWidth() - 25, 500)); Box hpb = new Box(BoxLayout.Y_AXIS); hpb.add(hp); hpb.setMaximumSize(hpb.getPreferredSize()); hpb.setBorder(UIUtils.createPadding(0, 5, 0, 0)); b.add(hpb); } if (item.component != null) { if (item.description != null) { b.add(Box.createVerticalStrut(5)); } item.component.setAlignmentY(Component.TOP_ALIGNMENT); item.component.setBorder(UIUtils.createPadding(5, 10, 0, 0)); b.add(item.component); } b.add(Box.createVerticalGlue()); ws.panel = b; } return ws; }
public SketchProperties(Editor e, Sketch s) { super(); editor = e; sketch = s; fields = new HashMap<String, JComponent>(); this.setPreferredSize(new Dimension(500, 400)); this.setMinimumSize(new Dimension(500, 400)); this.setMaximumSize(new Dimension(500, 400)); this.setSize(new Dimension(500, 400)); Point eLoc = editor.getLocation(); int x = eLoc.x; int y = eLoc.y; Dimension eSize = editor.getSize(); int w = eSize.width; int h = eSize.height; int cx = x + (w / 2); int cy = y + (h / 2); this.setLocation(new Point(cx - 250, cy - 200)); this.setModal(true); outer = new JPanel(new BorderLayout()); outer.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); this.add(outer); win = new JPanel(); win.setLayout(new BorderLayout()); outer.add(win, BorderLayout.CENTER); buttonBar = new JPanel(new FlowLayout(FlowLayout.RIGHT)); saveButton = new JButton("OK"); saveButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { save(); SketchProperties.this.dispose(); } }); cancelButton = new JButton("Cancel"); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { SketchProperties.this.dispose(); } }); buttonBar.add(saveButton); buttonBar.add(cancelButton); win.add(buttonBar, BorderLayout.SOUTH); tabs = new JTabbedPane(); overviewPane = new JPanel(); overviewPane.setLayout(new BoxLayout(overviewPane, BoxLayout.PAGE_AXIS)); overviewPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); addTextField(overviewPane, "author", "Sketch author:"); addTextArea(overviewPane, "summary", "Summary:"); addTextArea(overviewPane, "license", "Copyright / License:"); tabs.add("Overview", overviewPane); objectsPane = new JPanel(); objectsPane.setLayout(new BoxLayout(objectsPane, BoxLayout.PAGE_AXIS)); objectsPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); addTextField(objectsPane, "board", "Board:"); addTextField(objectsPane, "core", "Core:"); addTextField(objectsPane, "compiler", "Compiler:"); addTextField(objectsPane, "port", "Serial port:"); addTextField(objectsPane, "programmer", "Programmer:"); JButton setDef = new JButton("Set to current IDE values"); setDef.setMaximumSize(setDef.getPreferredSize()); setDef.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setObjectValues(); } }); objectsPane.add(Box.createVerticalGlue()); objectsPane.add(setDef); tabs.add("Objects", objectsPane); win.add(tabs, BorderLayout.CENTER); this.setTitle("Sketch Properties"); this.pack(); this.setVisible(true); }