Swing

Table of Contents

Introduction

Example applications

Menus

import java.awt.Dimension;
import java.awt.event.*;

import javax.swing.*;


public class MenuExperiment extends JFrame implements ActionListener {

    public static void main(String[] args) {
	new MenuExperiment();
    }

    public MenuExperiment()    {
	JMenuBar MenuBar = new JMenuBar();
	JMenu Menu = new JMenu("File");
	JMenuItem Exit = new JMenuItem("Exit");
	Exit.addActionListener(this);

	Menu.add(Exit);
	MenuBar.add(Menu);
	setJMenuBar(MenuBar);

	setSize(500,500);
	setDefaultCloseOperation(EXIT_ON_CLOSE);
	setVisible(true);
    }

    @Override
    public void actionPerformed(ActionEvent evt) {
	String cmd = evt.getActionCommand();
	if (cmd == "Exit") {
	    setVisible(false);
	    dispose();
	}
    }
}

Dialogs

Trees

SwingX

Miscellaneous

GitHubImpressum