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:com.google.code.facebook.graph.sna.applet.RadialTreeLensDemo.java
/** * create an instance of a simple graph with controls to * demo the zoomand hyperbolic features. * //w ww .jav a2 s . com */ public RadialTreeLensDemo() { // create a simple graph for the demo // create a simple graph for the demo graph = new DelegateForest<String, Integer>(); createTree(); layout = new TreeLayout<String, Integer>(graph); radialLayout = new RadialTreeLayout<String, Integer>(graph); radialLayout.setSize(new Dimension(600, 600)); Dimension preferredSize = new Dimension(600, 600); final VisualizationModel<String, Integer> visualizationModel = new DefaultVisualizationModel<String, Integer>( radialLayout, preferredSize); vv = new VisualizationViewer<String, Integer>(visualizationModel, preferredSize); PickedState<String> ps = vv.getPickedVertexState(); PickedState<Integer> pes = vv.getPickedEdgeState(); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(ps, Color.red, Color.yellow)); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Integer>(pes, Color.black, Color.cyan)); vv.setBackground(Color.white); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>()); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<String>()); Container content = getContentPane(); GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv); content.add(gzsp); /** * the regular graph mouse for the normal view */ final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); rings = new Rings(); vv.addPreRenderPaintable(rings); hyperbolicViewSupport = new ViewLensSupport<String, Integer>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); 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()); } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); JMenuBar menubar = new JMenuBar(); menubar.add(graphMouse.getModeMenu()); gzsp.setCorner(menubar); JPanel controls = new JPanel(); JPanel zoomControls = new JPanel(new GridLayout(2, 1)); zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel hyperControls = new JPanel(new GridLayout(3, 2)); hyperControls.setBorder(BorderFactory.createTitledBorder("Examiner Lens")); zoomControls.add(plus); zoomControls.add(minus); JPanel modeControls = new JPanel(new BorderLayout()); modeControls.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modeControls.add(graphMouse.getModeComboBox()); hyperControls.add(hyperView); controls.add(zoomControls); controls.add(hyperControls); controls.add(modeControls); content.add(controls, BorderLayout.SOUTH); }
From source file:com.sshtools.common.ui.SshToolsConnectionKerberosTab.java
/** * Creates a new SshToolsConnectionKerberosTab object. *//*from w ww . ja v a 2s .c o m*/ public SshToolsConnectionKerberosTab() { super(); // Create the main connection details panel JPanel mainConnectionDetailsPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.insets = new Insets(0, 2, 2, 2); // enabled option //gbc.fill = GridBagConstraints.NONE; useKerberos = new JCheckBox("Use MyProxy Kerberos support"); UIUtil.jGridBagAdd(mainConnectionDetailsPanel, useKerberos, gbc, GridBagConstraints.REMAINDER); // Host name UIUtil.jGridBagAdd(mainConnectionDetailsPanel, new JLabel("Hostname"), gbc, GridBagConstraints.REMAINDER); //gbc.fill = GridBagConstraints.HORIZONTAL; UIUtil.jGridBagAdd(mainConnectionDetailsPanel, jTextHostname, gbc, GridBagConstraints.REMAINDER); //gbc.fill = GridBagConstraints.NONE; // Username UIUtil.jGridBagAdd(mainConnectionDetailsPanel, new JLabel("Username"), gbc, GridBagConstraints.REMAINDER); //gbc.fill = GridBagConstraints.HORIZONTAL; UIUtil.jGridBagAdd(mainConnectionDetailsPanel, jTextUsername, gbc, GridBagConstraints.REMAINDER); JPanel settingsPanel = new JPanel(new GridBagLayout()); settingsPanel .setBorder(BorderFactory.createTitledBorder("Settings if krb5.conf or krb5.ini file not found: ")); GridBagConstraints gbc2 = new GridBagConstraints(); gbc2.fill = GridBagConstraints.HORIZONTAL; gbc2.anchor = GridBagConstraints.NORTHWEST; gbc2.insets = new Insets(0, 2, 2, 2); gbc2.weightx = 1.0; // realm UIUtil.jGridBagAdd(settingsPanel, new JLabel("Realm"), gbc2, GridBagConstraints.REMAINDER); gbc2.fill = GridBagConstraints.HORIZONTAL; UIUtil.jGridBagAdd(settingsPanel, jTextRealm, gbc2, GridBagConstraints.REMAINDER); gbc2.fill = GridBagConstraints.NONE; // kdc UIUtil.jGridBagAdd(settingsPanel, new JLabel("KDC"), gbc2, GridBagConstraints.REMAINDER); gbc2.fill = GridBagConstraints.HORIZONTAL; gbc2.weighty = 1.0; UIUtil.jGridBagAdd(settingsPanel, jTextKDC, gbc2, GridBagConstraints.REMAINDER); gbc2.fill = GridBagConstraints.NONE; // gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.insets = new Insets(4, 2, 2, 2); UIUtil.jGridBagAdd(mainConnectionDetailsPanel, settingsPanel, gbc, GridBagConstraints.REMAINDER); IconWrapperPanel iconMainConnectionDetailsPanel = new IconWrapperPanel( new ResourceIcon(SshToolsConnectionHostTab.class, AUTH_ICON), mainConnectionDetailsPanel); setLayout(new GridBagLayout()); setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(2, 2, 2, 2); gbc.weightx = 1.0; gbc.weighty = 1.0; UIUtil.jGridBagAdd(this, iconMainConnectionDetailsPanel, gbc, GridBagConstraints.REMAINDER); }
From source file:edu.uci.ics.jung.samples.RadialTreeLensDemo.java
/** * create an instance of a simple graph with controls to * demo the zoomand hyperbolic features. * /*from w w w . jav a 2 s .c o m*/ */ @SuppressWarnings({ "unchecked", "rawtypes" }) public RadialTreeLensDemo() { // create a simple graph for the demo // create a simple graph for the demo graph = new DelegateForest<String, Integer>(); createTree(); layout = new TreeLayout<String, Integer>(graph); radialLayout = new RadialTreeLayout<String, Integer>(graph); radialLayout.setSize(new Dimension(600, 600)); Dimension preferredSize = new Dimension(600, 600); final VisualizationModel<String, Integer> visualizationModel = new DefaultVisualizationModel<String, Integer>( radialLayout, preferredSize); vv = new VisualizationViewer<String, Integer>(visualizationModel, preferredSize); PickedState<String> ps = vv.getPickedVertexState(); PickedState<Integer> pes = vv.getPickedEdgeState(); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(ps, Color.red, Color.yellow)); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Integer>(pes, Color.black, Color.cyan)); vv.setBackground(Color.white); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>()); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<String>()); Container content = getContentPane(); GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv); content.add(gzsp); /** * the regular graph mouse for the normal view */ final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); rings = new Rings(); vv.addPreRenderPaintable(rings); hyperbolicViewSupport = new ViewLensSupport<String, Integer>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); 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()); } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); JMenuBar menubar = new JMenuBar(); menubar.add(graphMouse.getModeMenu()); gzsp.setCorner(menubar); JPanel controls = new JPanel(); JPanel zoomControls = new JPanel(new GridLayout(2, 1)); zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel hyperControls = new JPanel(new GridLayout(3, 2)); hyperControls.setBorder(BorderFactory.createTitledBorder("Examiner Lens")); zoomControls.add(plus); zoomControls.add(minus); JPanel modeControls = new JPanel(new BorderLayout()); modeControls.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modeControls.add(graphMouse.getModeComboBox()); hyperControls.add(hyperView); controls.add(zoomControls); controls.add(hyperControls); controls.add(modeControls); content.add(controls, BorderLayout.SOUTH); }
From source file:SimpleSoundCapture.java
public SimpleSoundCapture() { setLayout(new BorderLayout()); EmptyBorder eb = new EmptyBorder(5, 5, 5, 5); SoftBevelBorder sbb = new SoftBevelBorder(SoftBevelBorder.LOWERED); setBorder(new EmptyBorder(5, 5, 5, 5)); JPanel p1 = new JPanel(); p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS)); JPanel p2 = new JPanel(); p2.setBorder(sbb); p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS)); JPanel buttonsPanel = new JPanel(); buttonsPanel.setBorder(new EmptyBorder(10, 0, 5, 0)); playB = addButton("Play", buttonsPanel, false); captB = addButton("Record", buttonsPanel, true); p2.add(buttonsPanel);// w ww . j a v a 2s.co m p1.add(p2); add(p1); }
From source file:AlternateAppearanceBoundsTest.java
JPanel createBoundsPanel() { JPanel panel = new JPanel(); panel.setBorder(new TitledBorder("Scopes")); String boundsValues[] = { "Tiny Bounds", "Small Bounds", "Big Bounds" }; boundsType = new JComboBox(boundsValues); boundsType.addActionListener(this); boundsType.setSelectedIndex(2);/* ww w . j a va 2 s. c om*/ panel.add(new JLabel("Bounds")); panel.add(boundsType); useBoundingLeaf = new JCheckBox("Enable BoundingLeaf", boundingLeafOn); useBoundingLeaf.addActionListener(this); panel.add(useBoundingLeaf); override = new JCheckBox("Enable App Override", false); override.addActionListener(this); panel.add(override); return panel; }
From source file:com.floreantpos.actions.ClockInOutAction.java
@Override public void execute() { final User user = PasswordEntryDialog.getUser(Application.getPosWindow(), Messages.getString("ClockInOutAction.3")); //$NON-NLS-1$ if (user == null) { return;/*from ww w . j av a 2s. com*/ } final POSDialog dialog = new POSDialog(Application.getPosWindow(), true); dialog.setTitle(Messages.getString("ClockInOutAction.4")); //$NON-NLS-1$ PosButton btnClockIn = new PosButton(Messages.getString("ClockInOutAction.5")); //$NON-NLS-1$ btnClockIn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); performClockIn(user); } }); PosButton btnClockOut = new PosButton(Messages.getString("ClockInOutAction.6")); //$NON-NLS-1$ btnClockOut.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); performClockOut(user); } }); PosButton btnDriverIn = new PosButton("DRIVER IN"); //$NON-NLS-1$ btnDriverIn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); performDriverIn(user); } }); PosButton btnDriverOut = new PosButton("DRIVER OUT"); //$NON-NLS-1$ btnDriverOut.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); performDriverOut(user); } }); PosButton btnCancel = new PosButton(Messages.getString("ClockInOutAction.7")); //$NON-NLS-1$ btnCancel.setPreferredSize(new Dimension(150, 120)); btnCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }); JPanel contentPane = (JPanel) dialog.getContentPane(); contentPane.setBorder(new EmptyBorder(10, 10, 10, 10)); contentPane.setLayout(new GridLayout(1, 0, 10, 10)); if (user.isClockedIn()) { contentPane.add(btnClockOut); } else { contentPane.add(btnClockIn); } if (user.isDriver()) { if (user.isClockedIn()) { if (user.isAvailableForDelivery()) { contentPane.add(btnDriverOut); } else { contentPane.add(btnDriverIn); } } } contentPane.add(btnCancel); dialog.pack(); dialog.open(); }
From source file:com.game.ui.views.CharachterEditorPanel.java
public void doGui() { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JLabel noteLbl = new JLabel("Pls select a value to choose an enemy or you can create a new " + "Enemy entity below. Once selected an Enemy character, its' details will be available below"); noteLbl.setAlignmentX(0);//w w w. j a v a 2s . com // noteLbl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(noteLbl); DefaultComboBoxModel model = new DefaultComboBoxModel(); for (GameCharacter character : GameBean.enemyDetails) { System.out.println(character.getName()); model.addElement(character.getName()); } comboBox = new JComboBox(model); comboBox.setSelectedIndex(-1); comboBox.setMaximumSize(new Dimension(100, 30)); comboBox.setAlignmentX(0); comboBox.setActionCommand("dropDown"); comboBox.addActionListener(this); add(Box.createVerticalStrut(10)); add(comboBox); add(Box.createVerticalStrut(10)); JPanel panel1 = new JPanel(); panel1.setAlignmentX(0); panel1.setBorder(LineBorder.createGrayLineBorder()); panel1.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(5, 5, 5, 5); c.weightx = 1; c.weighty = 1; c.gridwidth = 2; JLabel enemyDtlLbl = new JLabel("Enemy Character Details : "); enemyDtlLbl.setFont(new Font("Times New Roman", Font.BOLD, 15)); panel1.add(enemyDtlLbl, c); c.gridwidth = 1; c.gridy = 1; JLabel nameLbl = new JLabel("Name : "); panel1.add(nameLbl, c); c.gridx = 1; JTextField name = new JTextField(""); name.setColumns(20); panel1.add(name, c); c.gridx = 0; c.gridy = 2; JLabel imageLbl = new JLabel("Image Path : "); panel1.add(imageLbl, c); c.gridx = 1; JTextField image = new JTextField(""); image.setColumns(20); panel1.add(image, c); c.gridx = 0; c.gridy = 3; JLabel healthLbl = new JLabel("Health Pts : "); panel1.add(healthLbl, c); c.gridx = 1; JTextField health = new JTextField(""); health.setColumns(20); panel1.add(health, c); c.gridx = 0; c.gridy = 4; JLabel attackPtsLbl = new JLabel("Attack Points : "); panel1.add(attackPtsLbl, c); c.gridx = 1; JTextField attackPts = new JTextField(""); attackPts.setColumns(20); panel1.add(attackPts, c); c.gridx = 0; c.gridy = 5; JLabel armoursPtsLbl = new JLabel("Armour Points : "); panel1.add(armoursPtsLbl, c); c.gridx = 1; JTextField armourPts = new JTextField(""); armourPts.setColumns(20); panel1.add(armourPts, c); c.gridx = 0; c.gridy = 6; JLabel attackRngeLbl = new JLabel("Attack Range : "); panel1.add(attackRngeLbl, c); c.gridx = 1; JTextField attackRnge = new JTextField(""); attackRnge.setColumns(20); panel1.add(attackRnge, c); c.gridx = 0; c.gridy = 7; JLabel movementLbl = new JLabel("Movement : "); panel1.add(movementLbl, c); c.gridx = 1; JTextField movement = new JTextField(""); movement.setColumns(20); panel1.add(movement, c); c.gridx = 0; c.gridy = 8; c.gridwidth = 2; JButton submit = new JButton("Save"); submit.addActionListener(this); submit.setActionCommand("button"); panel1.add(submit, c); add(panel1); c.gridx = 0; c.gridy = 9; JLabel validationMess = new JLabel("Pls enter all the fields or pls choose a character from the drop down"); validationMess.setForeground(Color.red); validationMess.setVisible(false); add(validationMess, c); add(Box.createVerticalGlue()); }
From source file:edu.cornell.mannlib.vitro.webapp.controller.freemarker.ImageUploaderThumbnailerTester_2.java
private Component createImagePanel(CropData cropData) { RenderedOp image = createCroppedImage(cropData); Set<String> blackSides = checkBlackEdges(image); if (!blackSides.isEmpty()) { log.warn("edges at " + cropData + ", " + blackSides); }/*ww w . java 2 s . c om*/ 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 ImageCanvas(image)); p.setBackground(new Color(0xFFFFFF)); p.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); return p; }
From source file:eu.europeana.sip.gui.SipCreatorGUI.java
private Component createFilterPanel() { JPanel p = new JPanel(new BorderLayout()); p.setBorder(BorderFactory.createTitledBorder("Filter")); filterTimer = new Timer(300, new ActionListener() { @Override/*from w ww . j av a2 s.c om*/ public void actionPerformed(ActionEvent actionEvent) { dataSetList.clearSelection(); dataSetListModel.setPattern(filter.getText()); } }); filterTimer.setRepeats(false); filter.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent documentEvent) { filterTimer.restart(); } @Override public void removeUpdate(DocumentEvent documentEvent) { filterTimer.restart(); } @Override public void changedUpdate(DocumentEvent documentEvent) { filterTimer.restart(); } }); p.add(filter, BorderLayout.CENTER); return p; }
From source file:FocusTraversalDemo.java
public FocusTraversalDemo() { super(new BorderLayout()); newPolicy = new MyOwnFocusTraversalPolicy(); tf1 = new JTextField("Field 1"); tf2 = new JTextField("A Bigger Field 2"); tf3 = new JTextField("Field 3"); tf4 = new JTextField("A Bigger Field 4"); tf5 = new JTextField("Field 5"); tf6 = new JTextField("A Bigger Field 6"); table = new JTable(4, 3); togglePolicy = new JCheckBox("Custom FocusTraversalPolicy"); togglePolicy.setActionCommand("toggle"); togglePolicy.addActionListener(this); togglePolicy.setFocusable(false); //Remove it from the focus cycle. //Note that HTML is allowed and will break this run of text //across two lines. label = new JLabel( "<html>Use Tab (or Shift-Tab) to navigate from component to component.<p>Control-Tab (or Control-Shift-Tab) allows you to break out of the JTable.</html>"); JPanel leftTextPanel = new JPanel(new GridLayout(3, 2)); leftTextPanel.add(tf1, BorderLayout.PAGE_START); leftTextPanel.add(tf3, BorderLayout.CENTER); leftTextPanel.add(tf5, BorderLayout.PAGE_END); leftTextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5)); JPanel rightTextPanel = new JPanel(new GridLayout(3, 2)); rightTextPanel.add(tf2, BorderLayout.PAGE_START); rightTextPanel.add(tf4, BorderLayout.CENTER); rightTextPanel.add(tf6, BorderLayout.PAGE_END); rightTextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5)); JPanel tablePanel = new JPanel(new GridLayout(0, 1)); tablePanel.add(table, BorderLayout.CENTER); tablePanel.setBorder(BorderFactory.createEtchedBorder()); JPanel bottomPanel = new JPanel(new GridLayout(2, 1)); bottomPanel.add(togglePolicy, BorderLayout.PAGE_START); bottomPanel.add(label, BorderLayout.PAGE_END); add(leftTextPanel, BorderLayout.LINE_START); add(rightTextPanel, BorderLayout.CENTER); add(tablePanel, BorderLayout.LINE_END); add(bottomPanel, BorderLayout.PAGE_END); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }