📄 nimrodmain.java
字号:
/*
* (C) Copyright 2005 Nilo J. Gonzalez
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser Gereral Public Licence as published by the Free
* Software Foundation; either version 2 of the Licence, or (at your opinion) any
* later version.
*
* This library is distributed in the hope that it will be usefull, but WITHOUT ANY
* WARRANTY; without even the implied warranty of merchantability or fitness for a
* particular purpose. See the GNU Lesser General Public Licence for more details.
*
* You should have received a copy of the GNU Lesser General Public Licence along
* with this library; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, Ma 02111-1307 USA.
*
* http://www.gnu.org/licenses/lgpl.html (English)
* http://gugs.sindominio.net/gnu-gpl/lgpl-es.html (Espa駉l)
*
*
* Original author: Nilo J. Gonz醠ez
*/
/**
*
*/
package com.nilo.plaf.nimrod;
import java.awt.*;
import java.awt.event.*;
import java.beans.PropertyVetoException;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.tree.*;
import java.io.*;
import java.util.*;
/**
* This is only a facility to create themes and is poorly coded... Just works.
* @author Nilo J. Gonzalez
*/
public class NimRODMain extends JFrame {
private static final long serialVersionUID = 1L;
public static NimRODLookAndFeel nf;
public static NimRODTheme nt;
private JPanel bP1, bP2, bP3, bS1, bS2, bS3, bB, bW;
private JPanel bSelection, bBackground;
private JButton bOpen, bSave, bPrueba;
private JTextField tNomFich;
private JSlider sMenuOpacidad, sFrameOpacidad;
private JProgressBar pb3, pb4;
private JSpinner sp;
private JDesktopPane desktop;
private JPanel pConfig, pView1, pView2, pView3, pView4, pView5;
private JMenuBar menuBar;
private JTabbedPane tabPan;
private static int pos = 0;
NimRODMain() {
super( "NimROD Look&Feel Theme Configuration");
menuBar = new JMenuBar();
hazMenuBar();
setJMenuBar( menuBar);
hazConfig();
hazPreview1();
hazPreview2();
hazPreview3();
hazPreview4();
hazPreview5();
tabPan = new JTabbedPane();
tabPan.add( "Config", pConfig);
tabPan.add( "Preview 1", pView1);
tabPan.add( "Preview 2", pView2);
tabPan.add( "Preview 3", pView3);
tabPan.add( "Preview 4", pView4);
tabPan.add( "Preview 5", pView5);
getContentPane().add( tabPan, BorderLayout.CENTER);
addWindowListener( new MiWL());
setSize( 390,450);
setVisible( true);
}
private void hazMenuBar() {
JMenu menuTabs = new JMenu( "Tabs");
menuBar.add( menuTabs);
JMenuItem menuItem = new JMenuItem( "Top");
menuItem.addActionListener( new MiTL());
menuTabs.add( menuItem);
menuItem = new JMenuItem( "Bottom");
menuItem.addActionListener( new MiTL());
menuTabs.add( menuItem);
menuItem = new JMenuItem( "Left");
menuItem.addActionListener( new MiTL());
menuTabs.add( menuItem);
menuItem = new JMenuItem( "Right");
menuItem.addActionListener( new MiTL());
menuTabs.add( menuItem);
JMenu menuOtro = new JMenu( "Menu");
menuBar.add( menuOtro);
menuItem = new JMenuItem( "One item");
menuItem.setMnemonic( KeyEvent.VK_O);
menuOtro.add( menuItem);
menuItem = new JMenuItem( "Not enabled");
menuItem.setMnemonic( KeyEvent.VK_E);
menuItem.setEnabled( false);
menuOtro.add( menuItem);
menuItem = new JMenuItem( "Other item");
menuItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_4, ActionEvent.ALT_MASK));
menuOtro.add( menuItem);
menuItem = new JMenuItem( "Other Not enabled");
menuItem.setEnabled( false);
menuItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_5, ActionEvent.ALT_MASK));
menuOtro.add( menuItem);
ButtonGroup group = new ButtonGroup();
JRadioButtonMenuItem rbMi = new JRadioButtonMenuItem( "Cats", true);
rbMi.setMnemonic( KeyEvent.VK_G);
group.add( rbMi);
menuOtro.add( rbMi);
rbMi = new JRadioButtonMenuItem( "Dogs");
rbMi.setMnemonic( KeyEvent.VK_P);
rbMi.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_P, ActionEvent.CTRL_MASK));
group.add( rbMi);
menuOtro.add( rbMi);
rbMi = new JRadioButtonMenuItem( "Birds", true);
rbMi.setEnabled( false);
rbMi.setMnemonic( KeyEvent.VK_E);
group.add( rbMi);
menuOtro.add( rbMi);
rbMi = new JRadioButtonMenuItem( "Elephants");
rbMi.setEnabled( false);
rbMi.setMnemonic( KeyEvent.VK_V);
rbMi.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_V, ActionEvent.CTRL_MASK));
group.add( rbMi);
menuOtro.add( rbMi);
menuOtro.addSeparator();
JCheckBoxMenuItem cbMi = new JCheckBoxMenuItem( "Eat", true);
cbMi.setMnemonic( KeyEvent.VK_C);
menuOtro.add( cbMi);
cbMi = new JCheckBoxMenuItem( "Drink", false);
cbMi.setMnemonic( KeyEvent.VK_B);
cbMi.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_B, ActionEvent.CTRL_MASK));
menuOtro.add( cbMi);
cbMi = new JCheckBoxMenuItem( "Walk", true);
cbMi.setEnabled( false);
cbMi.setMnemonic( KeyEvent.VK_R);
menuOtro.add( cbMi);
cbMi = new JCheckBoxMenuItem( "Look", false);
cbMi.setEnabled( false);
cbMi.setMnemonic( KeyEvent.VK_M);
cbMi.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_M, ActionEvent.CTRL_MASK));
menuOtro.add( cbMi);
menuOtro.addSeparator();
JMenu submenu = new JMenu( "A submenu");
submenu.setMnemonic( KeyEvent.VK_S);
menuItem = new JMenuItem( "An item in the submenu");
menuItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_2, ActionEvent.ALT_MASK));
submenu.add( menuItem);
menuItem = new JMenuItem( "Another item");
submenu.add( menuItem);
menuItem = new JMenuItem( "Not enabled");
menuItem.setEnabled( false);
submenu.add( menuItem);
menuItem = new JMenuItem( "Not enabled, too");
menuItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_3, ActionEvent.ALT_MASK));
menuItem.setEnabled( false);
submenu.add( menuItem);
menuOtro.add( submenu);
JMenu masMenus = new JMenu( "Not enabled");
masMenus.setEnabled( false);
menuBar.add( masMenus);
}
private void hazConfig() {
// Para abrir y guardar
tNomFich = new JTextField( 20);
tNomFich.setEditable( false);
bOpen = new JButton( "Open");
bOpen.addActionListener( new MiAL());
bOpen.setToolTipText( "Open theme files");
bSave = new JButton( "Save");
bSave.setToolTipText( "Save theme files");
bSave.addActionListener( new MiAL());
JPanel pAlto = new JPanel( new FlowLayout());
pAlto.add( tNomFich);
pAlto.add( bOpen);
pAlto.add( bSave);
MiML ml = new MiML();
// Para los colores de seleccion
bSelection = hazPanel( ml);
bP1 = hazPanel( ml);
bP2 = hazPanel( ml);
bP3 = hazPanel( ml);
JPanel pSel = new JPanel( new GridLayout( 1,5, 3,3));
pSel.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Selection"));
pSel.add( bSelection);
pSel.add( new JLabel());
pSel.add( bP1);
pSel.add( bP2);
pSel.add( bP3);
// Para los colores de fondo
bBackground = hazPanel( ml);
bS1 = hazPanel( ml);
bS2 = hazPanel( ml);
bS3 = hazPanel( ml);
JPanel pFon = new JPanel( new GridLayout( 1,5, 3,3));
pFon.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Background"));
pFon.add( bBackground);
pFon.add( new JLabel());
pFon.add( bS1);
pFon.add( bS2);
pFon.add( bS3);
bB = hazPanel( ml);
bW = hazPanel( ml);
JPanel pBW = new JPanel( new GridLayout( 1,2, 3,3));
pBW.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Black & White"));
pBW.add( bB);
pBW.add( bW);
bPrueba = new JButton( "Test");
bPrueba.setToolTipText( "Test current selection");
bPrueba.addActionListener( new MiAL());
JPanel pMenuOp = new JPanel();
pMenuOp.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Menu Opacity"));
sMenuOpacidad = new JSlider( SwingConstants.HORIZONTAL, 0, 255, nt.getMenuOpacity());
pMenuOp.add( sMenuOpacidad);
JPanel pFrameOp = new JPanel();
pFrameOp.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Internal Frame Opacity"));
sFrameOpacidad = new JSlider( SwingConstants.HORIZONTAL, 0, 255, nt.getFrameOpacity());
pFrameOp.add( sFrameOpacidad);
hazPaleta();
pConfig = new JPanel( new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets( 5,5,5,5);
c.gridwidth = 2;
c.gridx = 0; c.gridy = 0;
pConfig.add( pAlto, c);
c.gridwidth = 1;
c.gridx = 0; c.gridy = 1;
pConfig.add( pSel, c);
c.gridx = 1; c.gridy = 1;
pConfig.add( pBW, c);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -