Java Code Examples for javax.swing.JPanel#setBackground()

The following examples show how to use javax.swing.JPanel#setBackground() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private void initUI() {
    toolbar = ProfilerToolbar.create(false);
    
    
    JPanel p = new JPanel(new VerticalLayout(false, 6));
    p.setOpaque(true);
    p.setBackground(UIUtils.getProfilerResultsBackground());
    
    HeapView defaultContent = createDefaultSummary();
    if (defaultContent != null) content.add(0, defaultContent);
    
    for (HeapView view : content) {
        p.add(new ContentContainer(view));
        ProfilerToolbar viewToolbar = view.getToolbar();
        if (viewToolbar != null) toolbar.add(viewToolbar);
    }
    
    uiCreated(new ArrayList(content));
    
    component = new ScrollableContainer(p);
    
    content.clear();
    content = null;
}
 
Example 2
private JPanel getDock() {

        JPanel dPanel = new JPanel(new GridLayout(7, 1));
        dPanel.setOpaque(false);
        dPanel.setBackground(new Color(0, 0, 0, 0));
        testDesignButton = create("TestDesign");
        testExecutionButton = create("TestExecution");
        dashBoardButton = create("DashBoard");

        dPanel.add(getLeftFiller());
        dPanel.add(getLeftFiller());

        dPanel.add(testDesignButton);
        dPanel.add(testExecutionButton);
        dPanel.add(dashBoardButton);

        dPanel.add(getLeftFiller());
        dPanel.add(getLeftFiller());

        return dPanel;
    }
 
Example 3
Source Project: jplag   File: JPlagCreator.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static JPanel createPanel(String title, int width, int height, int vGap, int hGap, int alignment, int type) {
	FlowLayout flowLayout1 = new FlowLayout();
	JPanel controlPanel = new JPanel();

	controlPanel.setLayout(flowLayout1);
	flowLayout1.setAlignment(alignment);
	controlPanel.setPreferredSize(new java.awt.Dimension(width, height));

	controlPanel.setBackground(JPlagCreator.SYSTEMCOLOR);
	if (type == WITH_LINEBORDER)
		controlPanel.setBorder(JPlagCreator.LINE);
	if (type == WITH_TITLEBORDER)
		controlPanel.setBorder(JPlagCreator.titleBorder(title, Color.BLACK, Color.BLACK));
	flowLayout1.setVgap(vGap);
	flowLayout1.setHgap(hGap);
	return controlPanel;
}
 
Example 4
private void buildPanel() {
    JPanel tilePanel = new JPanel();
    tilePanel.setBackground(Color.GRAY);
    tilePanel.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.weightx = 1;
    constraints.weighty = 1;
    for (TileType tileType : TileType.enabledTiles()) {
        TileQuantityPanel quantityPanel = new TileQuantityPanel(tileType, distribution.getQuantity(tileType));
        quantityPanels.add(quantityPanel);
        tilePanel.add(quantityPanel, constraints);
        constraints.gridx++;
        if (constraints.gridx >= GRID_WIDTH) {
            constraints.gridx = 0;
            constraints.gridy++;
        }
    }
    buildButtons(tilePanel, constraints);
    getContentPane().add(tilePanel);
}
 
Example 5
Source Project: netbeans   File: InfoPanel.java    License: Apache License 2.0 6 votes vote down vote up
Item(Color backgroundColor, int preferredHeight, JComponent innerPanel) {
    this.backgroundColor = backgroundColor;
    this.preferredHeight = preferredHeight;
    this.innerPanel = innerPanel;
    topGapPanel = createGapPanel();
    bottomGapPanel = createGapPanel();
    separator = createSeparator();
    outerPanel = new JPanel();
    outerPanel.setBackground(backgroundColor);
    outerPanel.setLayout(new BorderLayout());
    outerPanel.add(BorderLayout.NORTH, topGapPanel);
    outerPanel.add(BorderLayout.CENTER, innerPanel);
    outerPanel.add(BorderLayout.SOUTH, bottomGapPanel);
    outerPanel.setPreferredSize(new Dimension(0, preferredHeight));
    scrollPane = new JScrollPane();
    scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0));
    scrollPane.setPreferredSize(new Dimension(0, preferredHeight));
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setViewportView(outerPanel);
}
 
Example 6
private static JPanel createBox(final Color color, final Consumer<Color> consumer, final boolean alphaHidden)
{
	final JPanel box = new JPanel();
	String hex = alphaHidden ? ColorUtil.colorToHexCode(color) : ColorUtil.colorToAlphaHexCode(color);

	box.setBackground(color);
	box.setOpaque(true);
	box.setPreferredSize(new Dimension(BOX_SIZE, BOX_SIZE));
	box.setToolTipText("#" + hex.toUpperCase());
	box.addMouseListener(new MouseAdapter()
	{
		@Override
		public void mouseClicked(MouseEvent e)
		{
			consumer.accept(color);
		}
	});

	return box;
}
 
Example 7
public void fillWithSummaryTitles(JPanel gridPanel, StatKey prefixKey, List<CounterReportTemplate> templateList) {
    // Panel for titles of all cols
    JPanel panelTmp = new JPanel();

    // Color of this panel
    panelTmp.setBackground(ModelTreeRTStats.instance().getColorByString("columnTitle"));

    // We want a text alignment on the left
    panelTmp.setLayout(new javax.swing.BoxLayout(panelTmp, javax.swing.BoxLayout.X_AXIS));

    // First column
    panelTmp.add(new JLabel("<html>Summary</html>"));

    // We add this panel to the main panel for shorts stats
    gridPanel.add(panelTmp);

    // For each template
    for (CounterReportTemplate template : templateList) {
        // Others columns
        JPanel panelTmp2 = new JPanel();

        // Color of this panel
        panelTmp2.setBackground(ModelTreeRTStats.instance().getColorByString("columnTitle"));

        // We want a text alignment on the left
        panelTmp2.setLayout(new javax.swing.BoxLayout(panelTmp2, javax.swing.BoxLayout.X_AXIS));

        // We add to this panel short descr of each template
        panelTmp2.add(new JLabel("<html>" + template.summary + "</html>"));

        // We add a toolTip on head section
        panelTmp2.setToolTipText(template.name);

        // We add this panel to the main panel for shorts stats
        gridPanel.add(panelTmp2);
    }
}
 
Example 8
public ValidationErrorsBalloonView() {
	panelMessages = new JPanel(new VerticalLayout(3, VerticalLayout.BOTH, VerticalLayout.TOP));
	panelMessages.setBackground(errorBackgroundColor);
	panelMessages.setOpaque(true);

	balloonStyle = new RoundedBalloonStyle(5, 5, errorBackgroundColor, new Color(255, 0, 0));
}
 
Example 9
public void init() {
    JButton button = new JButton("Button"); // NON-NLS: the button text
    button.setBorder(BorderFactory.createLineBorder(Color.red, 1));

    TitledBorder border = new TitledBorder("Bordered Pane"); // NON-NLS: the panel title
    border.setTitlePosition(TitledBorder.BELOW_BOTTOM);

    JPanel panel = create(button, border);
    panel.setBackground(Color.green);

    getContentPane().add(create(panel, BorderFactory.createEmptyBorder(10, 10, 10, 10)));
}
 
Example 10
public ThumbnailList()
	{
		metaDataEntries = new ArrayList<MetaData>();
		
		
		content = new JPanel();
		content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
		
//		thumbnailScrollPane = new JScrollPane(content);
		content.setBackground(new Color(133,133,133));
		this.setViewportView(content);
		this.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
		this.setBorder(BorderFactory.createLineBorder(Color.BLACK));
	}
 
Example 11
protected JComponent createComponent() {
    component = new JPanel(new BorderLayout());
    component.setOpaque(true);
    component.setBackground(UIUtils.getProfilerResultsBackground());
    
    objectsView.getComponent().setVisible(false); // force init in showObjectsView()
    showObjectsView();
    
    return component;
}
 
Example 12
private static void createAndShowGUI() {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setBackground(Color.BLUE);
    radioButton = new JRadioButton();
    radioButton.setOpaque(false);
    JPanel panel = new JPanel();
    panel.setBackground(Color.BLUE);
    panel.add(radioButton);
    frame.getContentPane().add(panel);
    frame.pack();
    frame.setVisible(true);
}
 
Example 13
private static void createAndShowUI() {
    frame = new JFrame();
    frame.setBounds(10, scrTop + 10, 300, 100);
    JPanel panel = new JPanel();
    panel.setBackground(color);
    frame.getContentPane().add(panel);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}
 
Example 14
Source Project: netbeans   File: LoadGenProfilingPoint.java    License: Apache License 2.0 5 votes vote down vote up
private void initComponents() {
    setLayout(new BorderLayout());

    JPanel contentsPanel = new JPanel(new BorderLayout());
    contentsPanel.setBackground(UIUtils.getProfilerResultsBackground());
    contentsPanel.setOpaque(true);
    contentsPanel.setBorder(BorderFactory.createMatteBorder(0, 15, 15, 15, UIUtils.getProfilerResultsBackground()));

    headerArea = new HTMLTextArea() {
            protected void showURL(URL url) {
                String urlString = url.toString();

                if (START_LOCATION_URLMASK.equals(urlString)) {
                    Utils.openLocation(LoadGenProfilingPoint.this.getStartLocation());
                } else if (LoadGenProfilingPoint.this.usesEndLocation()) {
                    Utils.openLocation(LoadGenProfilingPoint.this.getEndLocation());
                }
            }
        };

    JScrollPane headerAreaScrollPane = new JScrollPane(headerArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                                       JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    headerAreaScrollPane.setBorder(BorderFactory.createMatteBorder(0, 0, 15, 0, UIUtils.getProfilerResultsBackground()));
    headerAreaScrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
    contentsPanel.add(headerAreaScrollPane, BorderLayout.NORTH);

    dataArea = new HTMLTextArea();

    JScrollPane dataAreaScrollPane = new JScrollPane(dataArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                                     JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    TitledBorder tb = new TitledBorder(Bundle.LoadGenProfilingPoint_DataString());
    tb.setTitleFont(Utils.getTitledBorderFont(tb).deriveFont(Font.BOLD));
    tb.setTitleColor(javax.swing.UIManager.getColor("Label.foreground")); // NOI18N
    dataAreaScrollPane.setBorder(tb);
    dataAreaScrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
    dataAreaScrollPane.setBackground(UIUtils.getProfilerResultsBackground());
    contentsPanel.add(dataAreaScrollPane, BorderLayout.CENTER);

    add(contentsPanel, BorderLayout.CENTER);
}
 
Example 15
@NotNull
private JComponent createHintComponent(@NotNull String text,
    @NotNull final FindUsagesHandler handler, @NotNull final RelativePoint popupPosition,
    final Editor editor, @NotNull final Runnable cancelAction, final int maxUsages,
    @NotNull final FindUsagesOptions options) {
  JComponent label =
      HintUtil.createInformationLabel(suggestSecondInvocation(options, handler, text + "&nbsp;"));
  InplaceButton button =
      createSettingsButton(handler, popupPosition, editor, maxUsages, cancelAction);

  JPanel panel = new JPanel(new BorderLayout()) {
    @Override
    public void addNotify() {
      mySearchEverywhereRunnable = new Runnable() {
        @Override
        public void run() {
          searchEverywhere(options, handler, editor, popupPosition, maxUsages);
        }
      };
      super.addNotify();
    }

    @Override
    public void removeNotify() {
      mySearchEverywhereRunnable = null;
      super.removeNotify();
    }
  };
  button.setBackground(label.getBackground());
  panel.setBackground(label.getBackground());
  label.setOpaque(false);
  label.setBorder(null);
  panel.setBorder(HintUtil.createHintBorder());
  panel.add(label, BorderLayout.CENTER);
  panel.add(button, BorderLayout.EAST);
  return panel;
}
 
Example 16
Source Project: littleluck   File: InternalFrameDemo.java    License: Apache License 2.0 5 votes vote down vote up
public ImageScroller(Icon icon) {
            super();
            setBorder(null);
            JPanel p = new JPanel();
            p.setBorder(null);
//            p.setOpaque(false);
            p.setBackground(Color.white);
            p.setLayout(new BorderLayout());

            p.add(new JLabel(icon), BorderLayout.CENTER);

            getViewport().add(p);
            getHorizontalScrollBar().setUnitIncrement(10);
            getVerticalScrollBar().setUnitIncrement(10);
        }
 
Example 17
Source Project: Spark   File: FastpathContainer.java    License: Apache License 2.0 4 votes vote down vote up
public FastpathContainer() {

		  setLayout(new GridBagLayout());
		
		  topPanel = new JPanel();
		  mainPanel = new SparkTabbedPane();
		
		  add(topPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 0, 2), 0, 0));
		  add(mainPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(2, 2, 0, 2), 0, 0));
		
		  topPanel.setLayout(new BorderLayout());
		
		  mainPanel.setBackground(Color.white);
		  topPanel.setBackground(Color.white);
		
		  setBackground(Color.white);
		
		  mainPanel.getMainPanel().setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1));
		  mainPanel.getMainPanel().setBackground(Color.white);

    }
 
Example 18
/**
 * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable,
 *      java.lang.Object, boolean, boolean, int, int)
 */
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
    boolean hasFocus, int row, int column) {

  JPanel newPanel = new JPanel();
  newPanel.setLayout(new OverlayLayout(newPanel));

  Color bgColor;

  if (isSelected)
    bgColor = table.getSelectionBackground();
  else
    bgColor = table.getBackground();

  newPanel.setBackground(bgColor);

  if (hasFocus) {
    Border border = null;
    if (isSelected)
      border = UIManager.getBorder("Table.focusSelectedCellHighlightBorder");
    if (border == null)
      border = UIManager.getBorder("Table.focusCellHighlightBorder");
    if (border != null)
      newPanel.setBorder(border);
  }

  if (value != null) {

    if (value instanceof JComponent) {

      newPanel.add((JComponent) value);

    } else {

      JLabel newLabel = new JLabel();
      if (value instanceof IIsotope) {
        IIsotope is = (IIsotope) value;
        newLabel.setText(is.getSymbol());
      } else {
        newLabel.setText(value.toString());
      }

      if (font != null)
        newLabel.setFont(font);
      else if (table.getFont() != null)
        newLabel.setFont(table.getFont());

      newPanel.add(newLabel);
    }

    if (createTooltips)
      newPanel.setToolTipText(value.toString());

  }

  return newPanel;

}
 
Example 19
private JPanel createPanTableHeader(){
	
	dateChooser = CalendarChooser.getDateChooser();
	JPanel dateChooserPanel = dateChooser.getChooser();

	JPanel headerPanel = new JPanel(new BorderLayout());
	JLabel label = new JLabel(DisplayStrings.DATE_STR.toString());
	label.setFont(UIUtil.getFont());
	
	headerPanel.add(label, BorderLayout.WEST);
	headerPanel.add(dateChooserPanel, BorderLayout.EAST);
	
	headerPanel.setBorder(BorderFactory.createEtchedBorder());
	
	label.setPreferredSize(new Dimension(KeyColWidth , RowHeight));
	
	dateChooserPanel.setPreferredSize(new Dimension(ValueColWidth , RowHeight));
	headerPanel.setPreferredSize(headerSize);
	
	headerPanel.setBackground(UIConsts.TABLE_HEADER_BACKGROUND);
	label.setForeground(UIConsts.TABLE_HEADER_FOREGROUND);
	
	dateChooser.setBackground(UIConsts.TABLE_HEADER_BACKGROUND);
	dateChooser.setForeground(UIConsts.TABLE_HEADER_FOREGROUND);
	
	dateChooser.setSelectedDate(pan.getDate().getTime());
	JPanel outerPanel = new JPanel();
	outerPanel.add(headerPanel);
	
	return outerPanel;

}
 
Example 20
Source Project: Spark   File: DialPanel.java    License: Apache License 2.0 3 votes vote down vote up
public DialPanel() {
    setLayout(new GridBagLayout());

    JPanel imagePanel = new JPanel();
    imagePanel.setLayout(new BorderLayout());


    imagePanel.setBackground(Color.white);

    iconLabel = new JLabel(SparkRes.getImageIcon(SparkRes.TELEPHONE_24x24));
    iconLabel.setHorizontalAlignment(JLabel.CENTER);
    iconLabel.setVerticalTextPosition(JLabel.BOTTOM);
    iconLabel.setHorizontalTextPosition(JLabel.CENTER);
    imagePanel.add(iconLabel, BorderLayout.CENTER);
    iconLabel.setFont(new Font("Dialog", Font.BOLD, 14));


    dialPanel.setLayout(new GridBagLayout());

    JLabel dialLabel = new JLabel();
    dialPanel.add(dialLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.WEST, new Insets(5, 5, 5, 5), 0, 0));

    dialField = new JTextField();
    dialPanel.add(dialField, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));

    dialButton = new JButton("");
    dialPanel.add(dialButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.WEST, new Insets(5, 5, 5, 5), 0, 0));

    add(imagePanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    add(dialPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));

    iconLabel.setText(Res.getString("title.waiting.to.call"));

    ResourceUtils.resButton(dialButton, Res.getString("label.dial"));
    ResourceUtils.resLabel(dialLabel, dialField, Res.getString("label.number") + ":");
}