Use a tabbed pane.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@1022 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: RuntimeAdjust.java,v 1.4 2003/01/15 02:29:23 mdb Exp $
|
// $Id: RuntimeAdjust.java,v 1.5 2003/01/15 03:24:53 mdb Exp $
|
||||||
|
|
||||||
package com.samskivert.util;
|
package com.samskivert.util;
|
||||||
|
|
||||||
@@ -14,9 +14,11 @@ import java.util.Iterator;
|
|||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JSeparator;
|
import javax.swing.JSeparator;
|
||||||
|
import javax.swing.JTabbedPane;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
import com.samskivert.Log;
|
import com.samskivert.Log;
|
||||||
@@ -54,20 +56,19 @@ public class RuntimeAdjust
|
|||||||
* Creates a Swing user interface that can be used to adjust all
|
* Creates a Swing user interface that can be used to adjust all
|
||||||
* registered runtime adjustments.
|
* registered runtime adjustments.
|
||||||
*/
|
*/
|
||||||
public static JPanel createAdjustEditor ()
|
public static JComponent createAdjustEditor ()
|
||||||
{
|
{
|
||||||
VGroupLayout layout = new VGroupLayout(
|
VGroupLayout layout = new VGroupLayout(
|
||||||
VGroupLayout.NONE, VGroupLayout.STRETCH,
|
VGroupLayout.NONE, VGroupLayout.STRETCH,
|
||||||
3, VGroupLayout.TOP);
|
3, VGroupLayout.TOP);
|
||||||
layout.setOffAxisJustification(VGroupLayout.LEFT);
|
layout.setOffAxisJustification(VGroupLayout.LEFT);
|
||||||
ScrollablePanel panel = new ScrollablePanel(layout);
|
|
||||||
panel.setTracksViewportWidth(true);
|
|
||||||
|
|
||||||
Font font = panel.getFont();
|
JTabbedPane editor = new JTabbedPane();
|
||||||
|
Font font = editor.getFont();
|
||||||
Font smaller = font.deriveFont(font.getSize()-1f);
|
Font smaller = font.deriveFont(font.getSize()-1f);
|
||||||
Font bigger = font.deriveFont(Font.BOLD, font.getSize()+2f);
|
|
||||||
|
|
||||||
String library = null;
|
String library = null;
|
||||||
|
ScrollablePanel lpanel = null;
|
||||||
String pkgname = null;
|
String pkgname = null;
|
||||||
CollapsiblePanel pkgpanel = null;
|
CollapsiblePanel pkgpanel = null;
|
||||||
|
|
||||||
@@ -79,9 +80,9 @@ public class RuntimeAdjust
|
|||||||
if (!adjust.getLibrary().equals(library)) {
|
if (!adjust.getLibrary().equals(library)) {
|
||||||
library = adjust.getLibrary();
|
library = adjust.getLibrary();
|
||||||
pkgname = null;
|
pkgname = null;
|
||||||
JLabel label = new JLabel(library, JLabel.CENTER);
|
lpanel = new ScrollablePanel(layout);
|
||||||
label.setFont(bigger);
|
lpanel.setTracksViewportWidth(true);
|
||||||
panel.add(label);
|
editor.addTab(library, lpanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a new package panel if necessary
|
// create a new package panel if necessary
|
||||||
@@ -94,17 +95,17 @@ public class RuntimeAdjust
|
|||||||
pkgpanel.setTriggerContainer(pkgcheck);
|
pkgpanel.setTriggerContainer(pkgcheck);
|
||||||
pkgpanel.getContent().setLayout(layout);
|
pkgpanel.getContent().setLayout(layout);
|
||||||
pkgpanel.setCollapsed(false);
|
pkgpanel.setCollapsed(false);
|
||||||
panel.add(pkgpanel);
|
lpanel.add(pkgpanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add an entry for this adjustment
|
// add an entry for this adjustment
|
||||||
pkgpanel.getContent().add(new JSeparator());
|
pkgpanel.getContent().add(new JSeparator());
|
||||||
JPanel editor = adjust.getEditor();
|
JPanel aeditor = adjust.getEditor();
|
||||||
editor.setFont(smaller);
|
aeditor.setFont(smaller);
|
||||||
pkgpanel.getContent().add(editor);
|
pkgpanel.getContent().add(aeditor);
|
||||||
}
|
}
|
||||||
|
|
||||||
return panel;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Provides runtime adjustable boolean variables. */
|
/** Provides runtime adjustable boolean variables. */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: AdjustTestApp.java,v 1.1 2003/01/15 00:47:06 mdb Exp $
|
// $Id: AdjustTestApp.java,v 1.2 2003/01/15 03:24:53 mdb Exp $
|
||||||
|
|
||||||
package com.samskivert.util;
|
package com.samskivert.util;
|
||||||
|
|
||||||
@@ -7,7 +7,6 @@ import java.awt.BorderLayout;
|
|||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does something extraordinary.
|
* Does something extraordinary.
|
||||||
@@ -38,11 +37,11 @@ public class AdjustTestApp
|
|||||||
"otherpackage.test.enum_adjust1", config,
|
"otherpackage.test.enum_adjust1", config,
|
||||||
new String[] { "debug", "info", "warning" }, "info");
|
new String[] { "debug", "info", "warning" }, "info");
|
||||||
|
|
||||||
JPanel editor = RuntimeAdjust.createAdjustEditor();
|
|
||||||
JFrame frame = new JFrame();
|
JFrame frame = new JFrame();
|
||||||
((JComponent)frame.getContentPane()).setBorder(
|
((JComponent)frame.getContentPane()).setBorder(
|
||||||
BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||||
frame.getContentPane().add(editor, BorderLayout.CENTER);
|
frame.getContentPane().add(RuntimeAdjust.createAdjustEditor(),
|
||||||
|
BorderLayout.CENTER);
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
frame.pack();
|
frame.pack();
|
||||||
frame.show();
|
frame.show();
|
||||||
|
|||||||
Reference in New Issue
Block a user