java jbutton 背景图片,Jbutton在Jbutton背景图片上?

本文探讨了如何在Java中使用JButtons创建2D地图并实现在单位(按钮)覆盖地图时显示背景。作者建议改变单元按钮的布局,可能采用面板配合鼠标监听和键盘交互,以达到控制背景显示的目的。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Lets say I created a 2d tile map with jbuttons and then created units on top of the map is there a way to show the background of the map when the unit(also a jbutton) is on top of the tile, because how it is now is the background of the unit is just colored red, so is it possible to do this with jbuttons over jbuttons?

解决方案

Possible, yes, advisable, ah, probably not.

I believe you're going to need to change the layout of the title button to something you can control (this is going to depend upon your visual requirements).

I, personally, would probably go for a panel with a label inside it, using mouse listeners to monitor for mouse actions & probably input/action maps for keyboard interaction.

Jbuttons are just jcomponent, so they get all the functionality that jcomponents have

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值