zoukankan      html  css  js  c++  java
  • Swing 按钮图片位置以及按钮文字位置

    我为了实现:

    图片在上 文字在下的效果
     
    我的代码:
    imgPanel.setLayout(new GridLayout(3,3,20,20));
          
           RolloverButton ib1=new RolloverButton("房产管理",MyPluginRes.getImageIcon(MyPluginRes.ESTATERES));
           ib1.setVerticalTextPosition(SwingConstants.BOTTOM);  //必须设置文字树直方向位置
           ib1.setHorizontalTextPosition(SwingConstants.CENTER);//必须设置文字水平方向位置

    摘自: http://blog.chinaunix.net/uid-22375044-id-3086641.html

    1 JButton 图片和文字按钮的实现

     
     

    JButton btn1 = new JButton("打开", new ImageIcon(ImageView.class.getResource("10.png"))) ;

    btn1.setHorizontalTextPosition(SwingConstants.CENTER);

    btn1.setVerticalTextPosition(SwingConstants.BOTTOM);

    效果图 :

    clip_image003

    2 JButton 图片透明按钮的实现

     
     

    setLayout(new FlowLayout(FlowLayout.RIGHT, 30, 0));

    btn1.setIcon(UIConfig.getImgUrl("常用交易字.png"));

    btn1.setRolloverIcon(UIConfig.getImgUrl("常用交易.png"));

    btn1.setBorderPainted(false);

    btn1.setFocusPainted(false);

    btn1.setContentAreaFilled(false);

    btn1.setFocusable(true);

    btn1.setMargin(new Insets(0, 0, 0, 0));

    btn1.setText("常用交易");

    clip_image006

    3JRadioButton 图片透明按钮的实现

    JRadioButton radio = new JRadioButton(UIConfig.getImgUrl("常用交易字.png") );

    radio.setContentAreaFilled(false);

    radio.setRolloverIcon(UIConfig.getImgUrl("常用交易.png"));

    radio.setSelectedIcon(UIConfig.getImgUrl("常用交易.png"));

    clip_image006[1]

    I'm falling off the sky all alone.The courage inside is gonna break the fall. Nothing can dim my light within. I am That I am 程序 = 数据结构 + 算法
  • 相关阅读:
    Windows 10 开发日记(二)-- 手势顺序调研
    Windows 10 开发日记(一) -- 手势通览
    开篇说两句
    我从上海回苏州了,你懂的!
    数组名相关
    指针相关笔记
    static相关
    输入分式,输出化简式的C语言算法
    语句界定
    switch相关
  • 原文地址:https://www.cnblogs.com/IamThat/p/2945846.html
Copyright © 2011-2022 走看看