Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

JScollPane

  Asked By: Gail    Date: May 17    Category: Java    Views: 404
  

I want to use JScrollPane with JPanel which has setLayout as null.
Can anyone please tell me why the scrolling is not working.
I dont want to change the Layout.
This is the code:
import javax.swing.*;
import java.awt.*;

public class test extends JFrame
{

static JLabel v1, v2, v3, v4, v5, v6, v7, v8, v9,v10,v11;
public ImageIcon images;
static JDesktopPane main;
JPanel panel;
JScrollPane scrollPane;
test()
{


main = new JDesktopPane();



setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(720,590);

setResizable(false);
setMaximizedBounds(new Rectangle(720,560));
//setVisible(false);
main = new JDesktopPane();
panel = new JPanel();
panel.setLayout(null);
panel.setBackground(Color.red);
panel.setBounds(100,100,400,400);


JLabel lab = new JLabel("atif");
lab.setBounds(300,10,30,20);
panel.add(lab);
setContentPane(main);

scrollPane = new JScrollPane();
scrollPane.setBounds(100,100,100,100);
scrollPane.getViewport().add(panel);
//panel.add( scrollPane);
main.add(scrollPane);

}

public static void main(String [] args)
{
test t = new test();
t.setVisible(true);
}




}

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on JScollPane Or get search suggestion and latest updates.

Related Topics:



Tagged:  

 

Related Post