Friday, 2 May 2014

Example Of Java Program For JScrollbar (Implement ScrollBar)

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

/*<applet code="JScrolldemo" width=200 height=200></applet>*/

public class JScrolldemo extends JApplet
{
public void init()
{

Container c=getContentPane();

c.setLayout(new BorderLayout());

JPanel jp=new JPanel();
jp.setLayout(new GridLayout(2,2));


JRadioButton b1=new JRadioButton("Indian Express");
jp.add(b1);
JRadioButton b2=new JRadioButton("Times of India");
jp.add(b2);
JRadioButton b3=new JRadioButton("Sakal");
jp.add(b3);
JRadioButton b4=new JRadioButton("Lokmat");
jp.add(b4);

ButtonGroup bg1=new ButtonGroup();
ButtonGroup bg2=new ButtonGroup();
bg1.add(b1);
bg1.add(b2);
bg2.add(b3);
bg2.add(b4);

int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp=new JScrollPane(jp,v,h);

c.add(jsp,BorderLayout.CENTER);


}

}

No comments:

Post a Comment