⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demopanel.java

📁 java 开源,Swing外观:JGoodies look & feel. ... JGoodies look&feels让你的Swing 应用程序与applets看起来更漂亮.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* ==================================================================== * Copyright (c) 2001-2003 OYOAHA. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * * 2. The names "OYOAHA" must not be used to endorse or promote products  *    derived from this software without prior written permission.  *    For written permission, please contact email@oyoaha.com. * * 3. Products derived from this software may not be called "OYOAHA", *    nor may "OYOAHA" appear in their name, without prior written *    permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL OYOAHA OR ITS CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */package com.oyoaha.swing.plaf.oyoaha;import javax.swing.*;import javax.swing.table.*;import java.awt.*;import java.awt.event.*;import java.io.*;public class DemoPanel extends JPanel implements ActionListener{  private final static Insets insets = new Insets(4,4,4,4);    private JTabbedPane tabbedPane;  private JDesktopPane desktop;  private JButton paletteButton;  private JTextArea text;  private JSplitPane jSplitPane;  private JList list;  private JTree tree;  private JInternalFrame palette;  private JTable table;  private JToolBar tools;  private JRadioButton radioButton;  private JCheckBox checkBox;  private JComboBox comboBox;  private JComboBox comboBox2;  private JToggleButton toggleButton;  private JSlider slider;       private JTextField textField;  private JScrollBar scrollBar;  private JLabel label;    private JToolBar jtools;  private JRadioButton jradioButton;  private JCheckBox jcheckBox;  private JComboBox jcomboBox;  private JToggleButton jtoggleButton;  private JLabel jlabel;  public DemoPanel()  {    tabbedPane = new JTabbedPane();    tabbedPane.setVisible(false);    setLayout(new BorderLayout());    add(tabbedPane, BorderLayout.CENTER);    Thread t = new Thread(new LoadDemoPanel());    t.start();  }  public JTabbedPane getTabbedPane()  {    return tabbedPane;  }    public void setEnabled(boolean enabled)  {    if(tabbedPane!=null)    tabbedPane.setEnabled(enabled);        if (desktop!=null)    {        JInternalFrame[] f = desktop.getAllFrames();                for(int i=0;i<f.length;i++)        {            if(f[i]!=null)            f[i].setEnabled(enabled);        }    }        if(text!=null)    text.setEnabled(enabled);    if(table!=null)    table.setEnabled(enabled);    if(paletteButton!=null)    paletteButton.setEnabled(enabled);        if(tree!=null)    tree.setEnabled(enabled);    if(list!=null)        list.setEnabled(enabled);    if(jSplitPane!=null)        jSplitPane.setEnabled(enabled);        if (tools!=null)    {        for(int i=0;;i++)        {            Component c = tools.getComponentAtIndex(i);                        if(c==null)            break;                        c.setEnabled(enabled);        }        }        if(radioButton!=null)         radioButton.setEnabled(enabled);        if(checkBox!=null)     checkBox.setEnabled(enabled);        if(comboBox!=null)     comboBox.setEnabled(enabled);        if(comboBox2!=null)     comboBox2.setEnabled(enabled);        if(toggleButton!=null)     toggleButton.setEnabled(enabled);        if(slider!=null)     slider.setEnabled(enabled);        if(textField!=null)     textField.setEnabled(enabled);        if(scrollBar!=null)     scrollBar.setEnabled(enabled);        if(label!=null)     label.setEnabled(enabled);        if (jtools!=null)    {        for(int i=0;;i++)        {            Component c = jtools.getComponentAtIndex(i);                        if(c==null)            break;                        c.setEnabled(enabled);        }        }        if(jradioButton!=null)         jradioButton.setEnabled(enabled);        if(jcheckBox!=null)     jcheckBox.setEnabled(enabled);        if(jcomboBox!=null)     jcomboBox.setEnabled(enabled);        if(jtoggleButton!=null)     jtoggleButton.setEnabled(enabled);        if(jlabel!=null)     jlabel.setEnabled(enabled);    }  public Component getRoot()  {    return SwingUtilities.getRoot(this);  }  public void actionPerformed(ActionEvent e)  {    openImage();  }  private JComponent createTableDemoPanel()  {    JPanel panel = new JPanel();    DefaultTableModel model = new DefaultTableModel();    table  = new JTable(model);    for(int i=0;i<5;i++)    {      model.addColumn("Col " + i);    }    for(int i=0;i<10;i++)    {      Object[] o = new Object[5];      for(int u=0;u<5;u++)      {        if(u<3)        o[u] = new Integer(i);        else        if(u==3)        o[u] = new Boolean(true);        else        o[u] = "cell " + i;      }      model.addRow(o);    }    table.setRowHeight(22);    panel.setLayout(new BorderLayout());    JScrollPane scroll = new JScrollPane(table);    scroll.setPreferredSize(new Dimension(420,320));    panel.add(scroll);    return panel;  }  private JComponent createInfoDemoPanel()  {    JPanel panel = new JPanel();    text = new JTextArea();    text.setEditable(false);    text.setLineWrap(true);    text.setWrapStyleWord(true);    updateLnFInformation();    panel.setLayout(new BorderLayout());    JScrollPane scroll = new JScrollPane(text);    scroll.setPreferredSize(new Dimension(420,320));    panel.add(scroll);    return panel;  }  private JComponent createWindowsDemoPanel()  {    desktop = new JDesktopPane();    palette = new JInternalFrame("Palette");    palette.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);    palette.setResizable(true);    palette.setClosable(false);    palette.setMaximizable(false);    palette.setIconifiable(false);    palette.getContentPane().setLayout(new BorderLayout());    palette.setLocation(30,30);    paletteButton = new JButton("Open a picture...");    paletteButton.addActionListener(this);    palette.getContentPane().add(paletteButton, BorderLayout.CENTER);    palette.pack();    desktop.add(palette, JDesktopPane.PALETTE_LAYER);    palette.setVisible(true);    desktop.setPreferredSize(new Dimension(420,320));    return desktop;  }  private JComponent createSplitDemoPanel()  {    JPanel jPanel = new JPanel();    String[] data = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"};    list = new JList(data);    tree = new JTree();    tree.setEditable(true);    JScrollPane scroll1 = new JScrollPane(tree);    JScrollPane scroll2 = new JScrollPane(list);    scroll1.setPreferredSize(new Dimension(210,320));    scroll2.setPreferredSize(new Dimension(210,320));    jSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scroll1, scroll2);    jSplitPane.setOneTouchExpandable(true);    jSplitPane.setContinuousLayout(true);        jPanel.setLayout(new BorderLayout());    jPanel.add(jSplitPane, BorderLayout.CENTER);    return jPanel;  }  private JComponent createClassicDemoPanel()  {    JPanel p = new JPanel();    p.setLayout(new GridBagLayout());    tools = new JToolBar();    for(int i=0;i<5;i++)    {      JButton tb = new JButton("tool " + i);      tb.setToolTipText("Toolbar button" + i);      tools.add(tb);    }    tools.setFloatable(false);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -