List of usage examples for javax.swing JPanel setBackground
@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.") public void setBackground(Color bg)
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>(); }/*from www . ja v a 2s . 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); 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:eu.europa.esig.dss.applet.util.ComponentFactory.java
/** * @param builder//www . jav a 2 s .com * @return */ public static JPanel createPanel(final PanelBuilder builder) { final JPanel panel = builder.build(); panel.setOpaque(true); panel.setBackground(DEFAULT_BACKGROUND); return panel; }
From source file:eu.europa.esig.dss.applet.util.ComponentFactory.java
/** * @param layout//from ww w .j av a2s.c o m * @param bgColor * @return */ public static JPanel createPanel(final LayoutManager layout, final Color bgColor) { final JPanel panel = new JPanel(layout); panel.setOpaque(true); panel.setBackground(bgColor); return panel; }
From source file:de.ipk_gatersleben.ag_pbi.mmd.visualisations.gradient.GradientDataChartComponent.java
public static JPanel prettifyChart(org.graffiti.graph.GraphElement ge, ChartOptions co, JFreeChart jfChart, int idx) { if (jfChart.getTitle() != null) { jfChart.getTitle().setFont(NodeTools.getChartTitleFont(ge)); jfChart.getTitle().setPaint(NodeTools.getChartTitleColor(ge)); }/*from w ww . j av a 2s . c o m*/ ChartPanel jfreechartPanel = new ChartPanel(jfChart, false); JPanel chartPanel = jfreechartPanel; Color cbc = NodeTools.getChartBackgroundColor(ge, idx); if (cbc != null) { chartPanel.setOpaque(true); chartPanel.setBackground(cbc); } else { chartPanel.setOpaque(false); chartPanel.setBackground(null); } if (chartPanel instanceof ChartPanel) { ChartPanel cp = (ChartPanel) chartPanel; cp.setMinimumDrawHeight(300); cp.setMinimumDrawWidth(330); } if (co.borderHor > 0) chartPanel.setBorder(BorderFactory.createEmptyBorder(1, 0, 3, 0)); return chartPanel; }
From source file:eu.europa.ec.markt.dss.applet.util.ComponentFactory.java
/** * /*from w ww .ja v a 2s . c o m*/ * @param builder * @param opaque * @param bgColor * @return */ public static JPanel createPanel(final PanelBuilder builder, final boolean opaque, final Color bgColor) { final JPanel panel = builder.build(); panel.setOpaque(opaque); panel.setBackground(bgColor); return panel; }
From source file:eu.europa.ec.markt.dss.applet.util.ComponentFactory.java
/** * //from w ww . j av a 2 s .c o m * @param layout * @param bgColor * @param opaque * @return */ public static JPanel createPanel(final LayoutManager layout, final boolean opaque, final Color bgColor) { final JPanel panel = new JPanel(layout); panel.setOpaque(opaque); panel.setBackground(bgColor); return panel; }
From source file:Main.java
Main() { setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(900, 600);//from w w w . ja v a2 s .com JPanel left = new JPanel(); left.setBackground(Color.BLUE); JPanel right = new JPanel(new BorderLayout()); JLabel fox = new JLabel("The quick brown fox jumps over the lazy dog."); fox.setFont(new Font(null, 0, 50)); JPanel rightBottom = new JPanel(); rightBottom.setLayout(new GridLayout(10, 10)); for (int i = 1; i <= 100; i++) { rightBottom.add(new JButton("butt" + i)); } right.add(fox, BorderLayout.NORTH); right.add(rightBottom, BorderLayout.CENTER); add(right); }
From source file:Main.java
public Main() { JPanel parentPanel = new JPanel(); parentPanel.setLayout(new BorderLayout(10, 10)); JPanel childPanel1 = new JPanel(); childPanel1.setBackground(Color.red); childPanel1.setPreferredSize(new Dimension(300, 40)); JPanel childPanel2 = new JPanel(); childPanel2.setBackground(Color.blue); childPanel2.setPreferredSize(new Dimension(800, 600)); JButton myButton = new JButton("Add Component "); myButton.addActionListener(e -> { parentPanel.remove(childPanel1); parentPanel.add(childPanel2, BorderLayout.CENTER); parentPanel.revalidate();//from w w w .j a v a2 s . c om parentPanel.repaint(); pack(); }); setLocation(10, 200); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); parentPanel.add(childPanel1, BorderLayout.CENTER); parentPanel.add(myButton, BorderLayout.SOUTH); add(parentPanel); pack(); setVisible(true); }
From source file:SplashScreen.java
License:asdf
public SplashScreen(int d) { duration = d;/*w w w. j a va2 s. c om*/ JPanel content = (JPanel) getContentPane(); content.setBackground(Color.white); int width = 450; int height = 115; Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); int x = (screen.width - width) / 2; int y = (screen.height - height) / 2; setBounds(x, y, width, height); content.add(new JLabel("asdf"), BorderLayout.CENTER); Color oraRed = new Color(156, 20, 20, 255); content.setBorder(BorderFactory.createLineBorder(oraRed, 10)); setVisible(true); try { Thread.sleep(duration); } catch (Exception e) { } setVisible(false); }
From source file:Containers.java
public Containers() { this.setBackground(Color.white); // This component is white this.setFont(new Font("Dialog", Font.BOLD, 24)); JPanel p1 = new JPanel(); p1.setBackground(new Color(200, 200, 200)); // Panel1 is darker this.add(p1); // p1 is contained by this component p1.add(new JButton("#1")); // Button 1 is contained in p1 JPanel p2 = new JPanel(); p2.setBackground(new Color(150, 150, 150)); // p2 is darker than p2 p1.add(p2); // p2 is contained in p1 p2.add(new JButton("#2")); // Button 2 is contained in p2 JPanel p3 = new JPanel(); p3.setBackground(new Color(100, 100, 100)); // p3 is darker than p2 p2.add(p3); // p3 is contained in p2 p3.add(new JButton("#3")); // Button 3 is contained in p3 JPanel p4 = new JPanel(); p4.setBackground(new Color(150, 150, 150)); // p4 is darker than p1 p1.add(p4); // p4 is contained in p1 p4.add(new JButton("#4")); // Button4 is contained in p4 p4.add(new JButton("#5")); // Button5 is also contained in p4 this.add(new JButton("#6")); // Button6 is contained in this component }