我正在使用BeautyEye Laf作为Java Swing应用程序。
我在JTextField
内设置JPopupMenu
。无论我做什么,JTextField
都会显示为禁用状态。代码有点复杂,但我已经制作了易于测试的代码片段
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.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);
}
}
);
}
如果我删除LaF
(注释前两行),一切都按预期工作。 JTextField
是可编辑的。我先问这里,希望我做错了。如果这被证明是一个错误,我会将此作为一个问题发布在Github上。
答案 0 :(得分:0)
最后,这是图书馆的一个小改动。来自作者:
你可以找到上课 org.jb2011.lnf.beautyeye.ch7_popup.TranslucentPopupFactory源代码 在第416行,改变" setFocusableWindowState(false);"至 " setFocusableWindowState(真);"或者只是删除这一行。