java jpopupmenu 无法显示_[已解决] JPopupMenu还是不能实现文本组件可编辑

本文介绍 BeautyEye 3.7 版本如何解决 JTextField 在特定情况下不可编辑的问题,并提供了出现问题的示例代码,通过对比 v3.6 版本,演示了解决方案。

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

你可以把这段代码放到Eclipse里去执行看看,BeautyEye v3.7里解决了这个老外说的问题(你可以用v3.6对比一下,换个beautyeye的jar包就行)。

不知你描述的问题是否跟老外是一样的,你看看他的代码,或许能给你启发!

》BeautyEye的v3.7版解决的这个问题是老外提出来的,老外反馈的原话是:

“The JTextField is not editable. If you remove beautyeye the field becomes editable”

》老外给出的出问题的代码如下:

public static void main(String[] s)

throws Exception

{

BeautyEyeLNFHelper.frameBorderStyle = BeautyEyeLNFHelper.FrameBorderStyle.generalNoTranslucencyShadow;

org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper.launchBeautyEyeLNF();

final JPopupMenu popupTable = new JPopupMenu();

// find panel

JLabel findLabel = new JLabel("Filter for:");

findLabel.setPreferredSize(new Dimension(60, 20));

final JTextField findTextField = new JTextField();

findTextField.setColumns(10);

final JPanel container = new JPanel();

container.setBackground(new JMenuItem().getBackground()); // panel must have the same background with JMenuItems

container.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 0));

container.add(findLabel);

container.add(findTextField);

popupTable.add(container);

JButton button = new JButton("Action");

JPanel buttonPanel = new JPanel();

buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));

buttonPanel.add(button);

JPanel panel = new JPanel();

panel.setLayout(new BorderLayout());

panel.add(popupTable, BorderLayout.CENTER);

panel.add(buttonPanel, BorderLayout.SOUTH);

final JFrame frame = new JFrame();

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setSize(900, 800);

frame.getContentPane().setLayout(new BorderLayout());

frame.getContentPane().add(panel, BorderLayout.CENTER);

frame.setVisible(true);

button.addActionListener

(

new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

int x = (frame.getWidth() / 2);

int y = (frame.getHeight() / 2);

popupTable.show(frame, x, y);

}

}

);

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值