zoukankan      html  css  js  c++  java
  • JButton大小设置问题?

    JButton在FlowLayout、BorderLayout等一些布局中使用setSize()设置大小没效果,可以使用setPreferredSize方法进行设置,例如:

    public static void main(String[] args) {
      JFrame frame = new JFrame();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setLayout(new FlowLayout());
      JButton button = new JButton("测试按钮");
      Dimension preferredSize = new Dimension(300,100);//设置尺寸
      button.setPreferredSize(preferredSize );
      frame.add(button);
      frame.setBounds(0,0, 400, 300);
      frame.setVisible(true);
     }

  • 相关阅读:
    毕设进度28
    任务27
    任务26
    任务25
    任务24
    第二次冲刺
    课堂作业-搜狗输入法
    课堂作业-寻找水王
    博客花园典型用户和场景
    第十天
  • 原文地址:https://www.cnblogs.com/tianguook/p/2377929.html
Copyright © 2011-2022 走看看