Practical No 6
Title: Write a program using swing to display a ScrollPane and
JComboBox in an JApplet with the items-English,Marathi,Hindi,Sanskrit.
Program:
import javax.swing.*;
import java.awt.*;
public class ScrollPaneComboBoxFrame {
public static void main(String[] args) {
JFrame frame = new JFrame("ScrollPane and JComboBox Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 200);
frame.setLayout(new BorderLayout());
String[] languages = {"English", "Marathi", "Hindi", "Sanskrit"};
JComboBox<String> comboBox = new JComboBox<>(languages);
JPanel panel = new JPanel();
panel.add(comboBox);
JScrollPane scrollPane = new JScrollPane(panel);
frame.add(scrollPane, BorderLayout.CENTER);
frame.setVisible(true);
}
}
Output: