Package de.chris_soft.utilities.swing.swingx

Source Code of de.chris_soft.utilities.swing.swingx.TaskPaneDemo

/**
* NanoDoA - File based document archive
*
* Copyright (C) 2011-2012 Christian Packenius, christian.packenius@googlemail.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
package de.chris_soft.utilities.swing.swingx;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import org.jdesktop.swingx.JXTaskPane;
import org.jdesktop.swingx.JXTaskPaneContainer;

/**
*
*/
public class TaskPaneDemo extends JPanel implements ActionListener {
  /**
   * serialVersionUID.
   */
  private static final long serialVersionUID = 6574991583881650911L;

  private static JFrame frame;

  private JXTaskPaneContainer tpc;

  /**
   * main method allows us to run as a standalone demo.
   * @param args
   */
  public static void main(String[] args) {
    frame = new JFrame();
    frame.setIconImage(new ImageIcon("MS.JPG").getImage());

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(new TaskPaneDemo());
    frame.setPreferredSize(new Dimension(800, 600));
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }

  /**
   * Constructor.
   */
  public TaskPaneDemo() {
    super(new BorderLayout());

    tpc = new JXTaskPaneContainer();

    // "System" GROUP
    JXTaskPane systemGroup = new JXTaskPane();
    systemGroup.setTitle("System");
    systemGroup.setIcon(new ImageIcon("MS.JPG"));
    systemGroup.add(new JButton("email"));
    systemGroup.add(new JButton("delete"));
    tpc.add(systemGroup);

    // "Office" GROUP
    JXTaskPane officeGroup = new JXTaskPane();
    officeGroup.setName("officeGroup");
    officeGroup.add(new JButton("write"));
    tpc.add(officeGroup);

    // "SEE ALSO" GROUP and ACTIONS
    JXTaskPane seeAlsoGroup = new JXTaskPane();
    seeAlsoGroup.setName("seeAlsoGroup");
    seeAlsoGroup.add(new JButton("exploreInternet"));
    JButton moreButton = new JButton("more");
    moreButton.addActionListener(this);
    seeAlsoGroup.add(moreButton);
    tpc.add(seeAlsoGroup);

    add(new JScrollPane(tpc));
  }

  /**
   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  @Override
  public void actionPerformed(ActionEvent e) {
    JXTaskPane moreGroup = new JXTaskPane();
    moreGroup.setTitle("---MORE---");
    moreGroup.setIcon(new ImageIcon("MS.JPG"));
    moreGroup.add(new JButton("more1"));
    moreGroup.add(new JButton("more2"));
    tpc.add(moreGroup);
    tpc.validate();
  }
}
TOP

Related Classes of de.chris_soft.utilities.swing.swingx.TaskPaneDemo

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.