add New Line To Container - Java Swing

Java examples for Swing:JComponent

Description

add New Line To Container

Demo Code


//package com.java2s;
import javax.swing.*;
import javax.swing.border.LineBorder;

import java.awt.*;

public class Main {
    public static final Dimension SCREEN_SIZE = Toolkit.getDefaultToolkit()
            .getScreenSize();//from  w  ww  . j  a va2s . c o m

    public static void addNewLineTo(Container container) {
        JLabel label = new JLabel();
        label.setPreferredSize(new Dimension(SCREEN_SIZE.width, 0));
        container.add(label);
    }

    public static void addNewLineTo(Container container, int lineHeight) {
        JLabel label = new JLabel();
        label.setPreferredSize(new Dimension(SCREEN_SIZE.width, lineHeight));
        label.setBorder(new LineBorder(Color.BLACK));
        container.add(label);
    }
}

Related Tutorials