Path: blob/master/src/demo/share/jfc/Metalworks/MetalworksInBox.java
41152 views
/*1* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions5* are met:6*7* - Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9*10* - Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13*14* - Neither the name of Oracle nor the names of its15* contributors may be used to endorse or promote products derived16* from this software without specific prior written permission.17*18* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS19* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,20* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR21* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR22* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,23* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,24* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR25* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF26* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING27* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS28* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.29*/3031/*32* This source code is provided to illustrate the usage of a given feature33* or technique and has been deliberately simplified. Additional steps34* required for a production-quality application, such as security checks,35* input validation and proper error handling, might not be present in36* this sample code.37*/38394041import javax.swing.JInternalFrame;42import javax.swing.JScrollPane;43import javax.swing.JTree;44import javax.swing.tree.DefaultMutableTreeNode;454647/**48* This is a subclass of JInternalFrame which displays a tree.49*50* @author Steve Wilson51* @author Alexander Kouznetsov52*/53@SuppressWarnings("serial")54public class MetalworksInBox extends JInternalFrame {5556public MetalworksInBox() {57super("In Box", true, true, true, true);5859DefaultMutableTreeNode unread;60DefaultMutableTreeNode personal;61DefaultMutableTreeNode business;62DefaultMutableTreeNode spam;6364DefaultMutableTreeNode top = new DefaultMutableTreeNode("Mail Boxes");6566top.add(unread = new DefaultMutableTreeNode("Unread Mail"));67top.add(personal = new DefaultMutableTreeNode("Personal"));68top.add(business = new DefaultMutableTreeNode("Business"));69top.add(spam = new DefaultMutableTreeNode("Spam"));7071unread.add(new DefaultMutableTreeNode("Buy Stuff Now"));72unread.add(new DefaultMutableTreeNode("Read Me Now"));73unread.add(new DefaultMutableTreeNode("Hot Offer"));74unread.add(new DefaultMutableTreeNode("Re: Re: Thank You"));75unread.add(new DefaultMutableTreeNode("Fwd: Good Joke"));7677personal.add(new DefaultMutableTreeNode("Hi"));78personal.add(new DefaultMutableTreeNode("Good to hear from you"));79personal.add(new DefaultMutableTreeNode("Re: Thank You"));8081business.add(new DefaultMutableTreeNode("Thanks for your order"));82business.add(new DefaultMutableTreeNode("Price Quote"));83business.add(new DefaultMutableTreeNode("Here is the invoice"));84business.add(new DefaultMutableTreeNode(85"Project Metal: delivered on time"));86business.add(new DefaultMutableTreeNode("Your salary raise approved"));8788spam.add(new DefaultMutableTreeNode("Buy Now"));89spam.add(new DefaultMutableTreeNode("Make $$$ Now"));90spam.add(new DefaultMutableTreeNode("HOT HOT HOT"));91spam.add(new DefaultMutableTreeNode("Buy Now"));92spam.add(new DefaultMutableTreeNode("Don't Miss This"));93spam.add(new DefaultMutableTreeNode("Opportunity in Precious Metals"));94spam.add(new DefaultMutableTreeNode("Buy Now"));95spam.add(new DefaultMutableTreeNode("Last Chance"));96spam.add(new DefaultMutableTreeNode("Buy Now"));97spam.add(new DefaultMutableTreeNode("Make $$$ Now"));98spam.add(new DefaultMutableTreeNode("To Hot To Handle"));99spam.add(new DefaultMutableTreeNode("I'm waiting for your call"));100101JTree tree = new JTree(top);102JScrollPane treeScroller = new JScrollPane(tree);103treeScroller.setBackground(tree.getBackground());104setContentPane(treeScroller);105setSize(325, 200);106setLocation(75, 75);107108}109}110111112