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 程序 = 数据结构 + 算法
  • 相关阅读:
    BZOJ 1207
    Poj 2096 Collecting Bugs (概率DP求期望)
    HDU 5159 Card (概率求期望)
    HDU 4649 Professor Tian (概率DP)
    HDU 4652 Dice (概率DP)
    HDU5001 Walk(概率DP)
    C++中的 Round(),floor(),ceil()
    HDU 5245 Joyful(概率题求期望)
    poj 3071 Football (概率DP水题)
    关于一个群号分解的最大质数的求法
  • 原文地址:https://www.cnblogs.com/IamThat/p/2945846.html
Copyright © 2011-2022 走看看