Hello friends.I got some problems with a program I'm developing for a assignment. I want to add a image(background) to my Jframe and add some buttons. I wrote the code. I can load image into the frame but when I create the Jbutton and re-size it to smaller button it's not minimizing. the button shows all over the frame.. is there any solution.. ? thank you

import java.awt.Dimension;
import javax.swing.*;

public class GUItest01 extends JFrame {


  public static void main(String[] args) {


      JFrame frame = new JFrame("main");
       frame.setDefaultCloseOperation(EXIT_ON_CLOSE);

      ImageIcon ii = new ImageIcon("C:/icon.jpg");
      JLabel lable = new JLabel(ii);
      JScrollPane jsp = new JScrollPane(lable);
      frame.getContentPane().add(jsp);
      frame. setSize(1000, 700);


      JButton button = new JButton();
      button.setSize(new Dimension(50, 50));
      button.setLocation(500, 350);
     frame.getContentPane().add(button);

     



frame.setVisible(true);
  }
}

I java u have to use layouts for setting location, u can also use no layout as i already given u the link. Check the link... For starter use flow layout, for complicated setting of GUI use gridbaglayout... U can also use other layouts... If you are not powerful handling such details and time is short for your project, move to netbeans, but remember IDE is helpful for professional not for beginner.

I java u have to use layouts for setting location, u can also use no layout as i already given u the link. Check the link... For starter use flow layout, for complicated setting of GUI use gridbaglayout... U can also use other layouts... If you are not powerful handling such details and time is short for your project, move to netbeans, but remember IDE is helpful for professional not for beginner.

yeah.. that's why I'm trying to learn these things.. thanks anyway.. can you suggests any web post about this..?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.