Java JPanel Child addSection(JPanel panel, String title)

Here you can find the source of addSection(JPanel panel, String title)

Description

add Section

License

Open Source License

Declaration

public static void addSection(JPanel panel, String title) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.Font;

import javax.swing.JLabel;
import javax.swing.JPanel;

public class Main {
    public static void addSection(JPanel panel, String title) {
        addSection(panel, title, "center");
    }//from w  ww.j  av  a  2  s  .  co m

    public static void addSection(JPanel panel, String title, String alignment) {

        JLabel label = new JLabel(title);
        Font boldFont = label.getFont().deriveFont(Font.BOLD);
        label.setFont(boldFont);

        panel.add(label, "alignx " + alignment + ", wrap");
    }
}

Related

  1. addComponent(JPanel contentPane, GridBagConstraints gbc, JLabel label, JComponent component)
  2. addComponent(JPanel panel, Component c, int x, int y, int width, int height, int ipadx, int ipady, double weightx, double weighty, int fill, int anchor)
  3. addComponents(JPanel panel, JComponent... comps)
  4. addGBC(JPanel panel, Component component, int gridx, int gridy, int anchor, Insets insets)
  5. addInput2Pane(String label, Component c, JPanel p, int row)
  6. addSpacer(JPanel panel)
  7. addTo(JPanel panel, String label, String value)
  8. addToGridBag(Component comp, JPanel panel, int gridx, int gridy, int width, int height, int anchor)
  9. addToGridBag(final JPanel panel, final Component component, final int x, final int y)