Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Toolkit;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EtchedBorder;

public class Main extends JFrame {

    public Main() {
        JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5));
        ImageIcon icon = new ImageIcon(Toolkit.getDefaultToolkit().getImage("matte.gif"));
        simplePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red),
                BorderFactory.createMatteBorder(-1, -1, -1, -1, icon)));
        simplePanel.add(new JLabel("Examples"), JLabel.CENTER);

        add(simplePanel);
    }

    public static void main(String[] argv) {
        Main borderFactoryDemo = new Main();

        borderFactoryDemo.setVisible(true);
        borderFactoryDemo.pack();
    }
}