随笔-0  评论-15  文章-10  trackbacks-0

package cn.zbvc.java;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.plaf.synth.SynthLookAndFeel;
 
public class MyButton {
 JFrame frame 
= new JFrame("Test Buttons");
 JButton jButton 
= new JButton("JButton"); // 按钮
 public MyButton() {
  frame.setLayout(
new FlowLayout());
  frame.getContentPane().add(jButton);
 }
 
public void show() {
  frame.pack();
  frame.show();
 }
 
public static void main(String[] args) {
  MyButton tb 
= new MyButton();
  tb.show();
  SynthLookAndFeel slf 
= new SynthLookAndFeel();
  
try {
      slf.load(MyButton.
class.getResourceAsStream("mybutton.xml"), MyButton.class);
      UIManager.setLookAndFeel(slf);
  } 
catch (Exception e) {
      e.printStackTrace();
      
return;
  }

 }
}

/*
 *
 *<synth>
  <style id="mybutton">
     <state>
       <imagePainter method="buttonBackground" path="mybutton.png" sourceInsets="3 6 12 20" paintCenter="true" stretch="true"/>
    <insets top="3" left="6" bottom="12" right="20"/>
    <font name="Aharoni" size="16"/>
  </state>
  <property key="Button.margin" type="insets" value="0 0 5 8"/>
  </style>
  <bind style="mybutton" type="region" key="Button"/>
</synth>
 *
 *
*/
posted on 2011-07-10 10:08 吕鹏-Roc 阅读(967) 评论(0)  编辑  收藏 所属分类: Java常用代码

只有注册用户登录后才能发表评论。


网站导航: