将Jlabel放在另一个 [英] Place Jlabel over another

查看:93
本文介绍了将Jlabel放在另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用netbeans. 我想将一个JLabel恰好放在另一个JLabel上(包含在一个JPanel中,而JPanel又在JFrame中). Net Beans不允许这样做,并且会继续重新放置标签.我看到它仅在面板的Null布局中允许这样做. Netbeans默认使用组布局. 有没有办法做到这一点?还是我必须使用空布局?

I am using netbeans. I want to place one JLabel exactly over another JLabel (contained in a JPanel which is in turn in a JFrame). Net beans just wont allow it and keeps repositioning the labels. I saw it allows this only in a Null layout for the panel. Netbeans by default uses group layout. Is there a way to acheive this? Or must I use null layout?

推荐答案

  1. 使用 OverlayLayout

将正确的 LayoutManager设置为JLabel ,然后(现在JLabel是contianer)放在另一个JLabel

set proper LayoutManager to JLabel, then (now JLabel is contianer) put there another JLabel

这篇关于将Jlabel放在另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆