/* * LookFeelJInternalFrame.java * */
package alljava;import javax.swing.*;import java.util.jar.*;import java.util.*;/** *本例程实现能过substanc挂接实现对swing的灵活换肤 */public class LookFeelJInternalFrame extends javax.swing.JInternalFrame { static LookFeelJInternalFrame lookFeelWindow=null; public static void main(String args[]){ JFrame.setDefaultLookAndFeelDecorated(true); openLookFeelWindow(); } public static void openLookFeelWindow(){ if (lookFeelWindow == null){ javax.swing.JFrame jf=new JFrame("NetJava.org换肤演示"); jf.pack(); lookFeelWindow = new LookFeelJInternalFrame(); jf.add(lookFeelWindow); jf.setVisible(true); jf.setSize(800,600); } lookFeelWindow.pack(); lookFeelWindow.setVisible(true); lookFeelWindow.show(); lookFeelWindow.moveToFront(); lookFeelWindow.requestFocus(); try{ lookFeelWindow.setSelected(true); }catch ( java.beans.PropertyVetoException e){ System.out.println("open error: "+e); } } /** Creates new form LookFeelJInternalFrame */ public LookFeelJInternalFrame() { initComponents(); //加入titlePainter listTitlePainter.add("org.jvnet.substance.title.ClassicTitlePainter"); listTitlePainter.add("org.jvnet.substance.title.Glass3DTitlePainter"); listTitlePainter.add("org.jvnet.substance.title.RandomCubesTitlePainter"); try{ //加入sun的lookfeel listJava.add("javax.swing.plaf.metal.MetalLookAndFeel"); listJava.add("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); listJava.add("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); listJava.add("com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel");
initSubstanceLookFeel();jComboBoxJavaSkin.setModel(new javax.swing.DefaultComboBoxModel(listJava.toArray()));jComboBox2SubSkin.setModel(new javax.swing.DefaultComboBoxModel(listSkin.toArray()));jComboBoxSubTheme.setModel(new javax.swing.DefaultComboBoxModel(listTheme.toArray()));jComboBoxSubLookFeel.setModel(new javax.swing.DefaultComboBoxModel(listLookAndFeel.toArray()));jComboBoxMark.setModel(new javax.swing.DefaultComboBoxModel(listTitleWatermark.toArray()));jListGradientPainter.setListData(listGradientPainter.toArray());
}catch(Exception ef){ ef.printStackTrace(); System.out.println("create Look Feel error: "+ef); } }
/** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc=" 生成的代码 "> private void initComponents() { buttonGroup1 = new javax.swing.ButtonGroup(); jComboBoxJavaSkin = new javax.swing.JComboBox(); jLabel1 = new javax.swing.JLabel(); jComboBox2SubSkin = new javax.swing.JComboBox(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jComboBoxSubTheme = new javax.swing.JComboBox(); jLabel4 = new javax.swing.JLabel(); jComboBoxSubLookFeel = new javax.swing.JComboBox(); jLabel5 = new javax.swing.JLabel(); jSeparator1 = new javax.swing.JSeparator(); jRadioButton1 = new javax.swing.JRadioButton(); jScrollPane1 = new javax.swing.JScrollPane(); jListGradientPainter = new javax.swing.JList(); jLabel6 = new javax.swing.JLabel(); jRadioButton2 = new javax.swing.JRadioButton(); jRadioButton3 = new javax.swing.JRadioButton(); jLabel7 = new javax.swing.JLabel(); jLabel8 = new javax.swing.JLabel(); jComboBoxMark = new javax.swing.JComboBox(); jPanel1 = new javax.swing.JPanel(); jSliderWaterMark = new javax.swing.JSlider(); jTextField1 = new javax.swing.JTextField(); jCheckBox1 = new javax.swing.JCheckBox(); jButton1 = new javax.swing.JButton();
setBorder(javax.swing.BorderFactory.createMatteBorder(1, 2, 1, 2, new java.awt.Color(0, 0, 0))); setClosable(true); setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE); setTitle("/u9009/u62e9/u6362/u80a4"); jComboBoxJavaSkin.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); jComboBoxJavaSkin.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBoxJavaSkinActionPerformed(evt); } });
jLabel1.setText("JDK/u9009/u9879/uff1a");
jComboBox2SubSkin.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); jComboBox2SubSkin.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox2SubSkinActionPerformed(evt); } });
jLabel2.setText("Substance/u9009/u9879/uff1a");
jLabel3.setText("Skin /uff1a");
jComboBoxSubTheme.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); jComboBoxSubTheme.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBoxSubThemeActionPerformed(evt); } });
jLabel4.setText("Theme /uff1a");
jComboBoxSubLookFeel.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); jComboBoxSubLookFeel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBoxSubLookFeelActionPerformed(evt); } });
jLabel5.setText("Look Feel/uff1a");
buttonGroup1.add(jRadioButton1); jRadioButton1.setText("ClassicTitlePainter"); jRadioButton1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); jRadioButton1.setMargin(new java.awt.Insets(0, 0, 0, 0)); jRadioButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton1ActionPerformed(evt); } });
jListGradientPainter.setBorder(javax.swing.BorderFactory.createTitledBorder("")); jListGradientPainter.setModel(new javax.swing.AbstractListModel() { String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; public int getSize() { return strings.length; } public Object getElementAt(int i) { return strings[i]; } }); jListGradientPainter.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); jListGradientPainter.setDoubleBuffered(true); jListGradientPainter.addListSelectionListener(new javax.swing.event.ListSelectionListener() { public void valueChanged(javax.swing.event.ListSelectionEvent evt) { jListGradientPainterValueChanged(evt); } }); jListGradientPainter.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jListGradientPainterMouseClicked(evt); } });
jScrollPane1.setViewportView(jListGradientPainter);
jLabel6.setText("Title Painter/uff1a");
buttonGroup1.add(jRadioButton2); jRadioButton2.setText("Glass3DTitlePainter"); jRadioButton2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); jRadioButton2.setMargin(new java.awt.Insets(0, 0, 0, 0)); jRadioButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton2ActionPerformed(evt); } });
buttonGroup1.add(jRadioButton3); jRadioButton3.setText("RandomCubesTitlePainter"); jRadioButton3.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); jRadioButton3.setMargin(new java.awt.Insets(0, 0, 0, 0)); jRadioButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton3ActionPerformed(evt); } });
jLabel7.setText("Gradient/uff1a");
jLabel8.setText("Watermark/uff1a");
jComboBoxMark.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); jComboBoxMark.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBoxMarkActionPerformed(evt); } });
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Test")); jSliderWaterMark.setMajorTickSpacing(1); jSliderWaterMark.setMaximum(10); jSliderWaterMark.setPaintLabels(true); jSliderWaterMark.setPaintTicks(true); jSliderWaterMark.setValue(0); jSliderWaterMark.setAutoscrolls(true); jSliderWaterMark.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { public void mouseDragged(java.awt.event.MouseEvent evt) { jSliderWaterMarkMouseDragged(evt); } }); jSliderWaterMark.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { jSliderWaterMarkStateChanged(evt); } }); jSliderWaterMark.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jSliderWaterMarkMouseClicked(evt); } public void mouseEntered(java.awt.event.MouseEvent evt) { jSliderWaterMarkMouseEntered(evt); } }); jSliderWaterMark.addVetoableChangeListener(new java.beans.VetoableChangeListener() { public void vetoableChange(java.beans.PropertyChangeEvent evt)throws java.beans.PropertyVetoException { jSliderWaterMarkVetoableChange(evt); } });
jTextField1.setText("www.NetJava.org");
jCheckBox1.setText("jCheckBox1"); jCheckBox1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); jCheckBox1.setMargin(new java.awt.Insets(0, 0, 0, 0));
jButton1.setText("jButton1");
org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1Layout.createSequentialGroup() .addContainerGap() .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jSliderWaterMark, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE) .add(jCheckBox1) .add(jButton1) .add(jTextField1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)) .addContainerGap()) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup() .addContainerGap() .add(jCheckBox1) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jButton1) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 17, Short.MAX_VALUE) .add(jSliderWaterMark, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 47, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addContainerGap()) );
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(37, 37, 37) .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 66, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(12, 12, 12) .add(jComboBoxJavaSkin, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 356, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)) .add(layout.createSequentialGroup() .add(32, 32, 32) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 439, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jLabel5) .add(jLabel4) .add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 63, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(jLabel8)) .add(jLabel7)) .add(13, 13, 13) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 361, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() .add(3, 3, 3) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jComboBox2SubSkin, 0, 358, Short.MAX_VALUE) .add(jComboBoxSubTheme, 0, 358, Short.MAX_VALUE) .add(jComboBoxSubLookFeel, 0, 358, Short.MAX_VALUE))) .add(jComboBoxMark, 0, 361, Short.MAX_VALUE)) .add(12, 12, 12)) .add(layout.createSequentialGroup() .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 120, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 320, Short.MAX_VALUE))) .add(5, 5, 5))))) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jLabel6) .add(layout.createSequentialGroup() .add(10, 10, 10) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jRadioButton1) .add(jRadioButton2) .add(jRadioButton3)))) .add(29, 29, 29)) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jLabel1) .add(jComboBoxJavaSkin, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(16, 16, 16) .add(jSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel2) .add(jLabel6)) .add(14, 14, 14) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(jComboBoxSubLookFeel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(17, 17, 17) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jComboBox2SubSkin, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jLabel3))) .add(jLabel5) .add(layout.createSequentialGroup() .add(jRadioButton1) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jRadioButton2) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jRadioButton3))) .add(14, 14, 14) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jComboBoxSubTheme, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jLabel4)) .add(24, 24, 24) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 78, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jLabel7)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 38, Short.MAX_VALUE) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jComboBoxMark, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jLabel8))) .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .add(34, 34, 34)) ); pack(); }// </editor-fold>
//select Mark: private void jComboBoxMarkActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: // org.jvnet.substance.watermark.SubstanceImageWatermark.setOpacity(0.9f); // org.jvnet.substance.SubstanceLookAndFeel.setCurrentWatermark("org.jvnet.substance.watermark.SubstanceImageWatermark"); org.jvnet.substance.SubstanceLookAndFeel.setCurrentWatermark((String)jComboBoxMark.getSelectedItem()); forRePaint(); }
private void jSliderWaterMarkMouseEntered(java.awt.event.MouseEvent evt) { // TODO add your handling code here: }
private void jSliderWaterMarkMouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: }
private void jSliderWaterMarkMouseDragged(java.awt.event.MouseEvent evt) { // TODO add your handling code here:
}
private void jSliderWaterMarkVetoableChange(java.beans.PropertyChangeEvent evt)throws java.beans.PropertyVetoException { } private void jSliderWaterMarkStateChanged(javax.swing.event.ChangeEvent evt) { // TODO add your handling code here: // System.out.println("current is: "+jSliderWaterMark.getValue()); jButton1.setText("Is: "+jSliderWaterMark.getValue()); }
private void jListGradientPainterMouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: }
private void jRadioButton3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: org.jvnet.substance.SubstanceLookAndFeel.setCurrentTitlePainter(listTitlePainter.get(2).toString()); forRePaint(); }
private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: org.jvnet.substance.SubstanceLookAndFeel.setCurrentTitlePainter(listTitlePainter.get(1).toString()); forRePaint(); }
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: org.jvnet.substance.SubstanceLookAndFeel.setCurrentTitlePainter(listTitlePainter.get(0).toString()); forRePaint(); }
private void jListGradientPainterValueChanged(javax.swing.event.ListSelectionEvent evt) { // TODO add your handling code here: org.jvnet.substance.SubstanceLookAndFeel.setCurrentGradientPainter(jListGradientPainter.getSelectedValue().toString()); forRePaint(); } private void jComboBoxSubLookFeelActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try{
UIManager.setLookAndFeel((String)jComboBoxSubLookFeel.getSelectedItem()); // UIManager.setLookAndFeel("org.jvnet.substance.SubstanceLookAndFeel"); // org.jvnet.substance.SubstanceLookAndFeel.setCurrentWatermark("org.jvnet.substance.watermark.SubstanceImageWatermark"); }catch(Exception ef){ ef.printStackTrace(); JOptionPane.showMessageDialog(this, "第三方库换肤失败!"+ef.getMessage(), "错误!", JOptionPane.ERROR_MESSAGE); } forRePaint(); }
private void jComboBoxSubThemeActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: org.jvnet.substance.SubstanceLookAndFeel.setCurrentTheme((String)jComboBoxSubTheme.getSelectedItem()); forRePaint(); }
private void jComboBox2SubSkinActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: org.jvnet.substance.SubstanceLookAndFeel.setSkin((String)jComboBox2SubSkin.getSelectedItem()); forRePaint(); } //选择了java lookFeel: private void jComboBoxJavaSkinActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String tems=(String)jComboBoxJavaSkin.getSelectedItem(); tems.trim(); try{ UIManager.setLookAndFeel(tems); forRePaint(); }catch(Exception ef){ ef.printStackTrace(); JOptionPane.showMessageDialog(this, "JDK换肤失败!"+ef.getMessage(), "错误!", JOptionPane.ERROR_MESSAGE); } }
public void forRePaint(){// org.jvnet.substance.watermark.SubstanceFabricWatermark;// org.jvnet.substance.SubstanceLookAndFeel.setCurrentWatermark( ) SwingUtilities.updateComponentTreeUI(this.getParent()); } public void initSubstanceLookFeel(){ try{ java.util.jar.JarFile jf=new JarFile("E://substance.jar"); java.util.Enumeration<JarEntry> em= jf.entries(); while(em.hasMoreElements()){ java.util.jar.JarEntry jre=em.nextElement(); String tems=jre.toString(); if(tems.startsWith("org/jvnet/substance/skin/")&&tems.endsWith("Skin.class")){ tems=replace(tems,".class","").trim(); tems=replace(tems,"/","."); listSkin.add(tems); // System.out.println("Skin ****: "+tems); } if(tems.startsWith("org/jvnet/substance/skin/")&&tems.endsWith("LookAndFeel.class")){ tems=replace(tems,".class","").trim(); tems=replace(tems,"/","."); listLookAndFeel.add(tems); // System.out.println("LookAndFeel----: "+tems); } if(tems.startsWith("org/jvnet/substance/theme/")&&tems.endsWith("Theme.class")){ tems=replace(tems,".class","").trim(); tems=replace(tems,"/","."); listTheme.add(tems); // System.out.println("Theme > > >: "+tems); } if(tems.startsWith("org/jvnet/substance/painter/")&&tems.endsWith("GradientPainter.class")){ tems=replace(tems,".class","").trim(); tems=replace(tems,"/","."); listGradientPainter.add(tems); // System.out.println("Theme > > >: "+tems); } if(tems.startsWith("org/jvnet/substance/watermark/")&&tems.endsWith("Watermark.class")){ tems=replace(tems,".class","").trim(); tems=replace(tems,"/","."); listTitleWatermark.add(tems); // System.out.println("Theme > > >: "+tems); } } }catch(Exception ef){ JOptionPane.showMessageDialog(this, "无法找到换肤库!"+ef.getMessage(), "错误!", JOptionPane.ERROR_MESSAGE); dispose();//关掉 } } static String replace(java.lang.String strSource, java.lang.String strFrom, java.lang.String strTo) { java.lang.String strDest = ""; int intFromLen = strFrom.length(); int intPos; while ( (intPos = strSource.indexOf(strFrom)) != -1) { strDest = strDest + strSource.substring(0, intPos); strDest = strDest + strTo; strSource = strSource.substring(intPos + intFromLen); } strDest = strDest + strSource;
return strDest; }
private static List<String> listTheme=new ArrayList(); private static List<String> listLookAndFeel=new ArrayList(); private static List<String> listSkin=new ArrayList(); private static List<String> listGradientPainter=new ArrayList(); private static List<String> listTitlePainter=new ArrayList(); private static List<String> listTitleWatermark=new ArrayList(); private static List<String> listJava=new ArrayList(); // 变量声明 - 不进行修改 private javax.swing.ButtonGroup buttonGroup1; private javax.swing.JButton jButton1; private javax.swing.JCheckBox jCheckBox1; private javax.swing.JComboBox jComboBox2SubSkin; private javax.swing.JComboBox jComboBoxJavaSkin; private javax.swing.JComboBox jComboBoxMark; private javax.swing.JComboBox jComboBoxSubLookFeel; private javax.swing.JComboBox jComboBoxSubTheme; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JList jListGradientPainter; private javax.swing.JPanel jPanel1; private javax.swing.JRadioButton jRadioButton1; private javax.swing.JRadioButton jRadioButton2; private javax.swing.JRadioButton jRadioButton3; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JSeparator jSeparator1; private javax.swing.JSlider jSliderWaterMark; private javax.swing.JTextField jTextField1; // 变量声明结束 }