Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class Main extends JFrame {

    public Main() {
        JComboBox comboBox = new JComboBox();

        ((JLabel) comboBox.getRenderer()).setHorizontalAlignment(JLabel.RIGHT);

        comboBox.addItem("Apple");
        comboBox.addItem("Orange");
        comboBox.addItem("Mango");

        getContentPane().add(comboBox, "North");
        setSize(200, 100);
        this.setLocationRelativeTo(null);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        new Main().setVisible(true);
    }
}