List of usage examples for javax.swing JPanel setBorder
@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.") public void setBorder(Border border)
From source file:mergedoc.ui.MergeDocFrame.java
/** * ??????// ww w. ja v a 2s . com * @throws MergeDocException ????? */ private void initComponent() throws MergeDocException { // ???? preferencePanel = new PreferencePanel(); mergeManager = new MergeManager(); // ??? mainPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.X_AXIS)); mainPanel.add(preferencePanel); // ?????? JPanel outerPanel = new JPanel(); outerPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); outerPanel.setLayout(new BoxLayout(outerPanel, BoxLayout.Y_AXIS)); outerPanel.add(mainPanel); outerPanel.add(ComponentFactory.createSpacer(0, 7)); outerPanel.add(buttonBar); getContentPane().add(outerPanel); // ? initListener(); buttonBar.setState(buttonBar.INIT_STATE); // ConfigManager config = ConfigManager.getInstance(); String iconPath = config.getFile("icon.png").toString(); Image icon = Toolkit.getDefaultToolkit().createImage(iconPath); setIconImage(icon); // setTitle(SETTING_TITLE); Persister psst = Persister.getInstance(); setLocation(psst.getInt(Persister.WINDOW_X, 0), psst.getInt(Persister.WINDOW_Y, 0)); setSize(psst.getInt(Persister.WINDOW_WIDTH, 700), psst.getInt(Persister.WINDOW_HEIGHT, 570)); int state = psst.getInt(Persister.WINDOW_STATE, NORMAL); if ((state & Frame.ICONIFIED) != ICONIFIED) { setExtendedState(state); } setVisible(true); }
From source file:com.google.code.facebook.graph.sna.applet.BalloonLayoutDemo.java
public BalloonLayoutDemo() { // create a simple graph for the demo graph = new DelegateForest<String, Integer>(); createTree();//from w ww. j ava 2s.co m layout = new TreeLayout<String, Integer>(graph); radialLayout = new BalloonLayout<String, Integer>(graph); radialLayout.setSize(new Dimension(900, 900)); vv = new VisualizationViewer<String, Integer>(layout, new Dimension(600, 600)); vv.setBackground(Color.white); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray)); rings = new Rings(radialLayout); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); hyperbolicViewSupport = new ViewLensSupport<String, Integer>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(graphMouse.getModeListener()); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); final ScalingControl scaler = new CrossoverScalingControl(); vv.scaleToLayout(scaler); 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()); } }); JToggleButton radial = new JToggleButton("Balloon"); radial.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, layout, radialLayout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity(); vv.addPreRenderPaintable(rings); } else { LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, radialLayout, layout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity(); vv.removePreRenderPaintable(rings); } vv.repaint(); } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(radial); controls.add(scaleGrid); controls.add(modeBox); controls.add(hyperView); content.add(controls, BorderLayout.SOUTH); }
From source file:edu.cornell.mannlib.vitro.webapp.imageprocessor.jai.JaiImageProcessorTester2.java
private Component createImagePanel(CropData cropData) { RenderedOp image = createCroppedImage(cropData); Set<String> blackSides = checkBlackEdges(image); if (!blackSides.isEmpty()) { log.warn("edges at " + cropData + ", " + blackSides); }/*w w w. ja v a 2 s . c o m*/ String legend = "left=" + cropData.left + ", top=" + cropData.top + ", size=" + cropData.size; Label l = new Label(); l.setAlignment(Label.CENTER); if (!blackSides.isEmpty()) { l.setBackground(new Color(0xFFDDDD)); legend += " " + blackSides; } l.setText(legend); JPanel p = new JPanel(); p.setLayout(new BorderLayout()); p.add("South", l); p.add("Center", new javax.media.jai.widget.ImageCanvas(image)); p.setBackground(new Color(0xFFFFFF)); p.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); return p; }
From source file:edu.uci.ics.jung.samples.BalloonLayoutDemo.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public BalloonLayoutDemo() { // create a simple graph for the demo graph = new DelegateForest<String, Integer>(); createTree();/*from ww w .ja v a 2s . co m*/ layout = new TreeLayout<String, Integer>(graph); radialLayout = new BalloonLayout<String, Integer>(graph); radialLayout.setSize(new Dimension(900, 900)); vv = new VisualizationViewer<String, Integer>(layout, new Dimension(600, 600)); vv.setBackground(Color.white); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray)); rings = new Rings(radialLayout); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); hyperbolicViewSupport = new ViewLensSupport<String, Integer>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(graphMouse.getModeListener()); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); final ScalingControl scaler = new CrossoverScalingControl(); vv.scaleToLayout(scaler); 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()); } }); JToggleButton radial = new JToggleButton("Balloon"); radial.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, layout, radialLayout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity(); vv.addPreRenderPaintable(rings); } else { LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, radialLayout, layout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity(); vv.removePreRenderPaintable(rings); } vv.repaint(); } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(radial); controls.add(scaleGrid); controls.add(modeBox); controls.add(hyperView); content.add(controls, BorderLayout.SOUTH); }
From source file:com.intel.stl.ui.monitor.view.PSPortsDetailsPanel.java
protected JPanel createDeviceTypePanel() { JPanel panel = new JPanel(); panel.setOpaque(false);// ww w.ja v a2s . c o m panel.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2)); GridBagLayout gridBag = new GridBagLayout(); panel.setLayout(gridBag); GridBagConstraints gc = new GridBagConstraints(); gc.insets = new Insets(8, 2, 2, 2); gc.weighty = 0; gc.weightx = 1; gc.gridwidth = GridBagConstraints.REMAINDER; gc.gridheight = 1; deviceTypeChartPanel = new ChartPanel(null); deviceTypeChartPanel.setPreferredSize(new Dimension(80, 60)); panel.add(deviceTypeChartPanel, gc); typeNumberLabels = new JLabel[nodeTypes.length]; typeNameLabels = new JLabel[nodeTypes.length]; gc.fill = GridBagConstraints.BOTH; gc.insets = new Insets(2, 2, 2, 2); for (int i = 0; i < nodeTypes.length; i++) { gc.weightx = 1; gc.gridwidth = 1; typeNumberLabels[i] = createNumberLabel(); panel.add(typeNumberLabels[i], gc); gc.weightx = 0; gc.gridwidth = GridBagConstraints.REMAINDER; typeNameLabels[i] = createNameLabel(nodeTypes[i].getName()); panel.add(typeNameLabels[i], gc); } return panel; }
From source file:com.intel.stl.ui.monitor.view.PSPortsDetailsPanel.java
protected JPanel createFlowTypePanel() { JPanel panel = new JPanel(); panel.setOpaque(false);//from ww w.j ava 2 s . c o m panel.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2)); GridBagLayout gridBag = new GridBagLayout(); panel.setLayout(gridBag); GridBagConstraints gc = new GridBagConstraints(); gc.insets = new Insets(8, 2, 2, 2); gc.weighty = 0; gc.weightx = 1; gc.gridwidth = GridBagConstraints.REMAINDER; gc.gridheight = 1; flowTypeChartPanel = new ChartPanel(null); flowTypeChartPanel.setPreferredSize(new Dimension(80, 60)); panel.add(flowTypeChartPanel, gc); flowNumberLabels = new JLabel[flowTypes.length]; flowNameLabels = new JLabel[flowTypes.length]; gc.fill = GridBagConstraints.BOTH; gc.insets = new Insets(2, 2, 2, 2); for (int i = 0; i < flowTypes.length; i++) { gc.weightx = 1; gc.gridwidth = 1; flowNumberLabels[i] = createNumberLabel(); panel.add(flowNumberLabels[i], gc); gc.weightx = 0; gc.gridwidth = GridBagConstraints.REMAINDER; flowNameLabels[i] = createNameLabel(flowTypes[i].getName()); panel.add(flowNameLabels[i], gc); } return panel; }
From source file:de.codesourcery.jasm16.ide.ui.views.ProjectConfigurationView.java
@Override protected JPanel getPanel() { final JPanel result = new JPanel(); result.setLayout(new GridBagLayout()); // project name int y = 0;/*from w w w . j ava 2s . c o m*/ GridBagConstraints cnstrs = constraints(0, y, false, false, GridBagConstraints.NONE); result.add(new JLabel("Project name"), cnstrs); cnstrs = constraints(1, y++, true, false, GridBagConstraints.NONE); result.add(projectName, cnstrs); // build options panel final JPanel buildOptionsPanel = new JPanel(); buildOptionsPanel.setLayout(new GridBagLayout()); buildOptionsPanel.setBorder(BorderFactory.createTitledBorder("Build options")); cnstrs = constraints(0, 0, false, false, GridBagConstraints.NONE); buildOptionsPanel.add(new JLabel("Compilation root"), cnstrs); cnstrs = constraints(1, 0, false, false, GridBagConstraints.NONE); compilationRootName.setEditable(false); compilationRootName.setColumns(25); buildOptionsPanel.add(compilationRootName, cnstrs); cnstrs = constraints(2, 0, true, false, GridBagConstraints.NONE); buildOptionsPanel.add(compilationRootButton, cnstrs); compilationRootButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JFileChooser chooser; File baseDir = null; if (project != null) { baseDir = project.getConfiguration().getBaseDirectory(); } if (StringUtils.isNotBlank(compilationRootName.getText())) { File tmp = new File(compilationRootName.getText()).getParentFile(); if (tmp.exists() && tmp.isDirectory()) { baseDir = tmp; } } if (baseDir != null) { chooser = new JFileChooser(baseDir); } else { chooser = new JFileChooser(); } final int result = chooser.showOpenDialog(null); if (result == JFileChooser.APPROVE_OPTION && chooser.getSelectedFile().isFile()) { compilationRootName.setText(chooser.getSelectedFile().getAbsolutePath()); } } }); // generate self-relocating code ? cnstrs = constraints(0, 1, false, false, GridBagConstraints.NONE); buildOptionsPanel.add(new JLabel("Generate self-relocating code?"), cnstrs); cnstrs = constraints(1, 1, true, true, GridBagConstraints.NONE); cnstrs.gridwidth = 2; buildOptionsPanel.add(generateSelfRelocatingCode, cnstrs); // inline short literals ? cnstrs = constraints(0, 2, false, false, GridBagConstraints.NONE); buildOptionsPanel.add(new JLabel("Inline short literals?"), cnstrs); cnstrs = constraints(1, 2, true, true, GridBagConstraints.NONE); cnstrs.gridwidth = 2; buildOptionsPanel.add(inlineShortLiterals, cnstrs); // add build options panel to parent cnstrs = constraints(0, y++, true, false, GridBagConstraints.BOTH); cnstrs.gridwidth = 2; result.add(buildOptionsPanel, cnstrs); // buttons final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridBagLayout()); cnstrs = constraints(0, 0, false, false, GridBagConstraints.NONE); buttonPanel.add(saveButton, cnstrs); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (hasValidInput()) { onSave(); } } }); cnstrs = constraints(1, 0, true, true, GridBagConstraints.NONE); buttonPanel.add(cancelButton, cnstrs); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { onCancel(); } }); // button panel cnstrs = constraints(0, y++, true, true, GridBagConstraints.NONE); cnstrs.gridwidth = 2; result.add(buttonPanel, cnstrs); return result; }
From source file:DragFileDemo.java
public DragFileDemo() { super(new BorderLayout()); fc = new JFileChooser(); ;//from ww w . j av a 2 s . c om fc.setMultiSelectionEnabled(true); fc.setDragEnabled(true); fc.setControlButtonsAreShown(false); JPanel fcPanel = new JPanel(new BorderLayout()); fcPanel.add(fc, BorderLayout.CENTER); clear = new JButton("Clear All"); clear.addActionListener(this); JPanel buttonPanel = new JPanel(new BorderLayout()); buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); buttonPanel.add(clear, BorderLayout.LINE_END); JPanel upperPanel = new JPanel(new BorderLayout()); upperPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); upperPanel.add(fcPanel, BorderLayout.CENTER); upperPanel.add(buttonPanel, BorderLayout.PAGE_END); //The TabbedPaneController manages the panel that //contains the tabbed pane. When there are no files //the panel contains a plain text area. Then, as //files are dropped onto the area, the tabbed panel //replaces the file area. JTabbedPane tabbedPane = new JTabbedPane(); JPanel tabPanel = new JPanel(new BorderLayout()); tabPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); tpc = new TabbedPaneController(tabbedPane, tabPanel); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, upperPanel, tabPanel); splitPane.setDividerLocation(400); splitPane.setPreferredSize(new Dimension(530, 650)); add(splitPane, BorderLayout.CENTER); }
From source file:drusy.ui.panels.SwitchStatePanel.java
private void addUser(String hostName, String information, long txBytes, long rxBytes) { JPanel panel = new JPanel(); JLabel informationLabel = new JLabel(); ImageIcon imageIcon;//from ww w . j ava 2 s. co m //======== panel1 ======== { panel.setLayout(new BorderLayout()); panel.setBorder(new EmptyBorder(0, 10, 0, 10)); //---- label2 ---- if (hostName.equals("smartphone")) { imageIcon = Res.getImage("img/iphone-56.png"); } else { imageIcon = Res.getImage("img/mac-56.png"); } informationLabel.setIcon(imageIcon); informationLabel.setText("<html><b>" + information + "</b><br />Download: " + txBytes / 1000.0 + " ko/s <br />Upload: " + rxBytes / 1000.0 + " ko/s</html>"); informationLabel.setHorizontalAlignment(SwingConstants.CENTER); panel.add(informationLabel, BorderLayout.CENTER); } mainPanel.add(panel); adaptPanelSize(); users.add(panel); }
From source file:net.sf.firemox.ui.wizard.Wizard.java
/** * Create a new instance of this class.//from w ww.j a v a 2s . c o m * * @param ability * ability to associate to this ability. If this ability has an * associated picture, it will be used instead of given picture. * Ability's name is also used to fill the title. This ability will * be used to restart this wizard in case of Background button is * used. * @param title * the title of this wizard. * @param description * the description appended to the title of this wizard. This content * will be displayed as Html. * @param iconName * the icon's name to display on the top right place. * @param width * the preferred width. * @param height * the preferred height. */ public Wizard(Ability ability, String title, String description, String iconName, int width, int height) { super(MagicUIComponents.magicForm, StringUtils.capitalize(title), true); getRootPane().setPreferredSize(new Dimension(width, 300)); getRootPane().setMinimumSize(new Dimension(width, height)); setSize(new Dimension(width, height)); // center gameParamPanel = new JPanel(null); gameParamPanel.setLayout(new BoxLayout(gameParamPanel, BoxLayout.Y_AXIS)); if (ability == null) getContentPane().add(new WizardTitle(new WizardImageIcon((Image) null, iconName), description), BorderLayout.NORTH); else getContentPane().add(new WizardTitle(new WizardImageIcon(ability.getCard(), iconName), description), BorderLayout.NORTH); getContentPane().add(gameParamPanel, BorderLayout.CENTER); getContentPane().add(new JPanel(), BorderLayout.EAST); // bottom final JPanel abstractButtonPanel = new JPanel(new BorderLayout()); this.buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); this.ability = ability; abstractButtonPanel.setBorder(null); abstractButtonPanel.add(new JSeparator(), BorderLayout.NORTH); abstractButtonPanel.add(buttonPanel, BorderLayout.CENTER); abstractButtonPanel.add(wizardInfo, BorderLayout.SOUTH); getContentPane().add(abstractButtonPanel, BorderLayout.SOUTH); setLocationRelativeTo(null); }