2 Copyright (C) 2001, 2006 United States Government
3 as represented by the Administrator of the
4 National Aeronautics and Space Administration.
7 package gov
.nasa
.worldwind
.examples
;
9 import gov
.nasa
.worldwind
.*;
10 import gov
.nasa
.worldwind
.avlist
.AVKey
;
11 import gov
.nasa
.worldwind
.awt
.WorldWindowGLCanvas
;
15 import java
.awt
.event
.*;
19 * @version $Id: UsageInTabbedPane.java 2980 2007-09-22 01:07:06Z tgaskins $
21 public class UsageInTabbedPane
25 if (Configuration
.isMacOS())
27 System
.setProperty("apple.laf.useScreenMenuBar", "true");
28 System
.setProperty("com.apple.mrj.application.apple.menu.about.name", "World Wind Tabbed Pane Application");
29 System
.setProperty("com.apple.mrj.application.growbox.intrudes", "false");
33 public static class WWJPanel
extends JPanel
35 protected WorldWindowGLCanvas wwd
;
36 protected StatusBar statusBar
;
38 public WWJPanel(Dimension canvasSize
, boolean includeStatusBar
)
40 super(new BorderLayout());
42 this.wwd
= new WorldWindowGLCanvas();
43 this.wwd
.setPreferredSize(canvasSize
);
45 // Create the default model as described in the current worldwind properties.
46 Model m
= (Model
) WorldWind
.createConfigurationComponent(AVKey
.MODEL_CLASS_NAME
);
49 this.add(this.wwd
, BorderLayout
.CENTER
);
52 this.statusBar
= new StatusBar();
53 this.add(statusBar
, BorderLayout
.PAGE_END
);
54 this.statusBar
.setEventSource(wwd
);
59 public static void main(String
[] args
)
63 JFrame mainFrame
= new JFrame();
65 mainFrame
.setTitle("World Wind Tabbed Pane");
66 mainFrame
.setDefaultCloseOperation(JFrame
.EXIT_ON_CLOSE
);
68 final JTabbedPane tabbedPane
= new JTabbedPane();
69 final WWJPanel wwjPanel
= new WWJPanel(new Dimension(800, 600), true);
70 final JPanel controlPanel
= new JPanel(new BorderLayout());
72 JButton detachButton
= new JButton("Detach");
73 detachButton
.addActionListener(new ActionListener()
75 public void actionPerformed(ActionEvent actionEvent
)
77 System
.out
.println("Detaching wwj");
78 // wwjPanel.wwd.detachFromParent();
79 System
.out
.println("Removing tab");
80 tabbedPane
.removeTabAt(0);
81 System
.out
.println("Tab removed");
85 JButton attachButton
= new JButton("Attach");
86 attachButton
.addActionListener(new ActionListener()
88 public void actionPerformed(ActionEvent actionEvent
)
90 System
.out
.println("Adding tab");
91 tabbedPane
.insertTab("WWJ Pane 1", null, wwjPanel
, "Reattach", 0);
92 System
.out
.println("Tab added");
96 controlPanel
.add(detachButton
, BorderLayout
.NORTH
);
97 controlPanel
.add(attachButton
, BorderLayout
.SOUTH
);
99 tabbedPane
.add("WWJ Pane 1", wwjPanel
);
100 tabbedPane
.add("Dummy Pane", controlPanel
);
102 mainFrame
.getContentPane().add(tabbedPane
, BorderLayout
.CENTER
);
104 mainFrame
.setVisible(true);