Jump to content

How do I add buttons inside a background


alienA2
 Share

Recommended Posts

Please see the code, background image, and the buttons which are currently outside the background image. I would like to find out how to add the buttons inside the the background. tools used: notepadd++ and command prompt. Thanks

creation1.zip

Link to comment
Share on other sites

  • 2 weeks later...

Maybe u fixed it already :) import javax.swing.JFrame;import javax.swing.ImageIcon;import javax.swing.JLabel;import java.awt.Container;import javax.swing.JTextField;import javax.swing.JButton;import java.awt.FlowLayout; class ShowPicture{public static void main(String args[]) {JFrame frame;Container contentPane;JTextField textfield;JButton button;FlowLayout layout;String sorry; frame = new JFrame();frame.setTitle("Coffee Table"); ImageIcon icon = new ImageIcon("background.png");JLabel label = new JLabel(icon); /****************************/frame.setContentPane(label);contentPane = frame.getContentPane();/****************************/ textfield = new JTextField("Type your text here.");sorry = "This button is temporarily out of order.";button = new JButton(sorry); contentPane.add(textfield);contentPane.add(button);layout = new FlowLayout();contentPane.setLayout(layout); /****************************///contentPane.add(label);/****************************/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.pack();frame.setVisible(true);}}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...