Debian Codegraph @

src/dr/app/beauti/util/PanelUtils.java

raw symbols SCIP
1 /*
2 * PanelUtils.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
24 */
25
26 package dr.app.beauti.util;
27
28 import javax.swing.*;
29 import java.awt.*;
30
31 /**
32 * @author Andrew Rambaut
33 * @version $Id$
34 */
35 public class PanelUtils {
36 public static JPanel createAddRemoveButtonPanel(Action addAction,
37 Icon addIcon, String addToolTip, Action removeAction,
38 Icon removeIcon, String removeToolTip, int axis) {
39
40 JPanel buttonPanel = new JPanel();
41 buttonPanel.setLayout(new BoxLayout(buttonPanel, axis));
42 buttonPanel.setOpaque(false);
43 JButton addButton = new JButton(addAction);
44 if (addIcon != null) {
45 addButton.setIcon(addIcon);
46 addButton.setText(null);
47 }
48 addButton.setToolTipText(addToolTip);
49 addButton.putClientProperty("JButton.buttonType", "toolbar");
50 addButton.setOpaque(false);
51 addAction.setEnabled(false);
52
53 JButton removeButton = new JButton(removeAction);
54 if (removeIcon != null) {
55 removeButton.setIcon(removeIcon);
56 removeButton.setText(null);
57 }
58 removeButton.setToolTipText(removeToolTip);
59 removeButton.putClientProperty("JButton.buttonType", "toolbar");
60 removeButton.setOpaque(false);
61 removeAction.setEnabled(false);
62
63 buttonPanel.add(addButton);
64 buttonPanel.add(new JToolBar.Separator(new Dimension(6, 6)));
65 buttonPanel.add(removeButton);
66
67 return buttonPanel;
68 }
69
70 public static void setupComponent(JComponent comp) {
71 comp.setOpaque(false);
72
73 // comp.setFont(UIManager.getFont("SmallSystemFont"));
74 // comp.putClientProperty("JComponent.sizeVariant", "small");
75 if (comp instanceof JButton) {
76 comp.putClientProperty("JButton.buttonType", "textured");
77 // comp.putClientProperty("JButton.buttonType", "bevel");
78 // comp.putClientProperty("JButton.buttonType", "roundRect");
79 }
80 if (comp instanceof JComboBox) {
81 comp.putClientProperty("JComboBox.isPopDown", Boolean.TRUE);
82 // comp.putClientProperty("JComboBox.isSquare", Boolean.TRUE);
83 }
84 if (comp instanceof JTextArea) {
85 ((JTextArea) comp).setEditable(false);
86 ((JTextArea) comp).setOpaque(false);
87 ((JTextArea) comp).setLineWrap(true);
88 ((JTextArea) comp).setWrapStyleWord(true);
89 }
90 }
91
92 public static Frame getActiveFrame() {
93 Frame result = null;
94 Frame[] frames = Frame.getFrames();
95 for (int i = 0; i < frames.length; i++) {
96 Frame frame = frames[i];
97 if (frame.isVisible()) {
98 result = frame;
99 break;
100 }
101 }
102 return result;
103 }// END: getActiveFrame
104
105 }