我在Java设置的图片如何添加Jcombobox?

How can I add Jcombobox on the image set by me in Java?

我需要在 me.I 设置的图像上添加一个组合框,我也尝试过 LayeredPane,但得不到想要的结果。请帮助我。

I need to add a combobox on the image set by me

您可以设置任何Swing 组件的布局管理器。

因此,如果您在 JLabel 中显示图像,则可以设置标签的布局。例如:

JLabel background = new JLabel( new ImageIcon(...) );
background.setLayout( new FlowLayout() );

JComboBox comboBox = new JComboBox();
comboBox.addItem(...);
background.add( comboBox );

如果在JPanel上绘制图片,默认布局已经是FlowLayout,只需要重写面板的getPreferredsize()方法为图片大小即可。