50,549
社区成员
发帖
与我相关
我的任务
分享
public class NavigationPanel extends ImagePanel {
protected JPanel navButtonPanel;
public NavigationPanel() {
super(new ImageIcon(
"images/navigationBgr2.png").getImage());
init();
}
private void init() {
setOpaque(false);
}
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.add(new NavigationPanel());
frame.setSize(600, 200);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
public class IndexFrame extends JFrame {
private static final long serialVersionUID = 1L;
protected ImagePanel backgroundPanel;
protected NavigationPanel navigationPanel;
public IndexFrame() {
init();
}
private void init() {
JFrame frame = new JFrame();
backgroundPanel = new ImagePanel(new ImageIcon(
"images/backgroundImg.png").getImage());
backgroundPanel.setLayout(new BorderLayout());
navigationPanel = new NavigationPanel();
backgroundPanel.add(navigationPanel);
frame.setContentPane(backgroundPanel);
frame.pack();
frame.setLocation(200, 80);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public static void main(String[] args) {
new IndexFrame();
}
}