I have a panel drawSomething
to draw something in it and I need its size to be big and I have another panel
in my frame to put that panel drawSomething
in it so, I need to put scrollpane
around panel how can I do it?
here is my sample code :
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
public class myFrame extends JFrame{
public static void main(String[] args) {
myFrame mf = new myFrame();
mf.setSize(400,400);
mf.setVisible(true);
mf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mf.setLayout(null);
JPanel panel1 = new JPanel();
panel1.setBackground(Color.yellow);
JPanel drawSomething = new JPanel();
panel1.setBounds(100, 100, 200, 200);
drawSomething.setSize(500, 500);
drawSomething.setBackground(Color.BLACK);
panel1.add(drawSomething);
JScrollPane scroll = new JScrollPane(panel1);
mf.add(scroll);
}
}