Skip to content

An easy to use library to navigate between JPanels in Swing.

Notifications You must be signed in to change notification settings

riggraz/Java-Swing-Navigation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Java Swing Navigation

An easy to use library to navigate between JPanels in Swing.

How does it work?

You just need to use two classes: ScreenManager and Screen. First create a ScreenManager instance and then attach Screens to it:

screenManager = new ScreenManager();
	
screenManager.addScreen(new HomeScreen(), "HOMESCREEN");
screenManager.addScreen(new AboutScreen(), "ABOUTSCREEN");

where HomeScreen and AboutScreen are classes that extends the Screen class:

class HomeScreen extends Screen {
	JButton aboutBtn;

	public HomeScreen() {
		add(new JLabel("Welcome!"));
		aboutBtn = new JButton("Go to about screen");
		aboutBtn.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				navigateTo("ABOUTSCREEN");
			}
		}
	}
}

As you can see in the example above, inside Screen classes you can call the method navigateTo(String screenName) which is used to navigate to the specified screen.

Click here for a complete example.

Where can I get it?

Click here to download the JAR file.

Who is the author?

Riccardo Graziosi.

About

An easy to use library to navigate between JPanels in Swing.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages