public static JTextArea area = new JTextArea()
{
public void createObject()
{
setLineWrap(true);
setSize(850, 1100);
setOpaque(true);
setBackground(Color.WHITE);
setBounds(0, 0, 850, 1100);
setBorder(BorderFactory.createLineBorder(Color.lightGray, 1));
setBorder(new EmptyBorder(new Insets(100, 100, 100, 100)));
setFont(new Font("TimesRoman", Font.PLAIN, 11));
}
};
public static JPanel panelImg = new JPanel()
{
public void paintComponent(Graphics g)
{
try{
add(area);
Image img = new ImageIcon(ImageIO.read(new File("C:\\Program Files (x86)\\Oasis Script Writer\\Textures\\Backgrounds\\Background.jpg"))).getImage();
Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
setPreferredSize(size);
setMinimumSize(size);
setMaximumSize(size);
setSize(size);
setLayout(null);
g.drawImage(img, 0, 0, null);
} catch (Exception backgroundError) {
System.out.println("ERROR: " + backgroundError);
}
}
};
My goal is to overlay a jtextarea over a jpanel containing a full screen image so that I can place the jtextarea inside of a jscrollpane without effecting the jpanel and the image which it contains. Thank you in advance.
After that I added the jpanel to the jframe intending that the jtextarea was added to the jpanel and overlapping the image background.
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.getContentPane().add(panelImg);
heres a diagram: https://drive.google.com/file/d/0B9e6NVTCbgdwTFNkRlFDUkNYVXM/view?usp=sharing