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:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.analysis.diagnostics.ApproximationSetViewer.java
/** * Lays out the components on this window. This method is invoked by the * constructor, and should not be invoked again. *//*from w w w .jav a 2 s. com*/ protected void layoutComponents() { setLayout(new BorderLayout()); JPanel buttonPane = new JPanel(new FlowLayout(FlowLayout.CENTER)); buttonPane.add(useInitialBounds); buttonPane.add(useReferenceSetBounds); buttonPane.add(useDynamicBounds); buttonPane.add(useZoomBounds); JPanel objectivePane = new JPanel(new FlowLayout(FlowLayout.CENTER)); objectivePane.add(new JLabel(localization.getString("text.xAxis"))); objectivePane.add(xAxisSelection); objectivePane.add(new JLabel(localization.getString("text.yAxis"))); objectivePane.add(yAxisSelection); JPanel controlPane = new JPanel(new GridLayout(3, 1)); controlPane.add(slider); controlPane.add(buttonPane); controlPane.add(objectivePane); JPanel rightPane = new JPanel(new BorderLayout()); rightPane.add(chartContainer, BorderLayout.CENTER); rightPane.add(controlPane, BorderLayout.SOUTH); JPanel leftPane = new JPanel(new BorderLayout()); leftPane.setBorder(BorderFactory.createTitledBorder(localization.getString("text.seeds"))); leftPane.add(new JScrollPane(seedList), BorderLayout.CENTER); leftPane.add(selectAll, BorderLayout.SOUTH); leftPane.setMinimumSize(new Dimension(100, 100)); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPane, rightPane); add(splitPane, BorderLayout.CENTER); }
From source file:net.aepik.alasca.gui.util.LoadFileFrame.java
/** * Initialize frame content.//ww w. j ava 2 s .c o m */ private void initFrame() { // - Panel bouton du bas - JPanel boutonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); boutonsPanel.add(boutonOk); boutonsPanel.add(boutonAnnuler); // - Panel nom du fichier - JTextArea textAreaFilename = new JTextArea( "Indiquez le nom du fichier contenant les dfinitions du schma LDAP que vous souhaitez charger."); textAreaFilename.setEditable(false); textAreaFilename.setLineWrap(true); textAreaFilename.setWrapStyleWord(true); textAreaFilename.setFont((new JLabel()).getFont()); textAreaFilename.setBorder(BorderFactory.createEmptyBorder(7, 6, 12, 6)); textAreaFilename.setBackground(new Color(240, 235, 226)); boutonOpenFile.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createMatteBorder(0, 5, 0, 0, boutonsPanel.getBackground()), boutonOpenFile.getBorder())); JPanel filenamePanel = new JPanel(new BorderLayout()); filenamePanel.add(textAreaFilename, BorderLayout.NORTH); filenamePanel.add(filename, BorderLayout.CENTER); filenamePanel.add(boutonOpenFile, BorderLayout.EAST); filenamePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 4, 1, 4), BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(" Schma LDAP "), BorderFactory.createEmptyBorder(0, 5, 5, 5)))); // - Panel du selecteur de syntaxes - JTextArea textAreaSyntaxes = new JTextArea( "Il vous faut appliquer un filtre sur le schma que vous voulez charger. Voici la liste des filtres disponibles :"); textAreaSyntaxes.setEditable(false); textAreaSyntaxes.setLineWrap(true); textAreaSyntaxes.setWrapStyleWord(true); textAreaSyntaxes.setFont((new JLabel()).getFont()); textAreaSyntaxes.setBorder(BorderFactory.createEmptyBorder(7, 6, 12, 6)); textAreaSyntaxes.setBackground(new Color(240, 235, 226)); JPanel syntaxesPanel = new JPanel(new BorderLayout()); syntaxesPanel.add(textAreaSyntaxes, BorderLayout.NORTH); syntaxesPanel.add(syntaxes); syntaxesPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 4, 1, 4), BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(" Syntaxe LDAP "), BorderFactory.createEmptyBorder(0, 5, 5, 5)))); // On injecte le nom des classes de syntaxes possibles // dynamiquement. String[] syntaxesName = Schema.getSyntaxeNames(); for (int i = 0; syntaxesName != null && i < syntaxesName.length; i++) { syntaxes.addItem(syntaxesName[i]); } // - Organisation gnrale - JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(filenamePanel, BorderLayout.NORTH); mainPanel.add(syntaxesPanel, BorderLayout.CENTER); JPanel mainPanelContainer = new JPanel(new BorderLayout()); mainPanelContainer.add(mainPanel, BorderLayout.NORTH); mainPanelContainer.add(boutonsPanel, BorderLayout.SOUTH); mainPanelContainer.setBorder(BorderFactory.createEmptyBorder(2, 1, 1, 1)); getContentPane().add(new DescriptiveInternalFrame(mainFrame.getIconImage(), "Slectionner un fichier et sa syntaxe.", mainPanelContainer)); // - Listeners - addWindowListener(this); boutonOpenFile.addActionListener(this); boutonOk.addActionListener(this); boutonAnnuler.addActionListener(this); }
From source file:com.game.ui.views.ItemPanel.java
public void doCommonStuffForContent() { JPanel panel1 = new JPanel(); panel1.setAlignmentX(0);/*from www .java 2 s . c o m*/ panel1.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel1.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new Insets(5, 5, 5, 5); c.weightx = 1; c.weighty = 0.2; c.gridwidth = 2; JLabel dtlLbl = new JLabel(type + "Details : "); dtlLbl.setFont(new Font("Times New Roman", Font.BOLD, 15)); panel1.add(dtlLbl, 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); if (ringPanel) { createComponentsForRing(panel1, c); } else if (armourPanel) { createComponentsForArmour(panel1, c); } else if (potionPanel) { createComponentsForPotion(panel1, c); } else if (treasurePanel) { createComponentsForTreasure(panel1, c); } c.gridx = 0; c.gridy = c.gridy + 1; c.gridwidth = 2; JButton submit = new JButton("Save"); submit.addActionListener(this); submit.setActionCommand("button"); panel1.add(submit, c); c.gridx = 0; c.gridy = c.gridy + 1; c.gridwidth = 2; c.weighty = 0; c.weightx = 1; validationMess = new JLabel("Pls enter all the fields or pls choose a " + type + " from the drop down"); validationMess.setForeground(Color.red); validationMess.setVisible(false); panel1.add(validationMess, c); c.gridy++; c.weighty = 1; c.weightx = 1; panel1.add(new JPanel(), c); panel1.setBorder(LineBorder.createGrayLineBorder()); add(panel1); add(Box.createVerticalGlue()); }
From source file:edu.uci.ics.jung.samples.PerspectiveTransformerDemo.java
/** * create an instance of a simple graph with controls to * demo the zoom and perspective features. * /*from www.j a va 2 s . co m*/ */ @SuppressWarnings("serial") public PerspectiveTransformerDemo() { // create a simple graph for the demo graph = TestGraphs.getOneComponentGraph(); graphLayout = new FRLayout<String, Number>(graph); ((FRLayout<String, Number>) graphLayout).setMaxIterations(1000); Dimension preferredSize = new Dimension(600, 600); Map<String, Point2D> map = new HashMap<String, Point2D>(); Transformer<String, Point2D> vlf = TransformerUtils.mapTransformer(map); grid = this.generateVertexGrid(map, preferredSize, 25); gridLayout = new StaticLayout<String, Number>(grid, vlf, preferredSize); final VisualizationModel<String, Number> visualizationModel = new DefaultVisualizationModel<String, Number>( graphLayout, preferredSize); vv = new VisualizationViewer<String, Number>(visualizationModel, preferredSize); PickedState<Number> pes = vv.getPickedEdgeState(); vv.getRenderContext() .setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.red)); vv.getRenderContext().setVertexShapeTransformer(new Transformer<String, Shape>() { public Shape transform(String v) { return new Rectangle2D.Float(-10, -10, 20, 20); } }); vv.setBackground(Color.white); // 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<Number, Number> graphMouse = new DefaultModalGraphMouse<Number, Number>(); vv.setGraphMouse(graphMouse); viewSupport = new PerspectiveViewTransformSupport<String, Number>(vv); layoutSupport = new PerspectiveLayoutTransformSupport<String, Number>(vv); 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, 0.9f, vv.getCenter()); } }); final JSlider horizontalSlider = new JSlider(-120, 120, 0) { /* (non-Javadoc) * @see javax.swing.JComponent#getPreferredSize() */ @Override public Dimension getPreferredSize() { return new Dimension(80, super.getPreferredSize().height); } }; final JSlider verticalSlider = new JSlider(-120, 120, 0) { /* (non-Javadoc) * @see javax.swing.JComponent#getPreferredSize() */ @Override public Dimension getPreferredSize() { return new Dimension(super.getPreferredSize().width, 80); } }; verticalSlider.setOrientation(JSlider.VERTICAL); final ChangeListener changeListener = new ChangeListener() { public void stateChanged(ChangeEvent e) { int vval = -verticalSlider.getValue(); int hval = horizontalSlider.getValue(); Dimension d = vv.getSize(); PerspectiveTransform pt = null; pt = PerspectiveTransform.getQuadToQuad(vval, hval, d.width - vval, -hval, d.width + vval, d.height + hval, -vval, d.height - hval, 0, 0, d.width, 0, d.width, d.height, 0, d.height); viewSupport.getPerspectiveTransformer().setPerspectiveTransform(pt); layoutSupport.getPerspectiveTransformer().setPerspectiveTransform(pt); vv.repaint(); } }; horizontalSlider.addChangeListener(changeListener); verticalSlider.addChangeListener(changeListener); JPanel perspectivePanel = new JPanel(new BorderLayout()); JPanel perspectiveCenterPanel = new JPanel(new BorderLayout()); perspectivePanel.setBorder(BorderFactory.createTitledBorder("Perspective Controls")); final JButton center = new JButton("Center"); center.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { horizontalSlider.setValue(0); verticalSlider.setValue(0); } }); ButtonGroup radio = new ButtonGroup(); JRadioButton normal = new JRadioButton("None"); normal.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean selected = e.getStateChange() == ItemEvent.SELECTED; if (selected) { if (viewSupport != null) { viewSupport.deactivate(); } if (layoutSupport != null) { layoutSupport.deactivate(); } } center.setEnabled(!selected); horizontalSlider.setEnabled(!selected); verticalSlider.setEnabled(!selected); } }); final JRadioButton perspectiveView = new JRadioButton("In View"); perspectiveView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { viewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton perspectiveModel = new JRadioButton("In Layout"); perspectiveModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { layoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); radio.add(normal); radio.add(perspectiveModel); radio.add(perspectiveView); normal.setSelected(true); ButtonGroup graphRadio = new ButtonGroup(); JRadioButton graphButton = new JRadioButton("Graph"); graphButton.setSelected(true); graphButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { visualizationModel.setGraphLayout(graphLayout); vv.repaint(); } } }); JRadioButton gridButton = new JRadioButton("Grid"); gridButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { visualizationModel.setGraphLayout(gridLayout); vv.repaint(); } } }); graphRadio.add(graphButton); graphRadio.add(gridButton); JPanel modePanel = new JPanel(new GridLayout(2, 1)); modePanel.setBorder(BorderFactory.createTitledBorder("Display")); modePanel.add(graphButton); modePanel.add(gridButton); JMenuBar menubar = new JMenuBar(); menubar.add(graphMouse.getModeMenu()); gzsp.setCorner(menubar); Container controls = new JPanel(new BorderLayout()); JPanel zoomControls = new JPanel(new GridLayout(2, 1)); zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel perspectiveControls = new JPanel(new GridLayout(3, 1)); zoomControls.add(plus); zoomControls.add(minus); perspectiveControls.add(normal); perspectiveControls.add(perspectiveModel); perspectiveControls.add(perspectiveView); controls.add(zoomControls, BorderLayout.WEST); controls.add(modePanel); perspectivePanel.add(perspectiveControls, BorderLayout.WEST); perspectiveCenterPanel.add(horizontalSlider, BorderLayout.SOUTH); perspectivePanel.add(verticalSlider, BorderLayout.EAST); perspectiveCenterPanel.add(center); perspectivePanel.add(perspectiveCenterPanel); controls.add(perspectivePanel, BorderLayout.EAST); content.add(controls, BorderLayout.SOUTH); }
From source file:components.ListDemo.java
public ListDemo() { super(new BorderLayout()); listModel = new DefaultListModel(); listModel.addElement("Jane Doe"); listModel.addElement("John Smith"); listModel.addElement("Kathy Green"); //Create the list and put it in a scroll pane. list = new JList(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0);// w w w .j ava2 s. c o m list.addListSelectionListener(this); list.setVisibleRowCount(5); JScrollPane listScrollPane = new JScrollPane(list); JButton hireButton = new JButton(hireString); HireListener hireListener = new HireListener(hireButton); hireButton.setActionCommand(hireString); hireButton.addActionListener(hireListener); hireButton.setEnabled(false); fireButton = new JButton(fireString); fireButton.setActionCommand(fireString); fireButton.addActionListener(new FireListener()); employeeName = new JTextField(10); employeeName.addActionListener(hireListener); employeeName.getDocument().addDocumentListener(hireListener); String name = listModel.getElementAt(list.getSelectedIndex()).toString(); //Create a panel that uses BoxLayout. JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); buttonPane.add(fireButton); buttonPane.add(Box.createHorizontalStrut(5)); buttonPane.add(new JSeparator(SwingConstants.VERTICAL)); buttonPane.add(Box.createHorizontalStrut(5)); buttonPane.add(employeeName); buttonPane.add(hireButton); buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(listScrollPane, BorderLayout.CENTER); add(buttonPane, BorderLayout.PAGE_END); }
From source file:com.employee.scheduler.common.swingui.SolverAndPersistenceFrame.java
private JPanel createScorePanel() { JPanel scorePanel = new JPanel(new BorderLayout()); scorePanel.setBorder(BorderFactory.createEtchedBorder()); showConstraintMatchesDialogAction = new ShowConstraintMatchesDialogAction(); showConstraintMatchesDialogAction.setEnabled(false); scorePanel.add(new JButton(showConstraintMatchesDialogAction), BorderLayout.WEST); scoreField = new JTextField("Score:"); scoreField.setEditable(false);// w w w . j av a 2 s . c om scoreField.setForeground(Color.BLACK); scoreField.setBorder(BorderFactory.createLoweredBevelBorder()); scorePanel.add(scoreField, BorderLayout.CENTER); refreshScreenDuringSolvingCheckBox = new JCheckBox("Refresh screen during solving", solutionPanel.isRefreshScreenDuringSolving()); scorePanel.add(refreshScreenDuringSolvingCheckBox, BorderLayout.EAST); return scorePanel; }
From source file:com.google.code.facebook.graph.sna.applet.VertexCollapseDemoWithLayouts.java
public VertexCollapseDemoWithLayouts() { // create a simple graph for the demo graph = TestGraphs.getOneComponentGraph(); collapsedGraph = graph;/*from w w w.j a va2s .c o m*/ collapser = new GraphCollapser(graph); layout = new FRLayout(graph); Dimension preferredSize = new Dimension(400, 400); final VisualizationModel visualizationModel = new DefaultVisualizationModel(layout, preferredSize); vv = new VisualizationViewer(visualizationModel, preferredSize); vv.getRenderContext().setVertexShapeTransformer(new ClusterVertexShapeFunction()); final PredicatedParallelEdgeIndexFunction eif = PredicatedParallelEdgeIndexFunction.getInstance(); final Set exclusions = new HashSet(); eif.setPredicate(new Predicate() { public boolean evaluate(Object e) { return exclusions.contains(e); } }); vv.getRenderContext().setParallelEdgeIndexFunction(eif); vv.setBackground(Color.white); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller() { /* (non-Javadoc) * @see edu.uci.ics.jung.visualization.decorators.DefaultToolTipFunction#getToolTipText(java.lang.Object) */ @Override public String transform(Object v) { if (v instanceof Graph) { return ((Graph) v).getVertices().toString(); } return super.transform(v); } }); /** * the regular graph mouse for the normal view */ final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); Container content = getContentPane(); GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv); content.add(gzsp); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(graphMouse.getModeListener()); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); 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()); } }); JButton collapse = new JButton("Collapse"); collapse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Collection picked = new HashSet(vv.getPickedVertexState().getPicked()); if (picked.size() > 1) { Graph inGraph = layout.getGraph(); Graph clusterGraph = collapser.getClusterGraph(inGraph, picked); Graph g = collapser.collapse(layout.getGraph(), clusterGraph); collapsedGraph = g; double sumx = 0; double sumy = 0; for (Object v : picked) { Point2D p = (Point2D) layout.transform(v); sumx += p.getX(); sumy += p.getY(); } Point2D cp = new Point2D.Double(sumx / picked.size(), sumy / picked.size()); vv.getRenderContext().getParallelEdgeIndexFunction().reset(); layout.setGraph(g); layout.setLocation(clusterGraph, cp); vv.getPickedVertexState().clear(); vv.repaint(); } } }); JButton compressEdges = new JButton("Compress Edges"); compressEdges.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Collection picked = vv.getPickedVertexState().getPicked(); if (picked.size() == 2) { Pair pair = new Pair(picked); Graph graph = layout.getGraph(); Collection edges = new HashSet(graph.getIncidentEdges(pair.getFirst())); edges.retainAll(graph.getIncidentEdges(pair.getSecond())); exclusions.addAll(edges); vv.repaint(); } } }); JButton expandEdges = new JButton("Expand Edges"); expandEdges.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Collection picked = vv.getPickedVertexState().getPicked(); if (picked.size() == 2) { Pair pair = new Pair(picked); Graph graph = layout.getGraph(); Collection edges = new HashSet(graph.getIncidentEdges(pair.getFirst())); edges.retainAll(graph.getIncidentEdges(pair.getSecond())); exclusions.removeAll(edges); vv.repaint(); } } }); JButton expand = new JButton("Expand"); expand.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Collection picked = new HashSet(vv.getPickedVertexState().getPicked()); for (Object v : picked) { if (v instanceof Graph) { Graph g = collapser.expand(layout.getGraph(), (Graph) v); vv.getRenderContext().getParallelEdgeIndexFunction().reset(); layout.setGraph(g); } vv.getPickedVertexState().clear(); vv.repaint(); } } }); JButton reset = new JButton("Reset"); reset.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { layout.setGraph(graph); exclusions.clear(); vv.repaint(); } }); JButton help = new JButton("Help"); help.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog((JComponent) e.getSource(), instructions, "Help", JOptionPane.PLAIN_MESSAGE); } }); Class[] combos = getCombos(); final JComboBox jcb = new JComboBox(combos); // use a renderer to shorten the layout name presentation jcb.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); } }); jcb.addActionListener(new LayoutChooser(jcb, vv)); jcb.setSelectedItem(FRLayout.class); JPanel controls = new JPanel(); JPanel zoomControls = new JPanel(new GridLayout(2, 1)); zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom")); zoomControls.add(plus); zoomControls.add(minus); controls.add(zoomControls); JPanel collapseControls = new JPanel(new GridLayout(3, 1)); collapseControls.setBorder(BorderFactory.createTitledBorder("Picked")); collapseControls.add(collapse); collapseControls.add(expand); collapseControls.add(compressEdges); collapseControls.add(expandEdges); collapseControls.add(reset); controls.add(collapseControls); controls.add(modeBox); controls.add(help); controls.add(jcb); content.add(controls, BorderLayout.SOUTH); }
From source file:llc.rockford.webcast.EC2Driver.java
public Component createComponents() { startButton = new JButton("START SERVER"); startButton.setEnabled(false);// www. ja v a2 s . co m startButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { startButton.setEnabled(false); stopButton.setEnabled(false); new StartInstanceWorker(ec2Handle.getEc2Handle(), applicationState, amazonProperties).execute(); } }); startStreamButton = new JButton("START BROADCAST"); startStreamButton.setEnabled(false); startStreamButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { startStreamButton.setEnabled(false); stopStreamButton.setEnabled(true); try { broadcaster.start(); } catch (ExecuteException e1) { startStreamButton.setEnabled(true); e1.printStackTrace(); } catch (IOException e1) { startStreamButton.setEnabled(true); e1.printStackTrace(); } catch (InterruptedException e1) { e1.printStackTrace(); } } }); stopStreamButton = new JButton("STOP BROADCAST"); stopStreamButton.setEnabled(false); stopStreamButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { broadcaster.stop(); } }); statusLabel.setHorizontalAlignment(SwingConstants.CENTER); statusLabel.setOpaque(true); statusLabel.setBackground(Color.YELLOW); broadcastStatusLabel.setHorizontalAlignment(SwingConstants.CENTER); broadcastStatusLabel.setOpaque(true); broadcastStatusLabel.setBackground(Color.RED); stopButton = new JButton("STOP SERVER"); stopButton.setEnabled(false); stopButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { startButton.setEnabled(false); stopButton.setEnabled(false); new TerminateInstanceWorker(ec2Handle.getEc2Handle(), applicationState, amazonProperties).execute(); } }); JPanel pane = new JPanel(new GridLayout(7, 1)); pane.add(startButton); pane.add(statusLabel); pane.add(stopButton); pane.add(new JSeparator(SwingConstants.HORIZONTAL)); pane.add(startStreamButton); pane.add(broadcastStatusLabel); pane.add(stopStreamButton); pane.setBorder(BorderFactory.createEmptyBorder(30, // top 30, // left 10, // bottom 30) // right ); return pane; }
From source file:de.tud.kom.p2psim.impl.skynet.visualization.MetricsPlot.java
private JPanel createRadioBoxes(boolean enable) { JPanel rbPanel = new JPanel(new FlowLayout()); rbPanel.add(setJRadioButton("Min-Values", enable)); rbPanel.add(setJRadioButton("Max-Values", enable)); rbPanel.add(setJRadioButton("Standard-Deviation", enable)); setSizeOfComponent(rbPanel, new Dimension(plotWidth, boxOffset)); rbPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); return rbPanel; }
From source file:me.childintime.childintime.ui.window.tool.BmiToolDialog.java
/** * Build the UI.//from ww w. j av a2 s.c o m */ private void buildUi() { // Set the layout setLayout(new BorderLayout()); // Create a grid bag constraints configuration GridBagConstraints c = new GridBagConstraints(); // Create the container and body state panel final JPanel container = new JPanel(new GridBagLayout()); container.setBorder(BorderFactory.createEmptyBorder(16, 16, 16, 16)); // Add the close button c.fill = GridBagConstraints.NONE; c.gridx = 0; c.gridy = 0; c.weightx = 0; c.weighty = 0; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(0, 0, 0, 0); container.add(new JLabel("Select a student to see their details."), c); // Add the body state panel to the container c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridy = 1; c.weightx = 1; c.weighty = 1; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(16, 0, 0, 0); container.add(buildUiBodyStatePanel(), c); // Create the close button final JButton closeButton = new JButton("Close"); closeButton.addActionListener(e -> dispose()); // Add the close button c.fill = GridBagConstraints.NONE; c.gridx = 0; c.gridy = 2; c.weightx = 0; c.weighty = 0; c.anchor = GridBagConstraints.EAST; c.insets = new Insets(8, 0, 0, 0); container.add(closeButton, c); // Add the container add(container, BorderLayout.CENTER); }