微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我只能看到 (1,3) 网格布局 jpanel 中的中间组件有任何解决这个问题的方法吗?

如何解决我只能看到 (1,3) 网格布局 jpanel 中的中间组件有任何解决这个问题的方法吗?

我似乎无法查看 a1 JPanel 中的所有三个组件(JTextPanel、Image 和 Button),它只显示中间组件(在这种情况下仅显示图片)。而如果我删除 JTextPanel,我可以看到其他两个组件。

 GridLayout sold = new GridLayout(1,3);
            JPanel a1 = new JPanel();
            JPanel a2 = new JPanel();
            JPanel a3 = new JPanel();
            JPanel a4 = new JPanel();
    
    a1.setLayout(sold);
    a2.setLayout(sold);
    a3.setLayout(sold);
    a4.setLayout(sold);
    
    JPanel t1 = new JPanel();
    ImageIcon Img = new ImageIcon("images/shopPane.jpg");
    JLabel lblNewLabel = new JLabel();
    lblNewLabel.setIcon(Img);
    t1.add(lblNewLabel);
    
    JPanel t2 = new JPanel();       
    JTextPane armor1 = new JTextPane();
    armor1.setEditable(false);
    armor1.setContentType("text/html");
    armor1.setText("<html><h3 style=\"color:white;\">· Name :"+ Cesspool.armorz.get(0).name +"<br>"
            +"· Health Point : "+ Cesspool.armorz.get(0).healthPoint+ "<br>"
            +"· Defence : "+ Cesspool.armorz.get(0).defence + "<br>"
            + "· Accuracy : "+ Cesspool.armorz.get(0).accuracy + "<br>"
            + "· Speed : "+Cesspool.armorz.get(0).speed +"</h3> </html>");
    armor1.setBackground(Color.black);
    t2.add(armor1);
    
    JButton Button1 = new JButton();
    Button1.setText("Buy");
    Button1.setFocusable(false);
    Button1.setFocusPainted(false);
    Button1.setBackground(new Color(255,238,88));
    Button1.setForeground(Color.WHITE);
    
    
    a1.add(Button1);
    a1.add(t1);
    a1.add(t2);
    this.add(a1);

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。