If a GUI application has a JFrame
containing a JPanel
with an image
inside its entire body (so that the image is a kinda background image), and I want to add a (transparent) JTabbedPane
on the JPanel
.
Now I am using the GUI Builder of NetBeans to place a panel on the picture, but it probably goes under the picture. How can I being it on the top (that is above the picture, so that the tabbed pane is visible).
PS: I am trying to do it with GUI Builder, since I am completely new to Java Swing
. So please tell me a way in GUI Builder
preferably, if there is any?
Edit1:- package com.dev_nna.dbp;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
public class PanelForm extends javax.swing.JPanel {
private BufferedImage image;
public PanelForm() {
try {
image = ImageIO.read(getClass().getResource("/com/dev_nna/dbp/scheduler/resources/abstract-blue-white-background.jpg"));
} catch (IOException ex) {
ex.printStackTrace();
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
}// </editor-fold>
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(image, 0, 0, getWidth(), getHeight(), this);
}
@Override
public Dimension getPreferredSize() {
return new Dimension(1000, 1000);
}
}