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 程序 = 数据结构 + 算法
  • 相关阅读:
    关于virtual、非virtual继承函数的调用
    关于文件操作的文件格式与打开方式
    C++ 文件读写操作
    C++语法题
    检测java string变量是否含有中文
    常用知识库
    WMS仓储管理系统
    运输管理
    ipconfig/flushdns 清除系统DNS缓存
    cmd查看域名账号相关的命令
  • 原文地址:https://www.cnblogs.com/IamThat/p/2945846.html
Copyright © 2011-2022 走看看