tonicdemodialog.java
来自「用于java swing的皮肤软件」· Java 代码 · 共 153 行
JAVA
153 行
package com.digitprop.tonicdemo;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.digitprop.tonic.VariableGridLayout;
/** Demo dialog for the Tonic look and feel.
*
* @author Markus Fischer
*
* <p>This software is under the <a href="http://www.gnu.org/copyleft/lesser.html" target="_blank">GNU Lesser General Public License</a>
*/
/*
* ------------------------------------------------------------------------
* Copyright (C) 2004 Markus Fischer
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* You can contact the author at:
* Markus Fischer
* www.digitprop.com
* info@digitprop.com
* ------------------------------------------------------------------------
*/
public class TonicDemoDialog extends JDialog implements ActionListener
{
/** Creates an instance for the specified frame, with the
* specified title.
*/
public TonicDemoDialog(Frame owner, String title)
{
super(owner, title, true);
initGUI();
pack();
setSize(400, getHeight());
}
/** Initializes the GUI components of this dialog. The central part
* of the dialog is a JTabbedPane
*/
public void initGUI()
{
JTabbedPane tabbedPane=new JTabbedPane();
JPanel mainPanel=new JPanel();
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
mainPanel.add(new TitledSeparator("Magnetic core settings"));
mainPanel.add(createMagneticCoreSettings());
mainPanel.add(Box.createVerticalStrut(20));
mainPanel.add(new TitledSeparator("Stratospheric extractor unit"));
mainPanel.add(createStratosphericSettings());
mainPanel.add(Box.createVerticalStrut(20));
mainPanel.add(new TitledSeparator("Itinerary"));
mainPanel.add(createItinerary());
mainPanel.add(Box.createVerticalStrut(30));
mainPanel.add(createButtonPanel());
JPanel firstPanel=new JPanel(new BorderLayout());
firstPanel.add(BorderLayout.NORTH, mainPanel);
firstPanel.add(BorderLayout.CENTER, new JPanel());
tabbedPane.addTab("General", firstPanel);
JPanel emptyPanel=new JPanel(new BorderLayout());
JLabel label=new JLabel("This panel intentionally left blank");
label.setHorizontalAlignment(JLabel.CENTER);
emptyPanel.add(BorderLayout.CENTER, label);
tabbedPane.addTab("Advanced", emptyPanel);
emptyPanel=new JPanel(new BorderLayout());
label=new JLabel("This panel intentionally left blank");
label.setHorizontalAlignment(JLabel.CENTER);
emptyPanel.add(BorderLayout.CENTER, label);
tabbedPane.addTab("Ultra", emptyPanel);
emptyPanel=new JPanel(new BorderLayout());
label=new JLabel("This panel intentionally left blank");
label.setHorizontalAlignment(JLabel.CENTER);
emptyPanel.add(BorderLayout.CENTER, label);
tabbedPane.addTab("Time", emptyPanel);
JPanel centerPanel=new JPanel(new BorderLayout());
centerPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
centerPanel.add(tabbedPane);
getContentPane().add(BorderLayout.CENTER, centerPanel);
}
/** Creates the button panel at the bottom of the dialog */
private JPanel createButtonPanel()
{
JPanel result=new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 0));
JButton button=new JButton("Ok");
setPreferredButtonSize(button, 75, 0);
button.addActionListener(this);
result.add(button);
button=new JButton("Cancel");
setPreferredButtonSize(button, 75, 0);
button.addActionListener(this);
result.add(button);
return result;
}
private void setPreferredButtonSize(JButton button, int width, int height)
{
Dimension d=button.getPreferredSize();
width=Math.max(width, d.width);
height=Math.max(height, d.height);
button.setPreferredSize(new Dimension(width, height));
}
/** Creates a panel with some components */
private JPanel createMagneticCoreSettings()
{
String fields[]=
{
"Heat dissipation:", "22.5",
"Buoancy:", "0.54",
"Bearing:", "14
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?