All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fr.vergne.translation.editor.ToolPanel Maven / Gradle / Ivy

There is a newer version: 2.0
Show newest version
package fr.vergne.translation.editor;

import java.awt.GridLayout;

import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import fr.vergne.translation.editor.tool.Tool;

@SuppressWarnings("serial")
public class ToolPanel extends JPanel {

	private final JTabbedPane tabContainer;

	public ToolPanel() {
		setLayout(new GridLayout());
		tabContainer = new JTabbedPane();
		add(tabContainer);
	}

	public void addTool(Tool tool) {
		String target = tool.getTitle();
		for (int i = 0; i < tabContainer.getTabCount(); i++) {
			String title = tabContainer.getTitleAt(i);
			if (target.equals(title)) {
				tabContainer.setSelectedIndex(i);
				return;
			} else {
				// not this one
			}
		}
		tabContainer.add(target, tool.instantiatePanel());
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy