List of usage examples for javax.swing JPanel setAlignmentX
@BeanProperty(description = "The preferred horizontal alignment of the component.") public void setAlignmentX(float alignmentX)
From source file:de.unikassel.jung.PluggableRendererDemo.java
/** * @param jp/*from w ww.j a v a2 s .c o m*/ * panel to which controls will be added */ @SuppressWarnings("serial") protected void addBottomControls(final JPanel jp) { final JPanel control_panel = new JPanel(); jp.add(control_panel, BorderLayout.EAST); control_panel.setLayout(new BorderLayout()); final Box vertex_panel = Box.createVerticalBox(); vertex_panel.setBorder(BorderFactory.createTitledBorder("Vertices")); final Box edge_panel = Box.createVerticalBox(); edge_panel.setBorder(BorderFactory.createTitledBorder("Edges")); final Box both_panel = Box.createVerticalBox(); control_panel.add(vertex_panel, BorderLayout.NORTH); control_panel.add(edge_panel, BorderLayout.SOUTH); control_panel.add(both_panel, BorderLayout.CENTER); // set up vertex controls v_color = new JCheckBox("seed highlight"); v_color.addActionListener(this); v_stroke = new JCheckBox("stroke highlight on selection"); v_stroke.addActionListener(this); v_labels = new JCheckBox("show voltage values"); v_labels.addActionListener(this); v_shape = new JCheckBox("shape by degree"); v_shape.addActionListener(this); v_size = new JCheckBox("size by voltage"); v_size.addActionListener(this); v_size.setSelected(true); v_aspect = new JCheckBox("stretch by degree ratio"); v_aspect.addActionListener(this); v_small = new JCheckBox("filter when degree < " + VertexDisplayPredicate.MIN_DEGREE); v_small.addActionListener(this); vertex_panel.add(v_color); vertex_panel.add(v_stroke); vertex_panel.add(v_labels); vertex_panel.add(v_shape); vertex_panel.add(v_size); vertex_panel.add(v_aspect); vertex_panel.add(v_small); // set up edge controls JPanel gradient_panel = new JPanel(new GridLayout(1, 0)); gradient_panel.setBorder(BorderFactory.createTitledBorder("Edge paint")); no_gradient = new JRadioButton("Solid color"); no_gradient.addActionListener(this); no_gradient.setSelected(true); // gradient_absolute = new JRadioButton("Absolute gradient"); // gradient_absolute.addActionListener(this); gradient_relative = new JRadioButton("Gradient"); gradient_relative.addActionListener(this); ButtonGroup bg_grad = new ButtonGroup(); bg_grad.add(no_gradient); bg_grad.add(gradient_relative); // bg_grad.add(gradient_absolute); gradient_panel.add(no_gradient); // gradientGrid.add(gradient_absolute); gradient_panel.add(gradient_relative); JPanel shape_panel = new JPanel(new GridLayout(3, 2)); shape_panel.setBorder(BorderFactory.createTitledBorder("Edge shape")); e_line = new JRadioButton("line"); e_line.addActionListener(this); e_line.setSelected(true); // e_bent = new JRadioButton("bent line"); // e_bent.addActionListener(this); e_wedge = new JRadioButton("wedge"); e_wedge.addActionListener(this); e_quad = new JRadioButton("quad curve"); e_quad.addActionListener(this); e_cubic = new JRadioButton("cubic curve"); e_cubic.addActionListener(this); e_ortho = new JRadioButton("orthogonal"); e_ortho.addActionListener(this); ButtonGroup bg_shape = new ButtonGroup(); bg_shape.add(e_line); // bg.add(e_bent); bg_shape.add(e_wedge); bg_shape.add(e_quad); bg_shape.add(e_ortho); bg_shape.add(e_cubic); shape_panel.add(e_line); // shape_panel.add(e_bent); shape_panel.add(e_wedge); shape_panel.add(e_quad); shape_panel.add(e_cubic); shape_panel.add(e_ortho); fill_edges = new JCheckBox("fill edge shapes"); fill_edges.setSelected(false); fill_edges.addActionListener(this); shape_panel.add(fill_edges); shape_panel.setOpaque(true); e_color = new JCheckBox("highlight edge weights"); e_color.addActionListener(this); e_labels = new JCheckBox("show edge weight values"); e_labels.addActionListener(this); e_uarrow_pred = new JCheckBox("undirected"); e_uarrow_pred.addActionListener(this); e_darrow_pred = new JCheckBox("directed"); e_darrow_pred.addActionListener(this); e_darrow_pred.setSelected(true); e_arrow_centered = new JCheckBox("centered"); e_arrow_centered.addActionListener(this); JPanel arrow_panel = new JPanel(new GridLayout(1, 0)); arrow_panel.setBorder(BorderFactory.createTitledBorder("Show arrows")); arrow_panel.add(e_uarrow_pred); arrow_panel.add(e_darrow_pred); arrow_panel.add(e_arrow_centered); e_show_d = new JCheckBox("directed"); e_show_d.addActionListener(this); e_show_d.setSelected(true); e_show_u = new JCheckBox("undirected"); e_show_u.addActionListener(this); e_show_u.setSelected(true); JPanel show_edge_panel = new JPanel(new GridLayout(1, 0)); show_edge_panel.setBorder(BorderFactory.createTitledBorder("Show edges")); show_edge_panel.add(e_show_u); show_edge_panel.add(e_show_d); shape_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(shape_panel); gradient_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(gradient_panel); show_edge_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(show_edge_panel); arrow_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(arrow_panel); e_color.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(e_color); e_labels.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(e_labels); // set up zoom controls zoom_at_mouse = new JCheckBox("<html><center>zoom at mouse<p>(wheel only)</center></html>"); zoom_at_mouse.addActionListener(this); zoom_at_mouse.setSelected(true); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JPanel zoomPanel = new JPanel(); zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom")); plus.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(plus); minus.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(minus); zoom_at_mouse.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(zoom_at_mouse); JPanel fontPanel = new JPanel(); // add font and zoom controls to center panel font = new JCheckBox("bold text"); font.addActionListener(this); font.setAlignmentX(Component.CENTER_ALIGNMENT); fontPanel.add(font); both_panel.add(zoomPanel); both_panel.add(fontPanel); JComboBox modeBox = gm.getModeComboBox(); modeBox.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel modePanel = new JPanel(new BorderLayout()) { @Override public Dimension getMaximumSize() { return getPreferredSize(); } }; modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); JPanel comboGrid = new JPanel(new GridLayout(0, 1)); comboGrid.add(modePanel); fontPanel.add(comboGrid); JComboBox cb = new JComboBox(); cb.addItem(Renderer.VertexLabel.Position.N); cb.addItem(Renderer.VertexLabel.Position.NE); cb.addItem(Renderer.VertexLabel.Position.E); cb.addItem(Renderer.VertexLabel.Position.SE); cb.addItem(Renderer.VertexLabel.Position.S); cb.addItem(Renderer.VertexLabel.Position.SW); cb.addItem(Renderer.VertexLabel.Position.W); cb.addItem(Renderer.VertexLabel.Position.NW); cb.addItem(Renderer.VertexLabel.Position.N); cb.addItem(Renderer.VertexLabel.Position.CNTR); cb.addItem(Renderer.VertexLabel.Position.AUTO); cb.addItemListener(new ItemListener() { @Override public void itemStateChanged(final ItemEvent e) { Renderer.VertexLabel.Position position = (Renderer.VertexLabel.Position) e.getItem(); vv.getRenderer().getVertexLabelRenderer().setPosition(position); vv.repaint(); } }); cb.setSelectedItem(Renderer.VertexLabel.Position.SE); JPanel positionPanel = new JPanel(); positionPanel.setBorder(BorderFactory.createTitledBorder("Label Position")); positionPanel.add(cb); comboGrid.add(positionPanel); }
From source file:Installer.java
public Installer(File targetDir) { ToolTipManager.sharedInstance().setDismissDelay(Integer.MAX_VALUE); this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JPanel logoSplash = new JPanel(); logoSplash.setLayout(new BoxLayout(logoSplash, BoxLayout.Y_AXIS)); try {//from w w w . j a v a2 s . c om // Read png BufferedImage image; image = ImageIO.read(Installer.class.getResourceAsStream("logo.png")); ImageIcon icon = new ImageIcon(image); JLabel logoLabel = new JLabel(icon); logoLabel.setAlignmentX(CENTER_ALIGNMENT); logoLabel.setAlignmentY(CENTER_ALIGNMENT); logoLabel.setSize(image.getWidth(), image.getHeight()); if (!QUIET_DEV) // VIVE - hide oculus logo logoSplash.add(logoLabel); } catch (IOException e) { } catch (IllegalArgumentException e) { } userHomeDir = System.getProperty("user.home", "."); osType = System.getProperty("os.name").toLowerCase(); if (osType.contains("win")) { isWindows = true; appDataDir = System.getenv("APPDATA"); } version = "UNKNOWN"; try { InputStream ver = Installer.class.getResourceAsStream("version"); if (ver != null) { String[] tok = new BufferedReader(new InputStreamReader(ver)).readLine().split(":"); if (tok.length > 0) { jar_id = tok[0]; version = tok[1]; } } } catch (IOException e) { } // Read release notes, save to file String tmpFileName = System.getProperty("java.io.tmpdir") + releaseNotePathAddition + "Vivecraft" + version.toLowerCase() + "_release_notes.txt"; releaseNotes = new File(tmpFileName); InputStream is = Installer.class.getResourceAsStream("release_notes.txt"); if (!copyInputStreamToFile(is, releaseNotes)) { releaseNotes = null; } JLabel tag = new JLabel("Welcome! This will install Vivecraft " + version); tag.setAlignmentX(CENTER_ALIGNMENT); tag.setAlignmentY(CENTER_ALIGNMENT); logoSplash.add(tag); logoSplash.add(Box.createRigidArea(new Dimension(5, 20))); tag = new JLabel("Select path to minecraft. (The default here is almost always what you want.)"); tag.setAlignmentX(CENTER_ALIGNMENT); tag.setAlignmentY(CENTER_ALIGNMENT); logoSplash.add(tag); logoSplash.setAlignmentX(CENTER_ALIGNMENT); logoSplash.setAlignmentY(TOP_ALIGNMENT); this.add(logoSplash); JPanel entryPanel = new JPanel(); entryPanel.setLayout(new BoxLayout(entryPanel, BoxLayout.X_AXIS)); Installer.targetDir = targetDir; selectedDirText = new JTextField(); selectedDirText.setEditable(false); selectedDirText.setToolTipText("Path to minecraft"); selectedDirText.setColumns(30); entryPanel.add(selectedDirText); JButton dirSelect = new JButton(); dirSelect.setAction(new FileSelectAction()); dirSelect.setText("..."); dirSelect.setToolTipText("Select an alternative minecraft directory"); entryPanel.add(dirSelect); entryPanel.setAlignmentX(LEFT_ALIGNMENT); entryPanel.setAlignmentY(TOP_ALIGNMENT); infoLabel = new JLabel(); infoLabel.setHorizontalTextPosition(JLabel.LEFT); infoLabel.setVerticalTextPosition(JLabel.TOP); infoLabel.setAlignmentX(LEFT_ALIGNMENT); infoLabel.setAlignmentY(TOP_ALIGNMENT); infoLabel.setVisible(false); fileEntryPanel = new JPanel(); fileEntryPanel.setLayout(new BoxLayout(fileEntryPanel, BoxLayout.Y_AXIS)); fileEntryPanel.add(infoLabel); fileEntryPanel.add(entryPanel); fileEntryPanel.setAlignmentX(CENTER_ALIGNMENT); fileEntryPanel.setAlignmentY(TOP_ALIGNMENT); this.add(fileEntryPanel); this.add(Box.createVerticalStrut(5)); JPanel optPanel = new JPanel(); optPanel.setLayout(new BoxLayout(optPanel, BoxLayout.Y_AXIS)); optPanel.setAlignmentX(LEFT_ALIGNMENT); optPanel.setAlignmentY(TOP_ALIGNMENT); //Add forge options JPanel forgePanel = new JPanel(); forgePanel.setLayout(new BoxLayout(forgePanel, BoxLayout.X_AXIS)); //Create forge: no/yes buttons useForge = new JCheckBox(); AbstractAction actf = new updateActionF(); actf.putValue(AbstractAction.NAME, "Install Vivecraft with Forge " + FORGE_VERSION); useForge.setAction(actf); forgeVersion = new JComboBox(); if (!ALLOW_FORGE_INSTALL) useForge.setEnabled(false); useForge.setToolTipText( "<html>" + "If checked, installs Vivecraft with Forge support. The correct version of Forge<br>" + "(as displayed) must already be installed.<br>" + "</html>"); //Add "yes" and "which version" to the forgePanel useForge.setAlignmentX(LEFT_ALIGNMENT); forgeVersion.setAlignmentX(LEFT_ALIGNMENT); forgePanel.add(useForge); //forgePanel.add(forgeVersion); // Profile creation / update support createProfile = new JCheckBox("", true); AbstractAction actp = new updateActionP(); actp.putValue(AbstractAction.NAME, "Create Vivecraft launcher profile"); createProfile.setAction(actp); createProfile.setAlignmentX(LEFT_ALIGNMENT); createProfile.setSelected(true); createProfile.setToolTipText("<html>" + "If checked, if a Vivecraft profile doesn't already exist within the Minecraft launcher<br>" + "one is added. Then the profile is selected, and this Vivecraft version is set as the<br>" + "current version.<br>" + "</html>"); useShadersMod = new JCheckBox(); useShadersMod.setAlignmentX(LEFT_ALIGNMENT); if (!ALLOW_SHADERSMOD_INSTALL) useShadersMod.setEnabled(false); AbstractAction acts = new updateActionSM(); acts.putValue(AbstractAction.NAME, "Install Vivecraft with ShadersMod 2.3.29"); useShadersMod.setAction(acts); useShadersMod.setToolTipText("<html>" + "If checked, sets the vivecraft profile to use ShadersMod <br>" + "support." + "</html>"); useHydra = new JCheckBox("Razer Hydra support", false); useHydra.setAlignmentX(LEFT_ALIGNMENT); if (!ALLOW_HYDRA_INSTALL) useHydra.setEnabled(false); useHydra.setToolTipText("<html>" + "If checked, installs the additional Razor Hydra native library required for Razor Hydra<br>" + "support." + "</html>"); useHrtf = new JCheckBox("Enable binaural audio (Only needed once per PC)", false); useHrtf.setToolTipText("<html>" + "If checked, the installer will create the configuration file needed for OpenAL HRTF<br>" + "ear-aware sound in Minecraft (and other games).<br>" + " If the file has previously been created, you do not need to check this again.<br>" + " NOTE: Your sound card's output MUST be set to 44.1Khz.<br>" + " WARNING, will overwrite " + (isWindows ? (appDataDir + "\\alsoft.ini") : (userHomeDir + "/.alsoftrc")) + "!<br>" + " Delete the " + (isWindows ? "alsoft.ini" : "alsoftrc") + " file to disable HRTF again." + "</html>"); useHrtf.setAlignmentX(LEFT_ALIGNMENT); //Add option panels option panel forgePanel.setAlignmentX(LEFT_ALIGNMENT); //optPanel.add(forgePanel); //optPanel.add(useShadersMod); optPanel.add(createProfile); optPanel.add(useHrtf); this.add(optPanel); this.add(Box.createRigidArea(new Dimension(5, 20))); instructions = new JLabel("", SwingConstants.CENTER); instructions.setAlignmentX(CENTER_ALIGNMENT); instructions.setAlignmentY(TOP_ALIGNMENT); instructions.setForeground(Color.RED); instructions.setPreferredSize(new Dimension(20, 40)); this.add(instructions); this.add(Box.createVerticalGlue()); JLabel github = linkify("Vivecraft is open source. find it on Github", "https://github.com/jrbudda/Vivecraft_111", "Vivecraft 1.11 Github"); JLabel wiki = linkify("Vivecraft home page", "http://www.vivecraft.org", "Vivecraft Home"); JLabel donate = linkify("If you think Vivecraft is awesome, please consider donating.", "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=JVBJLN5HJJS52&lc=US&item_name=jrbudda¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted)", "jrbudda's Paypal"); JLabel optifine = linkify("Vivecraft includes OptiFine for performance. Consider donating to them as well.", "http://optifine.net/donate.php", "http://optifine.net/donate.php"); github.setAlignmentX(CENTER_ALIGNMENT); github.setHorizontalAlignment(SwingConstants.CENTER); wiki.setAlignmentX(CENTER_ALIGNMENT); wiki.setHorizontalAlignment(SwingConstants.CENTER); donate.setAlignmentX(CENTER_ALIGNMENT); donate.setHorizontalAlignment(SwingConstants.CENTER); optifine.setAlignmentX(CENTER_ALIGNMENT); optifine.setHorizontalAlignment(SwingConstants.CENTER); this.add(Box.createRigidArea(new Dimension(5, 20))); this.add(github); this.add(wiki); this.add(donate); this.add(optifine); this.setAlignmentX(LEFT_ALIGNMENT); updateFilePath(); updateInstructions(); }
From source file:metdemo.Finance.Pluggable.java
protected void addBottomControls(final JPanel jp) { final JPanel control_panel = new JPanel(); jp.add(control_panel, BorderLayout.SOUTH); control_panel.setLayout(new BorderLayout()); final Box vertex_panel = Box.createVerticalBox(); vertex_panel.setBorder(BorderFactory.createTitledBorder("Vertices")); final Box edge_panel = Box.createVerticalBox(); edge_panel.setBorder(BorderFactory.createTitledBorder("Edges")); final Box both_panel = Box.createVerticalBox(); control_panel.add(vertex_panel, BorderLayout.WEST); control_panel.add(edge_panel, BorderLayout.EAST); control_panel.add(both_panel, BorderLayout.CENTER); // set up vertex controls v_color = new JCheckBox("vertex seed coloring"); v_color.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { vcf.setSeedColoring(v_color.isSelected()); }//from ww w . j av a 2 s.c o m }); v_stroke = new JCheckBox("<html>vertex selection<p>stroke highlighting</html>"); v_stroke.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { vsh.setHighlight(v_stroke.isSelected()); } }); v_labels = new JCheckBox("show vertex ranks (voltages)"); v_labels.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (v_labels.isSelected()) pr.setVertexStringer(vs); else pr.setVertexStringer(vs_none); } }); v_shape = new JCheckBox("vertex degree shapes"); v_shape.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { vssa.useFunnyShapes(v_shape.isSelected()); } }); v_size = new JCheckBox("vertex voltage size"); v_size.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { vssa.setScaling(v_size.isSelected()); } }); v_aspect = new JCheckBox("vertex degree ratio stretch"); v_aspect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { vssa.setStretching(v_aspect.isSelected()); } }); v_small = new JCheckBox("filter vertices of degree < " + VertexDisplayPredicate.MIN_DEGREE); v_small.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { show_vertex.filterSmall(v_small.isSelected()); } }); vertex_panel.add(v_color); vertex_panel.add(v_stroke); vertex_panel.add(v_labels); vertex_panel.add(v_shape); vertex_panel.add(v_size); vertex_panel.add(v_aspect); vertex_panel.add(v_small); // set up edge controls JPanel gradient_panel = new JPanel(new GridLayout(1, 0)); gradient_panel.setBorder(BorderFactory.createTitledBorder("Edge paint")); no_gradient = new JRadioButton("Solid color"); no_gradient.setSelected(true); no_gradient.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { gradient_level = GRADIENT_NONE; } }); // gradient_absolute = new JRadioButton("Absolute gradient"); // gradient_absolute.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { gradient_level = GRADIENT_ABSOLUTE;}}); gradient_relative = new JRadioButton("Gradient"); gradient_relative.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { gradient_level = GRADIENT_RELATIVE; } }); ButtonGroup bg_grad = new ButtonGroup(); bg_grad.add(no_gradient); bg_grad.add(gradient_relative); //bg_grad.add(gradient_absolute); gradient_panel.add(no_gradient); //gradientGrid.add(gradient_absolute); gradient_panel.add(gradient_relative); JPanel shape_panel = new JPanel(new GridLayout(3, 2)); shape_panel.setBorder(BorderFactory.createTitledBorder("Edge shape")); e_line = new JRadioButton("line"); e_line.setSelected(true); e_line.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pr.setEdgeShapeFunction(new EdgeShape.Line()); } }); // e_bent = new JRadioButton("bent line"); // e_bent.setSelected(true); e_wedge = new JRadioButton("wedge"); e_wedge.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pr.setEdgeShapeFunction(new EdgeShape.Wedge(10)); } }); e_quad = new JRadioButton("quad curve"); e_quad.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pr.setEdgeShapeFunction(new EdgeShape.QuadCurve()); } }); e_cubic = new JRadioButton("cubic curve"); e_cubic.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pr.setEdgeShapeFunction(new EdgeShape.CubicCurve()); } }); ButtonGroup bg_shape = new ButtonGroup(); bg_shape.add(e_line); // bg.add(e_bent); bg_shape.add(e_wedge); bg_shape.add(e_quad); bg_shape.add(e_cubic); shape_panel.add(e_line); // shape_panel.add(e_bent); shape_panel.add(e_wedge); shape_panel.add(e_quad); shape_panel.add(e_cubic); fill_edges = new JCheckBox("fill edge shapes"); fill_edges.setSelected(false); fill_edges.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { edgePaint.useFill(fill_edges.isSelected()); } }); shape_panel.add(fill_edges); shape_panel.setOpaque(true); e_color = new JCheckBox("edge weight highlighting"); e_color.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ewcs.setWeighted(e_color.isSelected()); } }); e_labels = new JCheckBox("show edge weights"); e_labels.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e_labels.isSelected()) pr.setEdgeStringer(es); else pr.setEdgeStringer(es_none); } }); e_uarrow_pred = new JCheckBox("undirected"); e_uarrow_pred.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { show_arrow.showUndirected(e_uarrow_pred.isSelected()); } }); e_darrow_pred = new JCheckBox("directed"); e_darrow_pred.setSelected(true); e_darrow_pred.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { show_arrow.showDirected(e_darrow_pred.isSelected()); } }); JPanel arrow_panel = new JPanel(new GridLayout(1, 0)); arrow_panel.setBorder(BorderFactory.createTitledBorder("Show arrows")); arrow_panel.add(e_uarrow_pred); arrow_panel.add(e_darrow_pred); e_show_d = new JCheckBox("directed"); e_show_d.setSelected(true); e_show_d.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { show_edge.showDirected(e_show_d.isSelected()); } }); e_show_u = new JCheckBox("undirected"); e_show_u.setSelected(true); e_show_u.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { show_edge.showUndirected(e_show_u.isSelected()); } }); JPanel show_edge_panel = new JPanel(new GridLayout(1, 0)); show_edge_panel.setBorder(BorderFactory.createTitledBorder("Show edges")); show_edge_panel.add(e_show_u); show_edge_panel.add(e_show_d); shape_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(shape_panel); gradient_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(gradient_panel); show_edge_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(show_edge_panel); arrow_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(arrow_panel); e_color.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(e_color); e_labels.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(e_labels); // set up zoom controls zoom_at_mouse = new JCheckBox("<html><center>zoom at mouse<p>(wheel only)</center></html>"); zoom_at_mouse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { gm.setZoomAtMouse(zoom_at_mouse.isSelected()); } }); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // call listener in GraphMouse instead of manipulating vv scale directly // this is so the crossover from zoom to scale works with the buttons // as well as with the mouse wheel Dimension d = vv.getSize(); gm.mouseWheelMoved(new MouseWheelEvent(vv, MouseEvent.MOUSE_WHEEL, System.currentTimeMillis(), 0, d.width / 2, d.height / 2, 1, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, 1)); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // call listener in GraphMouse instead of manipulating vv scale directly // this is so the crossover from zoom to scale works with the buttons // as well as with the mouse wheel Dimension d = vv.getSize(); gm.mouseWheelMoved(new MouseWheelEvent(vv, MouseEvent.MOUSE_WHEEL, System.currentTimeMillis(), 0, d.width / 2, d.height / 2, 1, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, -1)); } }); Box zoomPanel = Box.createVerticalBox(); zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom")); plus.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(plus); minus.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(minus); zoom_at_mouse.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(zoom_at_mouse); // add font and zoom controls to center panel font = new JCheckBox("bold text"); font.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ff.setBold(font.isSelected()); } }); font.setAlignmentX(Component.CENTER_ALIGNMENT); both_panel.add(zoomPanel); both_panel.add(font); JComboBox modeBox = gm.getModeComboBox(); modeBox.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel modePanel = new JPanel(new BorderLayout()) { public Dimension getMaximumSize() { return getPreferredSize(); } }; modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); both_panel.add(modePanel); }
From source file:lcmc.gui.resources.ServiceInfo.java
/** Returns info panel with comboboxes for service parameters. */ @Override//from w w w . jav a 2 s . c o m public JComponent getInfoPanel() { if (!getResourceAgent().isMetaDataLoaded()) { final JPanel p = new JPanel(); p.add(new JLabel(Tools.getString("ServiceInfo.LoadingMetaData"))); return p; } final CloneInfo ci = getCloneInfo(); if (ci == null) { getBrowser().getCRMGraph().pickInfo(this); } else { getBrowser().getCRMGraph().pickInfo(ci); } if (infoPanel != null) { return infoPanel; } /* init save button */ final boolean abExisted = getApplyButton() != null; final ServiceInfo thisClass = this; final ButtonCallback buttonCallback = new ButtonCallback() { private volatile boolean mouseStillOver = false; /** * Whether the whole thing should be enabled. */ @Override public final boolean isEnabled() { final Host dcHost = getBrowser().getDCHost(); if (dcHost == null) { return false; } if (Tools.versionBeforePacemaker(dcHost)) { return false; } return true; } @Override public final void mouseOut() { if (!isEnabled()) { return; } mouseStillOver = false; getBrowser().getCRMGraph().stopTestAnimation(getApplyButton()); getApplyButton().setToolTipText(null); } @Override public final void mouseOver() { if (!isEnabled()) { return; } mouseStillOver = true; getApplyButton().setToolTipText(ClusterBrowser.STARTING_PTEST_TOOLTIP); getApplyButton() .setToolTipBackground(Tools.getDefaultColor("ClusterBrowser.Test.Tooltip.Background")); Tools.sleep(250); if (!mouseStillOver) { return; } mouseStillOver = false; final CountDownLatch startTestLatch = new CountDownLatch(1); getBrowser().getCRMGraph().startTestAnimation(getApplyButton(), startTestLatch); final Host dcHost = getBrowser().getDCHost(); getBrowser().ptestLockAcquire(); final ClusterStatus cs = getBrowser().getClusterStatus(); cs.setPtestData(null); apply(dcHost, true); final PtestData ptestData = new PtestData(CRM.getPtest(dcHost)); getApplyButton().setToolTipText(ptestData.getToolTip()); cs.setPtestData(ptestData); getBrowser().ptestLockRelease(); startTestLatch.countDown(); } }; if (getResourceAgent().isGroup()) { initApplyButton(buttonCallback, Tools.getString("Browser.ApplyGroup")); } else { initApplyButton(buttonCallback); } if (ci != null) { ci.setApplyButton(getApplyButton()); ci.setRevertButton(getRevertButton()); } /* add item listeners to the apply button. */ if (!abExisted) { getApplyButton().addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { final Thread thread = new Thread(new Runnable() { @Override public void run() { getBrowser().clStatusLock(); apply(getBrowser().getDCHost(), false); getBrowser().clStatusUnlock(); } }); thread.start(); } }); getRevertButton().addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { final Thread thread = new Thread(new Runnable() { @Override public void run() { getBrowser().clStatusLock(); revert(); getBrowser().clStatusUnlock(); } }); thread.start(); } }); } /* main, button and options panels */ final JPanel mainPanel = new JPanel(); mainPanel.setBackground(ClusterBrowser.PANEL_BACKGROUND); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); final JPanel buttonPanel = new JPanel(new BorderLayout()); buttonPanel.setBackground(ClusterBrowser.BUTTON_PANEL_BACKGROUND); buttonPanel.setMinimumSize(new Dimension(0, 50)); buttonPanel.setPreferredSize(new Dimension(0, 50)); buttonPanel.setMaximumSize(new Dimension(Short.MAX_VALUE, 50)); final JPanel optionsPanel = new JPanel(); optionsPanel.setBackground(ClusterBrowser.PANEL_BACKGROUND); optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.Y_AXIS)); optionsPanel.setAlignmentX(Component.LEFT_ALIGNMENT); /* Actions */ final JMenuBar mb = new JMenuBar(); mb.setBackground(ClusterBrowser.PANEL_BACKGROUND); AbstractButton serviceMenu; if (ci == null) { serviceMenu = getActionsButton(); } else { serviceMenu = ci.getActionsButton(); } buttonPanel.add(serviceMenu, BorderLayout.EAST); String defaultValue = PRIMITIVE_TYPE_STRING; if (ci != null) { if (ci.getService().isMaster()) { defaultValue = MASTER_SLAVE_TYPE_STRING; } else { defaultValue = CLONE_TYPE_STRING; } } if (!getResourceAgent().isClone() && getGroupInfo() == null) { typeRadioGroup = new Widget(defaultValue, new String[] { PRIMITIVE_TYPE_STRING, CLONE_TYPE_STRING, MASTER_SLAVE_TYPE_STRING }, null, /* units */ Widget.Type.RADIOGROUP, null, /* regexp */ ClusterBrowser.SERVICE_LABEL_WIDTH + ClusterBrowser.SERVICE_FIELD_WIDTH, null, /* abbrv */ new AccessMode(ConfigData.AccessType.ADMIN, false)); if (!getService().isNew()) { typeRadioGroup.setEnabled(false); } typeRadioGroup.addListeners(new WidgetListener() { @Override public void check(final Object value) { changeType(((JRadioButton) value).getText()); } }); final JPanel tp = new JPanel(); tp.setBackground(ClusterBrowser.PANEL_BACKGROUND); tp.setLayout(new BoxLayout(tp, BoxLayout.Y_AXIS)); tp.add(typeRadioGroup); typeRadioGroup.setBackgroundColor(ClusterBrowser.PANEL_BACKGROUND); optionsPanel.add(tp); } if (ci != null) { /* add clone fields */ addCloneFields(optionsPanel, ClusterBrowser.SERVICE_LABEL_WIDTH, ClusterBrowser.SERVICE_FIELD_WIDTH); } getResource().setValue(GUI_ID, getService().getId()); /* get dependent resources and create combo boxes for ones, that * need parameters */ final String[] params = getParametersFromXML(); final Info savedMAIdRef = savedMetaAttrInfoRef; addParams(optionsPanel, params, ClusterBrowser.SERVICE_LABEL_WIDTH, ClusterBrowser.SERVICE_FIELD_WIDTH, getSameAsFields(savedMAIdRef)); if (ci == null) { /* score combo boxes */ addHostLocations(optionsPanel, ClusterBrowser.SERVICE_LABEL_WIDTH, ClusterBrowser.SERVICE_FIELD_WIDTH); } for (final String param : params) { if (isMetaAttr(param)) { final Widget wi = getWidget(param, null); wi.setEnabled(savedMAIdRef == null); } } if (!getService().isNew()) { getWidget(GUI_ID, null).setEnabled(false); } if (!getResourceAgent().isGroup() && !getResourceAgent().isClone()) { /* Operations */ addOperations(optionsPanel, ClusterBrowser.SERVICE_LABEL_WIDTH, ClusterBrowser.SERVICE_FIELD_WIDTH); /* add item listeners to the operations combos */ for (final String op : getResourceAgent().getOperationNames()) { for (final String param : getBrowser().getCRMOperationParams(op)) { addOperationListeners(op, param); } } } /* add item listeners to the host scores combos */ if (ci == null) { addHostLocationsListeners(); } else { ci.addHostLocationsListeners(); } /* apply button */ addApplyButton(buttonPanel); addRevertButton(buttonPanel); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { /* invoke later on purpose */ setApplyButtons(null, params); } }); mainPanel.add(optionsPanel); final JPanel newPanel = new JPanel(); newPanel.setBackground(ClusterBrowser.PANEL_BACKGROUND); newPanel.setLayout(new BoxLayout(newPanel, BoxLayout.Y_AXIS)); newPanel.add(buttonPanel); newPanel.add( getMoreOptionsPanel(ClusterBrowser.SERVICE_LABEL_WIDTH + ClusterBrowser.SERVICE_FIELD_WIDTH + 4)); newPanel.add(new JScrollPane(mainPanel)); /* if id textfield was changed and this id is not used, * enable apply button */ infoPanel = newPanel; infoPanelDone(); return infoPanel; }
From source file:net.technicpack.launcher.ui.LauncherFrame.java
private void initComponents() { BorderLayout layout = new BorderLayout(); setLayout(layout);// w w w . java 2s.co m ///////////////////////////////////////////////////////////// //HEADER ///////////////////////////////////////////////////////////// JPanel header = new JPanel(); header.setLayout(new BoxLayout(header, BoxLayout.LINE_AXIS)); header.setBackground(COLOR_BLUE); header.setForeground(COLOR_WHITE_TEXT); header.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 10)); this.add(header, BorderLayout.PAGE_START); ImageIcon headerIcon = resources.getIcon("platform_icon_title.png"); JButton headerLabel = new JButton(headerIcon); headerLabel.setBorder(BorderFactory.createEmptyBorder(5, 8, 5, 0)); headerLabel.setContentAreaFilled(false); headerLabel.setFocusPainted(false); headerLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); headerLabel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { DesktopUtils.browseUrl("http://beta.technicpack.net/"); } }); header.add(headerLabel); header.add(Box.createRigidArea(new Dimension(6, 0))); ActionListener tabListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectTab(e.getActionCommand()); } }; discoverTab = new HeaderTab(resources.getString("launcher.title.discover"), resources); header.add(discoverTab); discoverTab.setActionCommand(TAB_DISCOVER); discoverTab.addActionListener(tabListener); modpacksTab = new HeaderTab(resources.getString("launcher.title.modpacks"), resources); modpacksTab.setIsActive(true); modpacksTab.setHorizontalTextPosition(SwingConstants.LEADING); modpacksTab.addActionListener(tabListener); modpacksTab.setActionCommand(TAB_MODPACKS); header.add(modpacksTab); newsTab = new HeaderTab(resources.getString("launcher.title.news"), resources); newsTab.setLayout(null); newsTab.addActionListener(tabListener); newsTab.setActionCommand(TAB_NEWS); header.add(newsTab); CountCircle newsCircle = new CountCircle(); newsCircle.setBackground(COLOR_RED); newsCircle.setForeground(COLOR_WHITE_TEXT); newsCircle.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS_BOLD, 14)); newsTab.add(newsCircle); newsCircle.setBounds(10, 17, 25, 25); header.add(Box.createHorizontalGlue()); JPanel rightHeaderPanel = new JPanel(); rightHeaderPanel.setOpaque(false); rightHeaderPanel.setLayout(new BoxLayout(rightHeaderPanel, BoxLayout.PAGE_AXIS)); rightHeaderPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); JPanel windowGadgetPanel = new JPanel(); windowGadgetPanel.setOpaque(false); windowGadgetPanel.setLayout(new BoxLayout(windowGadgetPanel, BoxLayout.LINE_AXIS)); windowGadgetPanel.setAlignmentX(RIGHT_ALIGNMENT); ImageIcon minimizeIcon = resources.getIcon("minimize.png"); JButton minimizeButton = new JButton(minimizeIcon); minimizeButton.setBorder(BorderFactory.createEmptyBorder()); minimizeButton.setContentAreaFilled(false); minimizeButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); minimizeButton.setFocusable(false); minimizeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { minimizeWindow(); } }); windowGadgetPanel.add(minimizeButton); ImageIcon closeIcon = resources.getIcon("close.png"); JButton closeButton = new JButton(closeIcon); closeButton.setBorder(BorderFactory.createEmptyBorder()); closeButton.setContentAreaFilled(false); closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { closeWindow(); } }); closeButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); closeButton.setFocusable(false); windowGadgetPanel.add(closeButton); rightHeaderPanel.add(windowGadgetPanel); rightHeaderPanel.add(Box.createVerticalGlue()); JButton launcherOptionsLabel = new JButton(resources.getString("launcher.title.options")); launcherOptionsLabel.setIcon(resources.getIcon("options_cog.png")); launcherOptionsLabel.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 14)); launcherOptionsLabel.setForeground(COLOR_WHITE_TEXT); launcherOptionsLabel.setHorizontalAlignment(SwingConstants.RIGHT); launcherOptionsLabel.setHorizontalTextPosition(SwingConstants.LEADING); launcherOptionsLabel.setAlignmentX(RIGHT_ALIGNMENT); launcherOptionsLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); launcherOptionsLabel.setBorder(BorderFactory.createEmptyBorder()); launcherOptionsLabel.setContentAreaFilled(false); launcherOptionsLabel.setFocusPainted(false); launcherOptionsLabel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openLauncherOptions(); } }); rightHeaderPanel.add(launcherOptionsLabel); header.add(rightHeaderPanel); ///////////////////////////////////////////////////////////// // CENTRAL AREA ///////////////////////////////////////////////////////////// centralPanel = new TintablePanel(); centralPanel.setBackground(COLOR_CHARCOAL); centralPanel.setForeground(COLOR_WHITE_TEXT); centralPanel.setTintColor(COLOR_CENTRAL_BACK); this.add(centralPanel, BorderLayout.CENTER); centralPanel.setLayout(new BorderLayout()); modpackPanel = new ModpackInfoPanel(resources, iconRepo, logoRepo, backgroundRepo, avatarRepo, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openModpackOptions((ModpackModel) e.getSource()); } }, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { refreshModpackOptions((ModpackModel) e.getSource()); } }); modpackSelector.setInfoPanel(modpackPanel); playButton = modpackPanel.getPlayButton(); playButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof ModpackModel) { setupPlayButtonText((ModpackModel) e.getSource(), userModel.getCurrentUser()); } else if (installer.isCurrentlyRunning()) { installer.cancel(); setupPlayButtonText(modpackSelector.getSelectedPack(), userModel.getCurrentUser()); } else { launchModpack(); } } }); modpackPanel.getDeleteButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(LauncherFrame.this, resources.getString("modpackoptions.delete.confirmtext"), resources.getString("modpackoptions.delete.confirmtitle"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { modpackSelector.getSelectedPack().delete(); modpackSelector.forceRefresh(); } } }); infoSwap = new JPanel(); infoLayout = new CardLayout(); infoSwap.setLayout(infoLayout); infoSwap.setOpaque(false); newsInfoPanel = new NewsInfoPanel(resources, avatarRepo); infoSwap.add(discoverInfoPanel, "discover"); JPanel newsHost = new JPanel(); infoSwap.add(newsHost, "news"); JPanel modpackHost = new JPanel(); infoSwap.add(modpackHost, "modpacks"); centralPanel.add(infoSwap, BorderLayout.CENTER); newsSelector = new NewsSelector(resources, newsInfoPanel, platformApi, avatarRepo, newsCircle, settings); newsHost.setLayout(new BorderLayout()); newsHost.add(newsInfoPanel, BorderLayout.CENTER); newsHost.add(newsSelector, BorderLayout.WEST); modpackHost.setLayout(new BorderLayout()); modpackHost.add(modpackPanel, BorderLayout.CENTER); modpackHost.add(modpackSelector, BorderLayout.WEST); footer = new TintablePanel(); footer.setTintColor(COLOR_CENTRAL_BACK); footer.setBackground(COLOR_FOOTER); footer.setLayout(new BoxLayout(footer, BoxLayout.LINE_AXIS)); footer.setForeground(COLOR_WHITE_TEXT); footer.setBorder(BorderFactory.createEmptyBorder(3, 6, 3, 12)); userWidget = new UserWidget(resources, skinRepository); userWidget.setMaximumSize(userWidget.getPreferredSize()); footer.add(userWidget); JLabel dashText = new JLabel("| "); dashText.setForeground(LauncherFrame.COLOR_WHITE_TEXT); dashText.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 15)); footer.add(dashText); JButton logout = new JButton(resources.getString("launcher.user.logout")); logout.setBorder(BorderFactory.createEmptyBorder()); logout.setContentAreaFilled(false); logout.setFocusable(false); logout.setForeground(LauncherFrame.COLOR_WHITE_TEXT); logout.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); logout.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 15)); logout.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { logout(); } }); footer.add(logout); installProgress = new ProgressBar(); installProgress.setForeground(Color.white); installProgress.setBackground(LauncherFrame.COLOR_GREEN); installProgress.setBorder(BorderFactory.createEmptyBorder(5, 45, 4, 45)); installProgress.setIcon(resources.getIcon("download_icon.png")); installProgress.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 12)); installProgress.setVisible(false); footer.add(installProgress); installProgressPlaceholder = Box.createHorizontalGlue(); footer.add(installProgressPlaceholder); JLabel buildCtrl = new JLabel(resources.getString("launcher.build.text", resources.getLauncherBuild(), resources.getString("launcher.build." + settings.getBuildStream()))); buildCtrl.setForeground(COLOR_WHITE_TEXT); buildCtrl.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 14)); buildCtrl.setHorizontalTextPosition(SwingConstants.RIGHT); buildCtrl.setHorizontalAlignment(SwingConstants.RIGHT); footer.add(buildCtrl); this.add(footer, BorderLayout.PAGE_END); }
From source file:org.eclim.installer.step.EclipsePluginsStep.java
@Override public void displayed() { setBusy(true);//w w w . j a va2 s .c om setPreviousEnabled(false); try { overallLabel.setText(""); overallProgress.setValue(0); taskLabel.setText(""); taskProgress.setValue(0); taskProgress.setIndeterminate(true); // handle step re-entry. if (featuresPanel != null) { stepPanel.remove(featuresPanel); } EclipseInfo info = (EclipseInfo) Installer.getContext().getValue("eclipse.info"); // find chosen features dependencies which need to be installed/upgraded. dependencies = unsatisfiedDependencies(info); if (dependencies.size() == 0) { overallProgress.setMaximum(1); overallProgress.setValue(1); overallLabel.setText("All third party plugins are up to date."); taskProgress.setMaximum(1); taskProgress.setValue(1); taskLabel.setText(""); } else { tableModel = new DefaultTableModel(); tableModel.addColumn("Feature"); tableModel.addColumn("Version"); tableModel.addColumn("Install / Upgrade"); JTable table = new JTable(tableModel); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setDefaultRenderer(Object.class, new DependencyCellRenderer()); table.getSelectionModel().addListSelectionListener(new DependencySelectionListener()); featuresPanel = new JPanel(new BorderLayout()); featuresPanel.setAlignmentX(0.0f); JPanel container = new JPanel(new BorderLayout()); container.add(table, BorderLayout.CENTER); JScrollPane scrollPane = new JScrollPane(container); scrollPane.setAlignmentX(0.0f); availableFeatures = loadAvailableFeatures(); for (Dependency dependency : dependencies) { String version = availableFeatures.get(dependency.getId()); String manual = ""; if (version == null) { manual = " (Manual)"; version = dependency.getRequiredVersion(); } tableModel.addRow(new Object[] { dependency.getId(), version, (dependency.isUpgrade() ? "Upgrade" : "Install") + manual, }); } JPanel buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0)); buttons.setAlignmentX(0.0f); JButton skipButton = new JButton(new SkipPluginsAction()); JButton installButton = new JButton(new InstallPluginsAction(skipButton)); buttons.add(installButton); buttons.add(skipButton); featuresPanel.add(scrollPane, BorderLayout.CENTER); featuresPanel.add(buttons, BorderLayout.SOUTH); stepPanel.add(featuresPanel); overallProgress.setValue(0); overallLabel.setText(""); taskProgress.setValue(0); taskLabel.setText(""); } } catch (Exception e) { setError(e); } finally { setValid(dependencies != null && dependencies.size() == 0); setBusy(false); setPreviousEnabled(true); taskProgress.setIndeterminate(false); } }
From source file:org.kepler.gui.ComponentLibraryPreferencesTab.java
/** * Initialize the top panel that contains controls for the table. *//*from ww w . ja va 2s . c o m*/ private void initTopPanel() { _newSource = new JButton(StaticResources.getDisplayString("general.ADD", "Add")); _newSource.setPreferredSize(new Dimension(100, 50)); _newSource.addActionListener(new AddSourceListener()); _removeSource = new JButton(StaticResources.getDisplayString("general.REMOVE", "Remove")); _removeSource.setPreferredSize(new Dimension(100, 50)); _removeSource.addActionListener(new RemoveSourceListener()); _defaultSources = new JButton(StaticResources.getDisplayString("preferences.useDefaults", "Use Defaults")); _defaultSources.setPreferredSize(new Dimension(100, 50)); _defaultSources.addActionListener(new DefaultSourcesListener()); _buildLibrary = new JButton(StaticResources.getDisplayString("preferences.build", "Build")); _buildLibrary.setPreferredSize(new Dimension(100, 50)); _buildLibrary.addActionListener(new BuildLibraryListener()); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); buttonPanel.setBackground(TabManager.BGCOLOR); buttonPanel.setAlignmentX(RIGHT_ALIGNMENT); buttonPanel.add(_newSource); buttonPanel.add(_removeSource); buttonPanel.add(_defaultSources); buttonPanel.add(_buildLibrary); LibraryManager lm = LibraryManager.getInstance(); JPanel topPanel = new JPanel(new BorderLayout()); topPanel.add(buttonPanel, BorderLayout.CENTER); add(topPanel); }
From source file:org.neuroph.netbeans.main.easyneurons.NeuralGraphRenderer.java
/** * @param jp//from w w w. j a va2 s. c o m * panel to which controls will be added */ protected void addControls(final JPanel jp) { final JPanel control_panel = new JPanel(); jp.add(control_panel, BorderLayout.EAST); control_panel.setLayout(new GridBagLayout()); java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 5); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; // control_panel.setBackground(new Color(00, 255, 00)); final Box vertex_panel = Box.createVerticalBox(); vertex_panel.setBorder(BorderFactory.createTitledBorder("Neurons")); final Box edge_panel = Box.createVerticalBox(); edge_panel.setBorder(BorderFactory.createTitledBorder("Connections")); final Box edges_and_vertex_panel = Box.createVerticalBox(); // Box zoom_and_mode_panel = Box.createVerticalBox(); // zoom_and_mode_panel.setBorder(BorderFactory.createTitledBorder("Other controls")); // final Box layout_panel = Box.createVerticalBox(); // layout_panel.setBorder(BorderFactory.createTitledBorder("Layout")); // JPanel zoom_and_mode_panel = new JPanel(); // zoom_and_mode_panel.setLayout(new GridBagLayout() ); // //GridLayout(3,1) // zoom_and_mode_panel.setBackground(new Color(0,255,0)); edges_and_vertex_panel.add(vertex_panel); edges_and_vertex_panel.add(edge_panel); // edges_and_vertex_panel.add(layout_panel); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; control_panel.add(edges_and_vertex_panel, gridBagConstraints); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; // control_panel.add(layout_panel, gridBagConstraints); // originalni layout // control_panel.add(vertex_panel, BorderLayout.WEST); // control_panel.add(edge_panel, BorderLayout.EAST); // control_panel.add(edges_and_vertex_panel, BorderLayout.CENTER); // set up vertex controls v_color = new JCheckBox("vertex seed coloring"); v_color.addActionListener(this); // v_stroke = new JCheckBox("<html>stroke highlight selected</html>"); // v_stroke.addActionListener(this); v_shape = new JCheckBox("vertex degree shapes"); v_shape.addActionListener(this); v_size = new JCheckBox("activation size"); v_size.addActionListener(this); v_size.setSelected(false); v_aspect = new JCheckBox("vertex degree ratio stretch"); v_aspect.addActionListener(this); v_small = new JCheckBox("filter vertices of degree < " + VertexDisplayPredicate.MIN_DEGREE); v_small.addActionListener(this); // vertex_panel.add(v_color); vertex_panel.add(v_labels); // vertex_panel.add(v_shape); vertex_panel.add(v_size); // vertex_panel.add(v_aspect); // vertex_panel.add(v_small); // vertex_panel.add(v_stroke); // set up edge controls // JPanel gradient_panel = new JPanel(new GridLayout(1, 0)); // gradient_panel.setBorder(BorderFactory.createTitledBorder("Edge paint")); // no_gradient = new JRadioButton("Solid color"); // no_gradient.addActionListener(this); // no_gradient.setSelected(true); // // gradient_absolute = new JRadioButton("Absolute gradient"); // // gradient_absolute.addActionListener(this); // gradient_relative = new JRadioButton("Gradient"); // gradient_relative.addActionListener(this); // ButtonGroup bg_grad = new ButtonGroup(); // bg_grad.add(no_gradient); // bg_grad.add(gradient_relative); // //bg_grad.add(gradient_absolute); // gradient_panel.add(no_gradient); // //gradientGrid.add(gradient_absolute); // gradient_panel.add(gradient_relative); // JPanel shape_panel = new JPanel(new GridLayout(3, 2)); // shape_panel.setBorder(BorderFactory // .createTitledBorder("Connection shape")); // e_line = new JRadioButton("line"); // e_line.addActionListener(this); // e_line.setSelected(true); // // e_bent = new JRadioButton("bent line"); // // e_bent.addActionListener(this); // e_wedge = new JRadioButton("wedge"); // e_wedge.addActionListener(this); // e_quad = new JRadioButton("quad curve"); // e_quad.addActionListener(this); // e_cubic = new JRadioButton("cubic curve"); // e_cubic.addActionListener(this); // ButtonGroup bg_shape = new ButtonGroup(); // bg_shape.add(e_line); // // bg.add(e_bent); // bg_shape.add(e_wedge); // bg_shape.add(e_quad); // bg_shape.add(e_cubic); // shape_panel.add(e_line); // // shape_panel.add(e_bent); // // shape_panel.add(e_wedge); // shape_panel.add(e_quad); // shape_panel.add(e_cubic); // // fill_edges = new JCheckBox("fill edge shapes"); // // fill_edges.setSelected(false); // // fill_edges.addActionListener(this); // // shape_panel.add(fill_edges); // shape_panel.setOpaque(true); e_color = new JCheckBox("weight highlighting"); e_color.addActionListener(this); e_uarrow_pred = new JCheckBox("undirected"); e_uarrow_pred.addActionListener(this); e_darrow_pred = new JCheckBox("directed"); e_darrow_pred.addActionListener(this); e_darrow_pred.setSelected(true); // JPanel arrow_panel = new JPanel(new GridLayout(1,0)); // arrow_panel.setBorder(BorderFactory.createTitledBorder("Show arrows")); // arrow_panel.add(e_uarrow_pred); // arrow_panel.add(e_darrow_pred); e_show_d = new JCheckBox("directed"); e_show_d.addActionListener(this); e_show_d.setSelected(true); e_show_u = new JCheckBox("undirected"); e_show_u.addActionListener(this); e_show_u.setSelected(true); JPanel show_edge_panel = new JPanel(new GridLayout(1, 0)); show_edge_panel.setBorder(BorderFactory.createTitledBorder("Show edges")); show_edge_panel.add(e_show_u); show_edge_panel.add(e_show_d); // shape_panel.setAlignmentX(Component.LEFT_ALIGNMENT); // edge_panel.add(shape_panel); // gradient_panel.setAlignmentX(Component.LEFT_ALIGNMENT); // edge_panel.add(gradient_panel); // show_edge_panel.setAlignmentX(Component.LEFT_ALIGNMENT); // edge_panel.add(show_edge_panel); // arrow_panel.setAlignmentX(Component.LEFT_ALIGNMENT); // edge_panel.add(arrow_panel); e_color.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(e_color); e_labels.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(e_labels); // Class<?>[] combos = getLayoutOptions(); // final JComboBox layoutCombo = new JComboBox(combos); // // use a renderer to shorten the layout name presentation // layoutCombo.setRenderer(new DefaultListCellRenderer() { // public Component getListCellRendererComponent(JList list, // Object value, int index, boolean isSelected, // boolean cellHasFocus) { // String valueString = value.toString(); // valueString = valueString.substring(valueString // .lastIndexOf('.') + 1); // return super.getListCellRendererComponent(list, valueString, // index, isSelected, cellHasFocus); // } // }); // layoutCombo.addActionListener(new LayoutChooser(layoutCombo, vv)); //// UNDO: layoutCombo.setSelectedItem(FRLayout.class); // layout_panel.add(layoutCombo); // set up zoom controls zoom_at_mouse = new JCheckBox("<html><center>zoom at mouse<p>(wheel only)</center></html>"); zoom_at_mouse.addActionListener(this); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JPanel zoomPanel = new JPanel(); zoomPanel.setAlignmentX(Component.RIGHT_ALIGNMENT); zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom")); zoomPanel.add(plus); zoomPanel.add(minus); gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 5); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.setAlignmentX(Component.RIGHT_ALIGNMENT); JPanel modePanel = new JPanel(new BorderLayout()) { @Override public Dimension getMaximumSize() { return getPreferredSize(); } }; modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; control_panel.add(modePanel, gridBagConstraints); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 3; control_panel.add(zoomPanel, gridBagConstraints); // add font control to center panel font = new JCheckBox("bold text"); font.addActionListener(this); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; control_panel.add(font, gridBagConstraints); }
From source file:pcgui.SetupVisualizationPanel.java
/** * Create the frame.//from w w w . j a va2 s. com * * @param switcher * * @param rootFrame */ public SetupVisualizationPanel(final PanelSwitcher switcher, JFrame rootFrame) { this.rootFrame = rootFrame; setLayout(new BorderLayout()); if (trackedVariables == null) { trackedVariables = new ArrayList<String>(); trackedVariables.add(""); } JLabel headingLabel = new JLabel("Setup Visualization"); headingLabel.setFont(new Font("Tahoma", Font.BOLD, 16)); add(headingLabel, BorderLayout.NORTH); JLabel chartTypeLabel = new JLabel("Chart Type"); chartTypeLabel.setPreferredSize(new Dimension(140, 30)); chartTypeCB = new JComboBox<String>(chartTypes); chartTypeCB.setPreferredSize(new Dimension(140, 30)); JLabel xAxisLabel = new JLabel("X Axis"); xAxisLabel.setPreferredSize(new Dimension(140, 30)); // xAxisTF = new JTextField(); // xAxisTF.setPreferredSize(new Dimension(100, 20)); xAxisCB = new JComboBox<String>(new DefaultComboBoxModel(trackedVariables.toArray())); xAxisCB.setPreferredSize(new Dimension(140, 30)); JLabel yAxisLabel = new JLabel("Y Axis"); yAxisLabel.setPreferredSize(new Dimension(140, 30)); // yAxisTF = new JTextField(); // yAxisTF.setPreferredSize(new Dimension(100, 20)); yAxisCB = new JComboBox<String>(new DefaultComboBoxModel(trackedVariables.toArray())); yAxisCB.setPreferredSize(new Dimension(140, 30)); JLabel iterationAsXLabel = new JLabel("Use Iteration Number as X Axis"); iterationAsXLabel.setPreferredSize(new Dimension(250, 30)); useIterationNumAsXChkBox = new JCheckBox("Use Iteration Count as X Axis"); useIterationNumAsXChkBox.setPreferredSize(new Dimension(250, 30)); addVisualizationBtn = new JButton("Add"); addVisualizationBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ArrayList<Object> visRow = new ArrayList<Object>(4); visRow.add(chartTypeCB.getSelectedItem()); visRow.add(xAxisCB.getSelectedItem()); visRow.add(yAxisCB.getSelectedItem()); visRow.add(useIterationNumAsXChkBox.isSelected()); visRow.add("");//for Delete model.addRow(visRow); } }); drawVisualizationBtn = new JButton("Draw Visualizations"); drawVisualizationBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ArrayList<ArrayList<Object>> visList = getVisualizationConfig(); boolean successOnCharts = true; for (ArrayList<Object> row : visList) { Visualization vis = new Visualization(); vis.setChartType((String) row.get(0)); vis.setXAxis((String) row.get(1)); vis.setYAxis((String) row.get(2)); vis.setUsingIterationNumAsX((boolean) row.get(3)); switch (vis.getChartType()) { case "LineChart": try { if (vis.isUsingIterationNumAsX()) { ModelSaver.drawLineChart(null, vis.getYAxis()); } else { ModelSaver.drawLineChart(vis.getXAxis(), vis.getYAxis()); } } catch (Exception exc) { successOnCharts = false; CustomErrorDialog.showDialog("Exception while drawing LineChart to Excel", exc.toString()); exc.printStackTrace(); } break; case "ScatterPlot": try { if (vis.isUsingIterationNumAsX()) { ModelSaver.drawScatterPlot(null, vis.getYAxis()); } else { ModelSaver.drawScatterPlot(vis.getXAxis(), vis.getYAxis()); } } catch (Exception exc) { successOnCharts = false; CustomErrorDialog.showDialog("Exception while drawing ScatterPlot to Excel", exc.toString()); exc.printStackTrace(); } break; case "BarChart": try { if (vis.isUsingIterationNumAsX()) { ModelSaver.drawBarChart(null, vis.getYAxis()); } else { ModelSaver.drawBarChart(vis.getXAxis(), vis.getYAxis()); } } catch (Exception exc) { successOnCharts = false; CustomErrorDialog.showDialog("Exception while drawing BarChart to Excel", exc.toString()); exc.printStackTrace(); } break; case "PieChart": try { if (vis.isUsingIterationNumAsX()) { ModelSaver.drawPieChart(null, vis.getYAxis()); } else { ModelSaver.drawPieChart(vis.getXAxis(), vis.getYAxis()); } } catch (Exception exc) { successOnCharts = false; CustomErrorDialog.showDialog("Exception while drawing PieChart to Excel", exc.toString()); exc.printStackTrace(); } break; } } if (successOnCharts) JOptionPane.showMessageDialog(new JFrame("Success"), "Visualization completed.\nOutput charts added to excel file : " + ModelSaver.excelFileName); } }); JPanel runConfig = new JPanel(); runConfig.setLayout(new GridLayout(3, 2)); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.CENTER; JPanel configLabel = new JPanel(new FlowLayout()); JPanel configCount = new JPanel(new FlowLayout()); JPanel configButtons = new JPanel(new FlowLayout()); configLabel.setAlignmentX(LEFT_ALIGNMENT); configLabel.add(chartTypeLabel); configLabel.add(xAxisLabel); configLabel.add(yAxisLabel); configLabel.add(iterationAsXLabel); configCount.setAlignmentX(LEFT_ALIGNMENT); configCount.add(chartTypeCB); configCount.add(xAxisCB); configCount.add(yAxisCB); configCount.add(useIterationNumAsXChkBox); configButtons.add(addVisualizationBtn); configButtons.add(drawVisualizationBtn); runConfig.add(configLabel); runConfig.add(configCount); runConfig.add(configButtons); add(runConfig, BorderLayout.SOUTH); setVisible(true); }
From source file:samples.graph.PluggableRendererDemo.java
/** * @param jp panel to which controls will be added *///w w w .jav a 2 s . c o m protected void addBottomControls(final JPanel jp) { final JPanel control_panel = new JPanel(); jp.add(control_panel, BorderLayout.SOUTH); control_panel.setLayout(new BorderLayout()); final Box vertex_panel = Box.createVerticalBox(); vertex_panel.setBorder(BorderFactory.createTitledBorder("Vertices")); final Box edge_panel = Box.createVerticalBox(); edge_panel.setBorder(BorderFactory.createTitledBorder("Edges")); final Box both_panel = Box.createVerticalBox(); control_panel.add(vertex_panel, BorderLayout.WEST); control_panel.add(edge_panel, BorderLayout.EAST); control_panel.add(both_panel, BorderLayout.CENTER); // set up vertex controls v_color = new JCheckBox("vertex seed coloring"); v_color.addActionListener(this); v_stroke = new JCheckBox("<html>vertex selection<p>stroke highlighting</html>"); v_stroke.addActionListener(this); v_labels = new JCheckBox("show vertex ranks (voltages)"); v_labels.addActionListener(this); v_shape = new JCheckBox("vertex degree shapes"); v_shape.addActionListener(this); v_size = new JCheckBox("vertex voltage size"); v_size.addActionListener(this); v_size.setSelected(true); v_aspect = new JCheckBox("vertex degree ratio stretch"); v_aspect.addActionListener(this); v_small = new JCheckBox("filter vertices of degree < " + VertexDisplayPredicate.MIN_DEGREE); v_small.addActionListener(this); vertex_panel.add(v_color); vertex_panel.add(v_stroke); vertex_panel.add(v_labels); vertex_panel.add(v_shape); vertex_panel.add(v_size); vertex_panel.add(v_aspect); vertex_panel.add(v_small); // set up edge controls JPanel gradient_panel = new JPanel(new GridLayout(1, 0)); gradient_panel.setBorder(BorderFactory.createTitledBorder("Edge paint")); no_gradient = new JRadioButton("Solid color"); no_gradient.addActionListener(this); no_gradient.setSelected(true); // gradient_absolute = new JRadioButton("Absolute gradient"); // gradient_absolute.addActionListener(this); gradient_relative = new JRadioButton("Gradient"); gradient_relative.addActionListener(this); ButtonGroup bg_grad = new ButtonGroup(); bg_grad.add(no_gradient); bg_grad.add(gradient_relative); //bg_grad.add(gradient_absolute); gradient_panel.add(no_gradient); //gradientGrid.add(gradient_absolute); gradient_panel.add(gradient_relative); JPanel shape_panel = new JPanel(new GridLayout(3, 2)); shape_panel.setBorder(BorderFactory.createTitledBorder("Edge shape")); e_line = new JRadioButton("line"); e_line.addActionListener(this); e_line.setSelected(true); // e_bent = new JRadioButton("bent line"); // e_bent.addActionListener(this); e_wedge = new JRadioButton("wedge"); e_wedge.addActionListener(this); e_quad = new JRadioButton("quad curve"); e_quad.addActionListener(this); e_cubic = new JRadioButton("cubic curve"); e_cubic.addActionListener(this); ButtonGroup bg_shape = new ButtonGroup(); bg_shape.add(e_line); // bg.add(e_bent); bg_shape.add(e_wedge); bg_shape.add(e_quad); bg_shape.add(e_cubic); shape_panel.add(e_line); // shape_panel.add(e_bent); shape_panel.add(e_wedge); shape_panel.add(e_quad); shape_panel.add(e_cubic); fill_edges = new JCheckBox("fill edge shapes"); fill_edges.setSelected(false); fill_edges.addActionListener(this); shape_panel.add(fill_edges); shape_panel.setOpaque(true); e_color = new JCheckBox("edge weight highlighting"); e_color.addActionListener(this); e_labels = new JCheckBox("show edge weights"); e_labels.addActionListener(this); e_uarrow_pred = new JCheckBox("undirected"); e_uarrow_pred.addActionListener(this); e_darrow_pred = new JCheckBox("directed"); e_darrow_pred.addActionListener(this); e_darrow_pred.setSelected(true); JPanel arrow_panel = new JPanel(new GridLayout(1, 0)); arrow_panel.setBorder(BorderFactory.createTitledBorder("Show arrows")); arrow_panel.add(e_uarrow_pred); arrow_panel.add(e_darrow_pred); e_show_d = new JCheckBox("directed"); e_show_d.addActionListener(this); e_show_d.setSelected(true); e_show_u = new JCheckBox("undirected"); e_show_u.addActionListener(this); e_show_u.setSelected(true); JPanel show_edge_panel = new JPanel(new GridLayout(1, 0)); show_edge_panel.setBorder(BorderFactory.createTitledBorder("Show edges")); show_edge_panel.add(e_show_u); show_edge_panel.add(e_show_d); shape_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(shape_panel); gradient_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(gradient_panel); show_edge_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(show_edge_panel); arrow_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(arrow_panel); e_color.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(e_color); e_labels.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(e_labels); // set up zoom controls zoom_at_mouse = new JCheckBox("<html><center>zoom at mouse<p>(wheel only)</center></html>"); zoom_at_mouse.addActionListener(this); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); Box zoomPanel = Box.createVerticalBox(); zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom")); plus.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(plus); minus.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(minus); zoom_at_mouse.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(zoom_at_mouse); // add font and zoom controls to center panel font = new JCheckBox("bold text"); font.addActionListener(this); font.setAlignmentX(Component.CENTER_ALIGNMENT); both_panel.add(zoomPanel); both_panel.add(font); JComboBox modeBox = gm.getModeComboBox(); modeBox.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel modePanel = new JPanel(new BorderLayout()) { public Dimension getMaximumSize() { return getPreferredSize(); } }; modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); both_panel.add(modePanel); }