0% found this document useful (0 votes)
8 views5 pages

1.3.2 AWT Controls & Layout Manager Part-8

Uploaded by

nihalpatil0021
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views5 pages

1.3.2 AWT Controls & Layout Manager Part-8

Uploaded by

nihalpatil0021
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Scrollbar

-used to add horizontal and vertical scrollbar


-Scrollbar is a GUI component allows us to see invisible number of rows and columns.
Constructor-
1. Scrollbar( )-creates a vertical scroll bar
2. Scrollbar(int style)- specify the orientation of the scroll bar
3. Scrollbar(int style, int initialValue, int thumbSize, int min, int max)
style- Scrollbar.VERTICAL or Scrollbar.HORIZONTAL
Methods-
1. void setValues(int initialValue, int thumbSize, int min, int max)- set the current value
2. int getValue( )- obtain the current value of the scroll bar.
3. int getMinimum( )-retrieve the minimum values
4. int getMaximum( )-retrieve the maximum values
Program- Develop a program to add scrollbar on applet
import java.awt.*;
import java.applet.*;
public class ScrollbarExample extends Applet
{
Scrollbar s=new Scrollbar();
public void init()
{
s.setBounds(100,100, 50,100);
add(s);

}
/* <applet code=ScrollbarExample width=200 height=300> </applet> */

Note- compile using javac ScrollbarExample.java and execute it by appletviewer ScrollbarExample.java


Program- Develop a program to add scrollbar on applet
import java.awt.*;
import java.applet.*;
public class ScrollbarExample extends Applet
{
Scrollbar s=new Scrollbar(Scrollbar.HORIZONTAL);
public void init()
{
s.setBounds(100,100, 50,100);
add(s);

}
/* <applet code=ScrollbarExample width=200 height=300> </applet> */

Note- compile using javac CheckboxGroupExample.java and execute it by appletviewer CheckboxGroupExample.java


Panel
- is a simplest container class.
- can attach any other component.

Constructors-
1. Panel()- Creates a new panel using the default layout manager.
2. Panel(LayoutManager layout)-Creates a new panel with the specified layout
manager.

setSIze(),setBounds(),setForeground()setbackground(),setFont() etc
Program- Develop a program to add Panel on Frame
import java.awt.*;
public class PanelExample {
PanelExample() {
Frame f= new Frame("Panel Example");
Panel panel1=new Panel();
panel.setBounds(40,80,200,200);
panel.setBackground(Color.gray);
Button b1=new Button("Button 1");
b1.setBounds(50,100,80,30);
b1.setBackground(Color.yellow);
Button b2=new Button("Button 2");
b2.setBounds(100,100,80,30);
b2.setBackground(Color.green);
panel1.add(b1); panel1.add(b2);
f.add(panel1);
f.setSize(400,400);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String args[]) { new PanelExample(); } }
Note- compile using javac PanelExample.java and execute it by PanelExample.java

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy