我不知道如何JLabel
在JPanel
. 我想在移动图像的标签中显示一些信息。图像在JPanel
. 我已经设法使JFrame
未装饰的。
输出http://i44.tinypic.com/2mhacsj.png
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Window;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
class Remote extends JFrame {
JPanel p2;
private Window Remote;
public Remote() {
createAndShowGUI();
}
public void createAndShowGUI() {
// Set title and default close operation
setTitle("Transparent Panel");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setUndecorated(true);
p2 = new JPanel();
JLabel label = new JLabel(new ImageIcon("C://Mobile.png"));
p2.add(label);
p2.setPreferredSize(new Dimension(1000, 800));
add(p2);
setLayout(new FlowLayout());
setSize(315, 610);
setVisible(true);
setLocation(800, 100);
}
public static void main(String args[]) {
// Run in the EDT
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
Remote remote = new Remote();
}
});
}
}
我有3个问题:
如何删除手机周围的边框[背景]?
如何在 中添加一些标签
JPanel
?如何使窗户可移动?