Package ui.tabs

Source Code of ui.tabs.SettingsTab

package ui.tabs;


import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTree;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.TreeSelectionModel;

import main.settings.Settings;
import main.settings.category.AbstractCategory;
import main.settings.panels.AbstractSettingPanel;


public class SettingsTab extends AbstractTab implements TreeSelectionListener
{
  private static final long serialVersionUID = 8830820505550004340L;
  private JTree tree;
  private JSplitPane splitPane;
  private JPanel rightComponent;

  public SettingsTab()
  {
    setLayout(new BorderLayout());

    AbstractSettingPanel.intializePanels();

    tree = new JTree(new Settings());
    tree.getSelectionModel().setSelectionMode(
        TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.addTreeSelectionListener(this);

    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splitPane.setLeftComponent(new JScrollPane(tree));
    splitPane.getLeftComponent().setPreferredSize(new Dimension(200, 100));

    tree.setSelectionRow(0);
    add(splitPane, BorderLayout.CENTER);
  }

  public void valueChanged(TreeSelectionEvent e)
  {
    rightComponent = ((AbstractCategory) e.getPath().getLastPathComponent())
        .getPanel();
    splitPane.setRightComponent(rightComponent);
  }

}
TOP

Related Classes of ui.tabs.SettingsTab

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.