1 /*
2 * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
25
26 package javax.swing.plaf.synth;
27
28 import java.awt.*;
29 import java.awt.event.*;
30 import javax.swing.*;
31 import javax.swing.plaf.*;
32 import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
33 import java.beans.PropertyChangeListener;
34 import java.beans.PropertyChangeEvent;
35 import java.beans.PropertyVetoException;
36 import sun.swing.SwingUtilities2;
37
38 /**
39 * The class that manages a synth title bar
40 *
41 * @author David Kloba
42 * @author Joshua Outwater
43 * @author Steve Wilson
44 */
45 class SynthInternalFrameTitlePane extends BasicInternalFrameTitlePane
46 implements SynthUI, PropertyChangeListener {
47
48 protected JPopupMenu systemPopupMenu;
49 protected JButton menuButton;
50
51 private SynthStyle style;
52 private int titleSpacing;
53 private int buttonSpacing;
54 // Alignment for the title, one of SwingConstants.(LEADING|TRAILING|CENTER)
55 private int titleAlignment;
56
57 public SynthInternalFrameTitlePane(JInternalFrame f) {
58 super(f);
59 }
60
61 public String getUIClassID() {
62 return "InternalFrameTitlePaneUI";
63 }
64
142 }
143
144 protected void installDefaults() {
145 super.installDefaults();
146 updateStyle(this);
147 }
148
149 protected void uninstallDefaults() {
150 SynthContext context = getContext(this, ENABLED);
151 style.uninstallDefaults(context);
152 context.dispose();
153 style = null;
154 JInternalFrame.JDesktopIcon di = frame.getDesktopIcon();
155 if(di != null && di.getComponentPopupMenu() == systemPopupMenu) {
156 // Release link to systemMenu from the JInternalFrame
157 di.setComponentPopupMenu(null);
158 }
159 super.uninstallDefaults();
160 }
161
162 private static class JPopupMenuUIResource extends JPopupMenu implements
163 UIResource { }
164
165 protected void assembleSystemMenu() {
166 systemPopupMenu = new JPopupMenuUIResource();
167 addSystemMenuItems(systemPopupMenu);
168 enableActions();
169 menuButton = createNoFocusButton();
170 updateMenuIcon();
171 menuButton.addMouseListener(new MouseAdapter() {
172 public void mousePressed(MouseEvent e) {
173 try {
174 frame.setSelected(true);
175 } catch(PropertyVetoException pve) {
176 }
177 showSystemMenu();
178 }
179 });
180 JPopupMenu p = frame.getComponentPopupMenu();
181 if (p == null || p instanceof UIResource) {
|
1 /*
2 * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
25
26 package javax.swing.plaf.synth;
27
28 import java.awt.*;
29 import java.awt.event.*;
30 import javax.swing.*;
31 import javax.swing.plaf.*;
32 import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
33 import java.beans.PropertyChangeListener;
34 import java.beans.PropertyChangeEvent;
35 import java.beans.PropertyVetoException;
36 import sun.swing.SwingUtilities2;
37
38 /**
39 * The class that manages a synth title bar
40 *
41 * @author David Kloba
42 * @author Joshua Outwater
43 * @author Steve Wilson
44 */
45 @SuppressWarnings("serial") // Superclass is not serializable across versions
46 class SynthInternalFrameTitlePane extends BasicInternalFrameTitlePane
47 implements SynthUI, PropertyChangeListener {
48
49 protected JPopupMenu systemPopupMenu;
50 protected JButton menuButton;
51
52 private SynthStyle style;
53 private int titleSpacing;
54 private int buttonSpacing;
55 // Alignment for the title, one of SwingConstants.(LEADING|TRAILING|CENTER)
56 private int titleAlignment;
57
58 public SynthInternalFrameTitlePane(JInternalFrame f) {
59 super(f);
60 }
61
62 public String getUIClassID() {
63 return "InternalFrameTitlePaneUI";
64 }
65
143 }
144
145 protected void installDefaults() {
146 super.installDefaults();
147 updateStyle(this);
148 }
149
150 protected void uninstallDefaults() {
151 SynthContext context = getContext(this, ENABLED);
152 style.uninstallDefaults(context);
153 context.dispose();
154 style = null;
155 JInternalFrame.JDesktopIcon di = frame.getDesktopIcon();
156 if(di != null && di.getComponentPopupMenu() == systemPopupMenu) {
157 // Release link to systemMenu from the JInternalFrame
158 di.setComponentPopupMenu(null);
159 }
160 super.uninstallDefaults();
161 }
162
163 @SuppressWarnings("serial") // Superclass is not serializable across versions
164 private static class JPopupMenuUIResource extends JPopupMenu implements
165 UIResource { }
166
167 protected void assembleSystemMenu() {
168 systemPopupMenu = new JPopupMenuUIResource();
169 addSystemMenuItems(systemPopupMenu);
170 enableActions();
171 menuButton = createNoFocusButton();
172 updateMenuIcon();
173 menuButton.addMouseListener(new MouseAdapter() {
174 public void mousePressed(MouseEvent e) {
175 try {
176 frame.setSelected(true);
177 } catch(PropertyVetoException pve) {
178 }
179 showSystemMenu();
180 }
181 });
182 JPopupMenu p = frame.getComponentPopupMenu();
183 if (p == null || p instanceof UIResource) {
|