我用的5.0版本的,不知道为什么总是显示不出来水印
public class TestIco extends JFrame { private JPanel contentPane; /**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
SubstanceImageWater water = new SubstanceImageWater(
TestIco.class.getResourceAsStream("img/03.jpg"));
// water.setKind(ImageWaterKind.SCREEN_CENTER_SCALE);
water.setOpacity(0.5f);// 设置水印透明度
SubstanceSkin skin = new OfficeBlue2007Skin()
.withWater(water); // 初始化有水印的皮肤 UIManager.setLookAndFeel(new SubstanceOfficeBlue2007LookAndFeel());
SubstanceLookAndFeel.setSkin(skin); // 设置皮肤 TestIco frame = new TestIco();
frame.setVisible(true); } catch (Exception e) {
e.printStackTrace();
}
}
});
} /**
* Create the frame.
*/
public TestIco() {
Image icon2 = this.getToolkit().getImage("img/03.jpg");
this.setIconImage(icon2);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
JButton btnNewButton = new JButton("New button");
contentPane.add(btnNewButton, BorderLayout.WEST); }}麻烦各位帮忙看看
public class TestIco extends JFrame { private JPanel contentPane; /**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
SubstanceImageWater water = new SubstanceImageWater(
TestIco.class.getResourceAsStream("img/03.jpg"));
// water.setKind(ImageWaterKind.SCREEN_CENTER_SCALE);
water.setOpacity(0.5f);// 设置水印透明度
SubstanceSkin skin = new OfficeBlue2007Skin()
.withWater(water); // 初始化有水印的皮肤 UIManager.setLookAndFeel(new SubstanceOfficeBlue2007LookAndFeel());
SubstanceLookAndFeel.setSkin(skin); // 设置皮肤 TestIco frame = new TestIco();
frame.setVisible(true); } catch (Exception e) {
e.printStackTrace();
}
}
});
} /**
* Create the frame.
*/
public TestIco() {
Image icon2 = this.getToolkit().getImage("img/03.jpg");
this.setIconImage(icon2);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
JButton btnNewButton = new JButton("New button");
contentPane.add(btnNewButton, BorderLayout.WEST); }}麻烦各位帮忙看看
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货