Hello great community, thanks for taking the time to look at this post i hope i dont offend any developers of my amateurness but im in deep trouble, im trying to set an image for my app and have some buttons that run things like opening a url, etc. simple stuff, then adding some text to it to describe the buttons, however, as im learning how to add buttons, then add images, i cannot blend them or combine them together, it seems that every time i find a solution for a piece of my app, it's incompatible with another, but enough of my rambles, let me show you the code im running:
package x(name of my package);
import javax.swing.*;
import java.awt.*;
class x(name of my class) extends JFrame
{
private static final long serialVersionUID = 1L;
JButton b1;
JLabel l1;
public button()
{
setTitle("Background Color for JFrame");
setSize(1440,1080);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
setLayout(new BorderLayout());
setContentPane(new JLabel(new ImageIcon("C:\\Users\\x(name of computer)\\Downloads\\helena.jpg")
setLayout(new FlowLayout());
l1=new JLabel("here is a button");
b1=new JButton("I am a button");
add(l1);
add(b1);
setSize(1,1);
setSize(1440,,1080);
}
public static void main(
String[] args){
new button();
}
}
/* Running this yields background image along with my buttons, however when trying to implement this code for some text on the background image, i get a bunch of errors and so my question is... with this code, how do i implement text ontop of the background image? How do i make my buttons run things? how do i customize my buttons with images?
**code:
Graphics g = image.getGraphics();
g.setFont(g.getFont().deriveFont(30f));
g.drawString("Hello World!", 100, 100);
g.dispose();
i appreciate all the help and thanks!
*/