Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.Component;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;

public class Main {
    public static void main(String[] args) {
        JFrame frame = new JFrame("SplitPaneFrame");

        JLabel leftImage = new JLabel(new ImageIcon("a.gif"));
        Component left = new JScrollPane(leftImage);
        JLabel rightImage = new JLabel(new ImageIcon("b.gif"));
        Component right = new JScrollPane(rightImage);

        JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, right);
        split.setDividerLocation(100);
        frame.getContentPane().add(split);

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(300, 200);
        frame.setVisible(true);
    }
}