List of usage examples for javax.swing JPanel add
public Component add(String name, Component comp)
From source file:com.intuit.tank.tools.debugger.PanelBuilder.java
/** * @param debuggerActions// w w w . j a va 2 s .c o m * @return */ static Component createTopPanel(ActionComponents actionComponents) { JPanel topPanel = new JPanel(new BorderLayout()); JToolBar toolbaBar = actionComponents.getToolBar(); topPanel.add(BorderLayout.NORTH, toolbaBar); return topPanel; }
From source file:max.hubbard.Factoring.Graphing.java
public static void makeGraphingInterface() { Interface.mainInterface();/* w ww .ja va 2s .co m*/ panel = new JPanel(new BorderLayout(3, 225)); JPanel pan = new JPanel(); JLabel area = new JLabel("Graphing"); area.setBackground(Color.lightGray); area.setFont(new Font("Times New Roman", Font.BOLD, 20)); pan.add(area, BorderLayout.CENTER); panel.add(pan, BorderLayout.NORTH); final JTextField field = new JTextField(); panel.add(field, BorderLayout.CENTER); field.setFont(new Font("Times New Roman", Font.BOLD, 25)); field.setText("x^4-2x^2-8"); JButton start = new JButton("GO!"); start.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { panel.updateUI(); Main.label.setText(""); graph(field.getText()); } }); panel.add(start, BorderLayout.SOUTH); Main.getFrame().add(panel, BorderLayout.EAST); Main.getFrame().pack(); }
From source file:MainClass.java
public static JPanel demo1() { JPanel pan = new JPanel(new BorderLayout()); pan.setBorder(new TitledBorder("change format midstream")); MaskFormatter lowercase = null; try {/* w ww . j a v a 2s .c o m*/ lowercase = new MaskFormatter("LLLL"); } catch (ParseException pe) { } final JFormattedTextField field = new JFormattedTextField(lowercase); field.setValue("lower case"); pan.add(field, BorderLayout.CENTER); final JButton change = new JButton("change format"); JPanel changePanel = new JPanel(); changePanel.add(change); pan.add(changePanel, BorderLayout.SOUTH); change.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { try { field.commitEdit(); MaskFormatter uppercase = new MaskFormatter("UUUU"); DefaultFormatterFactory factory = new DefaultFormatterFactory(uppercase); field.setFormatterFactory(factory); change.setEnabled(false); } catch (ParseException pe) { } } }); return pan; }
From source file:cimat.tesis.sna.visualization.ShowLayouts.java
private static JPanel getGraphPanel() { g_array = (Graph<? extends Object, ? extends Object>[]) new Graph<?, ?>[graph_names.length]; Factory<Graph<Integer, Number>> graphFactory = new Factory<Graph<Integer, Number>>() { public Graph<Integer, Number> create() { return new SparseMultigraph<Integer, Number>(); }/*from w ww . j a v a2 s. c om*/ }; Factory<Integer> vertexFactory = new Factory<Integer>() { int count; public Integer create() { return count++; } }; Factory<Number> edgeFactory = new Factory<Number>() { int count; public Number create() { return count++; } }; g_array[0] = TestGraphs.createTestGraph(false); g_array[1] = MixedRandomGraphGenerator.generateMixedRandomGraph(graphFactory, vertexFactory, edgeFactory, new HashMap<Number, Number>(), 20, true, new HashSet<Integer>()); g_array[2] = TestGraphs.getDemoGraph(); g_array[3] = TestGraphs.createDirectedAcyclicGraph(4, 4, 0.3); g_array[4] = TestGraphs.getOneComponentGraph(); g_array[5] = TestGraphs.createChainPlusIsolates(18, 5); g_array[6] = TestGraphs.createChainPlusIsolates(0, 20); Graph<? extends Object, ? extends Object> g = g_array[4]; // initial graph final VisualizationViewer<Integer, Number> vv = new VisualizationViewer<Integer, Number>(new FRLayout(g)); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<Integer>(vv.getPickedVertexState(), Color.red, Color.yellow)); final DefaultModalGraphMouse<Integer, Number> graphMouse = new DefaultModalGraphMouse<Integer, Number>(); vv.setGraphMouse(graphMouse); 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 reset = new JButton("reset"); reset.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Layout<Integer, Number> layout = vv.getGraphLayout(); layout.initialize(); Relaxer relaxer = vv.getModel().getRelaxer(); if (relaxer != null) { // if(layout instanceof IterativeContext) { relaxer.stop(); relaxer.prerelax(); relaxer.relax(); } } }); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(((DefaultModalGraphMouse<Integer, Number>) vv.getGraphMouse()).getModeListener()); JPanel jp = new JPanel(); jp.setBackground(Color.WHITE); jp.setLayout(new BorderLayout()); jp.add(vv, BorderLayout.CENTER); 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 control_panel = new JPanel(new GridLayout(2, 1)); JPanel topControls = new JPanel(); JPanel bottomControls = new JPanel(); control_panel.add(topControls); control_panel.add(bottomControls); jp.add(control_panel, BorderLayout.NORTH); final JComboBox graph_chooser = new JComboBox(graph_names); graph_chooser.addActionListener(new GraphChooser(jcb)); topControls.add(jcb); topControls.add(graph_chooser); bottomControls.add(plus); bottomControls.add(minus); bottomControls.add(modeBox); bottomControls.add(reset); return jp; }
From source file:edu.uci.ics.jung.samples.ShowLayouts.java
@SuppressWarnings({ "rawtypes", "unchecked" }) private static JPanel getGraphPanel() { g_array = (Graph<? extends Object, ? extends Object>[]) new Graph<?, ?>[graph_names.length]; Factory<Graph<Integer, Number>> graphFactory = new Factory<Graph<Integer, Number>>() { public Graph<Integer, Number> create() { return new SparseMultigraph<Integer, Number>(); }/*from w w w . j a v a 2 s.c o m*/ }; Factory<Integer> vertexFactory = new Factory<Integer>() { int count; public Integer create() { return count++; } }; Factory<Number> edgeFactory = new Factory<Number>() { int count; public Number create() { return count++; } }; g_array[0] = TestGraphs.createTestGraph(false); g_array[1] = MixedRandomGraphGenerator.generateMixedRandomGraph(graphFactory, vertexFactory, edgeFactory, new HashMap<Number, Number>(), 20, true, new HashSet<Integer>()); g_array[2] = TestGraphs.getDemoGraph(); g_array[3] = TestGraphs.createDirectedAcyclicGraph(4, 4, 0.3); g_array[4] = TestGraphs.getOneComponentGraph(); g_array[5] = TestGraphs.createChainPlusIsolates(18, 5); g_array[6] = TestGraphs.createChainPlusIsolates(0, 20); Graph<? extends Object, ? extends Object> g = g_array[4]; // initial graph final VisualizationViewer<Integer, Number> vv = new VisualizationViewer<Integer, Number>(new FRLayout(g)); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<Integer>(vv.getPickedVertexState(), Color.red, Color.yellow)); final DefaultModalGraphMouse<Integer, Number> graphMouse = new DefaultModalGraphMouse<Integer, Number>(); vv.setGraphMouse(graphMouse); 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 reset = new JButton("reset"); reset.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Layout<Integer, Number> layout = vv.getGraphLayout(); layout.initialize(); Relaxer relaxer = vv.getModel().getRelaxer(); if (relaxer != null) { // if(layout instanceof IterativeContext) { relaxer.stop(); relaxer.prerelax(); relaxer.relax(); } } }); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(((DefaultModalGraphMouse<Integer, Number>) vv.getGraphMouse()).getModeListener()); JPanel jp = new JPanel(); jp.setBackground(Color.WHITE); jp.setLayout(new BorderLayout()); jp.add(vv, BorderLayout.CENTER); 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 control_panel = new JPanel(new GridLayout(2, 1)); JPanel topControls = new JPanel(); JPanel bottomControls = new JPanel(); control_panel.add(topControls); control_panel.add(bottomControls); jp.add(control_panel, BorderLayout.NORTH); final JComboBox graph_chooser = new JComboBox(graph_names); graph_chooser.addActionListener(new GraphChooser(jcb)); topControls.add(jcb); topControls.add(graph_chooser); bottomControls.add(plus); bottomControls.add(minus); bottomControls.add(modeBox); bottomControls.add(reset); return jp; }
From source file:com.liveperson.infra.akka.actorx.ui.DisplayGraph.java
public static JPanel getGraphPanel() { final VisualizationViewer<String, String> vv = new VisualizationViewer<String, String>(new FRLayout(graph)); vv.setBackground(Color.white); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(vv.getPickedVertexState(), Color.blue, Color.yellow)); vv.getRenderContext().setVertexLabelTransformer(new Transformer<String, String>() { @Override/* w w w . j a v a 2s.c o m*/ public String transform(String s) { return getClassName(s); } }); vv.setVertexToolTipTransformer(new Transformer<String, String>() { @Override public String transform(String s) { return getClassName(s); } }); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<String>(vv.getPickedEdgeState(), Color.black, Color.green)); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<String, String>()); vv.setEdgeToolTipTransformer(new Transformer<String, String>() { @Override public String transform(String edge) { StringBuffer buffer = new StringBuffer(); buffer.append("<html>"); int index = edge.indexOf(Main.DELIMITER); String fromActor = edge.substring(0, index); String toActor = edge.substring(index + Main.DELIMITER.length()); Map<String, Set<String>> connections = castConnectionList.get(fromActor); Set<String> messages = connections.get(toActor); for (String msg : messages) { buffer.append("<p>").append(getClassName(msg)); } buffer.append("</html>"); return buffer.toString(); } }); ToolTipManager.sharedInstance().setDismissDelay(60000); final DefaultModalGraphMouse<String, String> graphMouse = new DefaultModalGraphMouse<String, String>(); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); vv.setGraphMouse(graphMouse); 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 reset = new JButton("reset"); reset.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Layout<String, String> layout = vv.getGraphLayout(); layout.initialize(); Relaxer relaxer = vv.getModel().getRelaxer(); if (relaxer != null) { // if(layout instanceof IterativeContext) { relaxer.stop(); relaxer.prerelax(); relaxer.relax(); } } }); JPanel jp = new JPanel(); jp.setBackground(Color.WHITE); jp.setLayout(new BorderLayout()); jp.add(vv, BorderLayout.CENTER); 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 control_panel = new JPanel(new GridLayout(2, 1)); JPanel topControls = new JPanel(); JPanel bottomControls = new JPanel(); control_panel.add(topControls); control_panel.add(bottomControls); jp.add(control_panel, BorderLayout.NORTH); topControls.add(jcb); bottomControls.add(plus); bottomControls.add(minus); bottomControls.add(reset); return jp; }
From source file:GUI.Main.java
static private WebPanel createAdminPanel(String url, String firstName, String lastName, final int myId) throws IOException { mainPanel.setPaintFocus(true);// w ww. j a va2s . co m // Text field input Search textSearchField = new WebTextField(15); textSearchField.setInputPrompt("Search"); textSearchField.setInputPromptFont(textSearchField.getFont().deriveFont(Font.ROMAN_BASELINE)); textSearchField.setTrailingComponent(new WebImage("resources/search.png")); System.out.println("My id" + myId); // Boite Message WebButton boiteMessageButton = new WebButton("Ouvrir ma Boite Message"); boiteMessageButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFrame boiteFrame = new JFrame("Boite de messages"); boiteFrame.setLocationRelativeTo(null); JPanel boite = new JPanel(new BorderLayout()); boite.add(new BoiteReception(myId), BorderLayout.CENTER); boiteFrame.add(boite); boiteFrame.setIconImage(new ImageIcon(getClass().getResource("/images/message.png")).getImage()); boiteFrame.pack(); boiteFrame.setLocationRelativeTo(boite); boiteFrame.setVisible(true); } }); // Text Button Search WebButton SearchButton = new WebButton("Search"); SearchButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { new ListOfOffres1().openListOfOffresFrameagn(1, textSearchField.getText(), myId); } catch (IOException ex) { Logger.getLogger(ListOfOffres1.class.getName()).log(Level.SEVERE, null, ex); } } }); // Exit Button WebButton logOutButton = new WebButton("Exit"); logOutButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ListOfOffresFrame.setVisible(false); //you can't see me! ListOfOffresFrame.dispose(); //Destroy the JFrame object ListOfOffresFrame = null; System.exit(0); } }); // Text Button Retour exitButton = new WebButton("Retour"); exitButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("Retour clicked"); ListOfOffres1.openPleaseWait(); try { System.out.println("aaaaaaaaaaaaaaaaaaaaaaaa" + myId); new ListOfOffres1().openListOfOffresFrameagn(0, "", myId); } catch (IOException ex) { Logger.getLogger(ListOfOffres1.class.getName()).log(Level.SEVERE, null, ex); } } }); final WebPanel descPanel = new WebPanel(false); GroupPanel OffrePanel = new GroupPanel(GroupingType.fillFirst, 5, false); descPanel.setOpaque(false); descPanel.setMargin(50, 50, 50, 50); mainPanel.setPaintFocus(true); mainPanel.setMargin(10); System.out.print(url); // load the image once mainPanel.setPreferredSize(new Dimension(300, 100)); OffrePanel.add(new GroupPanel(GroupingType.fillFirst, 5, false, loadImageX(url), new WebLabel("<html><body><h1><font color=#555555>" + firstName + " " + lastName + "</font></h1></body></html>", WebLabel.CENTER), textSearchField, SearchButton, new WhiteSpace(), new GroupPanel(GroupingType.fillFirst, false, new WhiteSpace(), boiteMessageButton, new GroupPanel(GroupingType.fillFirstAndLast, 5, true, exitButton, logOutButton)))); mainPanel.add(OffrePanel); return mainPanel; }
From source file:bigdata.explorer.nutch.grapview.ShowLayouts.java
private static JPanel getGraphPanel() throws IOException { g_array = (Graph<? extends Object, ? extends Object>[]) new Graph<?, ?>[graph_names.length]; Factory<Graph<Integer, Number>> graphFactory = new Factory<Graph<Integer, Number>>() { public Graph<Integer, Number> create() { return new SparseMultigraph<Integer, Number>(); }/*ww w.j a v a 2s.co m*/ }; Factory<Integer> vertexFactory = new Factory<Integer>() { int count; public Integer create() { return count++; } }; Factory<Number> edgeFactory = new Factory<Number>() { int count; public Number create() { return count++; } }; g_array[0] = TestGraphs.createTestGraph(false); g_array[1] = MixedRandomGraphGenerator.generateMixedRandomGraph(graphFactory, vertexFactory, edgeFactory, new HashMap<Number, Number>(), 20, true, new HashSet<Integer>()); g_array[2] = TestGraphs.getDemoGraph(); g_array[3] = TestGraphs.createDirectedAcyclicGraph(4, 4, 0.3); g_array[4] = TestGraphs.getOneComponentGraph(); g_array[5] = TestGraphs.createChainPlusIsolates(18, 5); g_array[6] = TestGraphs.createChainPlusIsolates(0, 20); g_array[7] = NutchGraphLoader.loadFullGraph("/home/kamir/ANALYSIS/Nutch/YellowMED_CORE"); Graph<? extends Object, ? extends Object> g = g_array[4]; // initial graph final VisualizationViewer<Integer, Number> vv = new VisualizationViewer<Integer, Number>(new FRLayout(g)); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<Integer>(vv.getPickedVertexState(), Color.red, Color.yellow)); final DefaultModalGraphMouse<Integer, Number> graphMouse = new DefaultModalGraphMouse<Integer, Number>(); vv.setGraphMouse(graphMouse); 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 reset = new JButton("reset"); reset.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Layout<Integer, Number> layout = vv.getGraphLayout(); layout.initialize(); Relaxer relaxer = vv.getModel().getRelaxer(); if (relaxer != null) { // if(layout instanceof IterativeContext) { relaxer.stop(); relaxer.prerelax(); relaxer.relax(); } } }); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(((DefaultModalGraphMouse<Integer, Number>) vv.getGraphMouse()).getModeListener()); JPanel jp = new JPanel(); jp.setBackground(Color.WHITE); jp.setLayout(new BorderLayout()); jp.add(vv, BorderLayout.CENTER); 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 control_panel = new JPanel(new GridLayout(2, 1)); JPanel topControls = new JPanel(); JPanel bottomControls = new JPanel(); control_panel.add(topControls); control_panel.add(bottomControls); jp.add(control_panel, BorderLayout.NORTH); final JComboBox graph_chooser = new JComboBox(graph_names); graph_chooser.addActionListener(new GraphChooser(jcb)); topControls.add(jcb); topControls.add(graph_chooser); bottomControls.add(plus); bottomControls.add(minus); bottomControls.add(modeBox); bottomControls.add(reset); return jp; }
From source file:net.sourceforge.doddle_owl.utils.Utils.java
public static JComponent createWestPanel(JComponent p) { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(p, BorderLayout.WEST); return panel; }
From source file:net.sourceforge.doddle_owl.utils.Utils.java
public static JComponent createEastPanel(JComponent p) { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(p, BorderLayout.EAST); return panel; }