0% found this document useful (0 votes)
39 views26 pages

Advance java pratice question

Uploaded by

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

Advance java pratice question

Uploaded by

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

1.

Write GUI programs for the following Swing Components


A. Java JButton
CODE:- OUTPUT:-
import javax.swing.*;
public class JButtonExample {
public static void main(String[] args) {
JFrame frame = new JFrame("JButton Example");
JButton button = new JButton("Click Me");
button.setBounds(50, 50, 100, 40);
frame.add(button);
frame.setSize(200, 150);
frame.setLayout(null);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}

B. Java JLabel
CODE:-
import javax.swing.*; OUTPUT:-
public class JLabelExample {
public static void main(String[] args) {
JFrame frame = new JFrame("JLabel Example");
JLabel label = new JLabel("Hello, World!");
label.setBounds(50, 50, 200, 30);
frame.add(label);
frame.setSize(300, 200);
frame.setLayout(null);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
C. Java JTextField
CODE:- OUTPUT:-
import javax.swing.*;
public class JTextFieldExample {
public static void main(String[] args) {
JFrame frame = new JFrame("JTextField Example");

JTextField textField = new JTextField();


textField.setBounds(50, 50, 150, 30);
frame.add(textField);
frame.setSize(300, 200);
frame.setLayout(null);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}

D. Java TextArea
CODE:- OUTPUT:-
import javax.swing.*;

public class JTextAreaExample {


public static void main(String[] args) {
JFrame frame = new JFrame("JTextArea Example");
JTextArea textArea = new JTextArea();
JScrollPane scrollPane = new JScrollPane(textArea);
scrollPane.setBounds(50, 50, 300, 200);
frame.add(scrollPane);
frame.setSize(400, 300);
frame.setLayout(null);
frame.setVisible(true);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}
}
E. JPasswordFieldExample
CODE:- OUTPUT:-
import javax.swing.*;
public class JPasswordFieldExample {
public static void main(String[] args) {
JFrame frame = new JFrame("JPasswordField Example");

JPasswordField passwordField = new JPasswordField();


passwordField.setBounds(50, 50, 150, 30);
frame.add(passwordField);
frame.setSize(300, 200);
frame.setLayout(null);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}

F. JcheckBox
CODE:- OUTPUT:-
import javax.swing.*;

public class JCheckboxExample {


public static void main(String[] args) {
JFrame frame = new JFrame("JCheckBox Example");
JCheckBox checkBox = new JCheckBox("Check me");
checkBox.setBounds(50, 50, 150, 30);
frame.add(checkBox);
frame.setSize(300, 200);
frame.setLayout(null);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}

}
G. Java JradioButton
CODE:-
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
public class JRadioButtonExample {

public static void main(String[] args) {


SwingUtilities.invokeLater(() -> {
JFrame frame = new JFrame("JRadioButton Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 200);
JPanel contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(10, 10, 10, 10));
contentPane.setLayout(new GridLayout(1, 1));
frame.setContentPane(contentPane);
JRadioButton radioButton1 = new JRadioButton("Option 1");
JRadioButton radioButton2 = new JRadioButton("Option 2");
ButtonGroup group = new ButtonGroup();
group.add(radioButton1);
group.add(radioButton2);
contentPane.add(radioButton1);
contentPane.add(radioButton2);
frame.setVisible(true);
});
}

OUTPUT:-
H. Java JComboBox
CODE:- OUTPUT:-
import javax.swing.*;
public class JComboBoxExample {
public static void main(String[] args) {
JFrame frame = new JFrame("JComboBox Example");

String[] options = {"Option 1", "Option 2", "Option 3"};


JComboBox<String> comboBox = new JComboBox<>(options);
comboBox.setBounds(50, 50, 150, 30);
frame.add(comboBox);
frame.setSize(300, 200);
frame.setLayout(null);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}

I. Java JList
CODE:- OUTPUT:-
import javax.swing.*;
public class JListExample {
public static void main(String[] args) {
JFrame frame = new JFrame("JList Example");
String[] data = {"Item 1", "Item 2", "Item 3", "Item 4", "Item 5"};
JList<String> list = new JList<>(data);
list.setBounds(50, 50, 150, 100);
frame.add(list);
frame.setSize(250, 200);
frame.setLayout(null);

frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}
}
J. Java MenuItem & JMenuJava JPopupMenu
CODE:- OUTPUT:-
import javax.swing.*;
public class JMenuItemJMenuExample {
public static void main(String[] args) {
JFrame frame = new JFrame("JMenuItem and JMenu Example");

JMenu menu = new JMenu("File");


JMenuItem menuItem1 = new JMenuItem("Open");
JMenuItem menuItem2 = new JMenuItem("Save");
JMenuItem menuItem3 = new JMenuItem("Exit");
menu.add(menuItem1);
menu.add(menuItem2);
menu.add(menuItem3);
JMenuBar menuBar = new JMenuBar();
menuBar.add(menu);
frame.setJMenuBar(menuBar);
frame.setSize(300, 200);
frame.setLayout(null);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}

Java PopMenuExample
CODE:-
import javax.swing.*;
public class JPopupMenuExample {
public static void main(String[] args) {
JFrame frame = new JFrame("JPopupMenu Example");

JPopupMenu popupMenu = new JPopupMenu();


JMenuItem menuItem1 = new JMenuItem("Copy");
JMenuItem menuItem2 = new JMenuItem("Paste");
popupMenu.add(menuItem1);
popupMenu.add(menuItem2);

frame.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
popupMenu.show(frame, evt.getX(), evt.getY());
}
});
frame.setSize(300, 200);
frame.setLayout(null);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

OUTPUT:-

K. Java JcolorChooser
CODE:- OUTPUT:-
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class JColorChooserDemo extends JFrame {
JPanel panel;
Color bgColor = Color.LIGHT_GRAY;
public JColorChooserDemo() {
panel = new JPanel(new BorderLayout());
JButton btnColor = new JButton("Change Color");
panel.add(btnColor,BorderLayout.SOUTH);
btnColor.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
Color color = JColorChooser.showDialog(JColorChooserDemo.this,
"Choose a color", bgColor);
if (color != null) { // new color selected
bgColor = color;
}
panel.setBackground(bgColor);
}
});
setContentPane(panel);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("JColorChooser Demo");
setSize(300, 200);
setLocationRelativeTo(null);
setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new JColorChooserDemo();
}
});
}
}
L. Java JtabbedPane
CODE:-
import java.awt.BorderLayout;
import javax.swing.*;
public class JTabbedPaneExample {
public static void main(String[] args) {

JFrame frame = new JFrame("JTabbedPane Example");


frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTabbedPane tabbedPane = new JTabbedPane();
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
panel1.add(new JLabel("This is Panel 1"));
panel2.add(new JLabel("This is Panel 2"));
tabbedPane.addTab("Tab 1", panel1);
tabbedPane.addTab("Tab 2", panel2);
frame.setLayout(new BorderLayout()); // Set the layout manager
frame.add(tabbedPane, BorderLayout.CENTER); // Add the tabbed pane to the center
of the frame
frame.setSize(300, 200);
frame.setVisible(true);
}
}

OUTPUT:-
M.Java JSlider
CODE:- OUTPUT:-
import javax.swing.*;
public class JSliderExample {
public static void main(String[] args) {
JFrame frame = new JFrame("JSlider Example");

JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 50);


slider.setMinorTickSpacing(5);
slider.setMajorTickSpacing(20);
slider.setPaintTicks(true);
slider.setPaintLabels(true);
JPanel panel = new JPanel();
panel.add(slider);
frame.add(panel);
frame.setSize(300, 200);
frame.setLayout(null);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}

N. JFileChooser
CODE:- OUTPUT:-
import javax.swing.*;
import java.awt.event.*;
public class JFileChooserExample {
public static void main(String[] args) {
JFrame frame = new JFrame("JFileChooser Example");
JButton button = new JButton("Open File Chooser");

button.setBounds(50, 50, 200, 30);


frame.add(button);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser();

int returnValue = fileChooser.showOpenDialog(null);


if (returnValue == JFileChooser.APPROVE_OPTION) {
JOptionPane.showMessageDialog(null, "Selected file: " +
fileChooser.getSelectedFile().getName());
} } });
frame.setSize(300, 200);
frame.setLayout(null);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}}

O. JavaToggleButton
CODE:- OUTPUT:-
import javax.swing.*;
public class JToggleButtonExample {
public static void main(String[] args) {
JFrame frame = new JFrame("JToggleButton Example");
JToggleButton toggleButton = new JToggleButton("Toggle Me");
toggleButton.setBounds(50, 50, 150, 30);
frame.add(toggleButton);
frame.setSize(300, 200);
frame.setLayout(null);
frame.setVisible(true);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}:
P. Java JToolBar
CODE:- OUTPUT:-
import javax.swing.*;
public class JToolBarExample {
public static void main(String[] args) {
JFrame frame = new JFrame("JToolBar Example");

JButton button1 = new JButton("Button 1");


JButton button2 = new JButton("Button 2");
JToolBar toolBar = new JToolBar();
toolBar.add(button1);
toolBar.add(button2);
frame.add(toolBar);
frame.setSize(300, 200);
frame.setLayout(null);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}}

Q. Java JprogressBar
CODE:- OUTPUT:-
import javax.swing.*;

public class JProgressBarExample {

public static void main(String[] args) {

JFrame frame = new JFrame("JProgressBar Example");

JProgressBar progressBar = new JProgressBar();

progressBar.setValue(50);

progressBar.setStringPainted(true);

frame.add(progressBar);

frame.setSize(300, 200);

frame.setLayout(null);

frame.setVisible(true);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}}
2. Write a JAVA Swing program using event Handling A
Frame with three buttons Red blue and green and change
the background color according to button pressed by user.
CODE:-
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class mycolor implements ActionListener
{
Button b1,b2,b3,b4;
Container cn;
JFrame f;
mycolor()
{
f = new JFrame("Event Handling");
cn = f.getContentPane();
f.setVisible(true);
f.setSize(500,500);
b1=new Button("RED");
b2=new Button("BLUE");
b3=new Button("GREEN");
b4=new Button("YELLOW");
f.add(b1);f.add(b2);f.add(b3);f.add(b4);
f.setLayout(null);
b1.setBounds(100,100,100,50);
b2.setBounds(100,200,100,50);
b3.setBounds(100,300,100,50);
b4.setBounds(100,400,100,50);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
}
public void actionPerformed(ActionEvent e)

{
if(e.getActionCommand()=="RED")
{
cn.setBackground(Color.red);
}
else if(e.getActionCommand()=="BLUE")
{
cn.setBackground(Color.blue);
}
else if(e.getActionCommand()=="GREEN")

{
cn.setBackground(Color.green);
}
else
{ cn.setBackground(Color.yellow);
}
}
public static void main(String[] args) {
mycolor mm = new mycolor();
}
}

OUTPUT:-
3. Design A Login Window as shown below and make it Active.
If user id and password are correct then design of question
4 should open. If password are incorrect then invalid
password message should be displayed.
CODE:- OUTPUT:-
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class login implements ActionListener
{
JButton b1,b2;
TextField t1,t2;
Label l1,l2;
JFrame f;
Container cn;
login()
{
f = new JFrame ("LoGiN PaGe");
f.setVisible(true);
f.setSize(350,350);
cn = f.getContentPane();
cn.setBackground(new Color(153,0,153));
b1 = new JButton("OK");
b2 = new JButton("Cancel");
f.add(b1); f.add(b2);
f.setLayout(null);
b1.setBounds(50,190,100,50);
b2.setBounds(200,190,100,50);
b1.setBackground(Color.CYAN);
b2.setBackground(Color.CYAN);
l1 = new Label("UserName");
f.add(l1);
l1.setBounds(30,65,150,50);
t1 = new TextField();
f.add(t1);
t1.setBounds(180,70,130,30);
l2 = new Label("Password");
f.add(l2);
l2.setBounds(30,115,150,50);
t2 = new TextField();
f.add(t2);
t2.setBounds(180,120,130,30);
l1.setForeground(Color.CYAN);
l2.setForeground(Color.CYAN);
Font ft = new Font("ARIAL",Font.ITALIC+Font.BOLD,18);
l1.setFont(ft);
l2.setFont(ft);
b1.addActionListener(this);
b2.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand()== "OK")
{
if(t1.getText().equals("sumit") && t2.getText().equals("sumit"))
{factinfo info = new factinfo();
info.setVisible(true);}
else{
f.dispose();
}
public static void main(String args[])
{
new login();
}}

4. Design Following Design Frame Using Swing Components


CODE:-
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
import com.mysql.cj.protocol.Resultset;
public class factinfo extends Frame implements ActionListener {
Label L, L1, l1, l2, l3, l4, l5, l6, l7, l8;
Button b1, b2, b3, b4, b5, b6, b8, b9, b0;
static TextField t1, t2, t3, t4, t5, t6, t7, t8;
Toolkit tk;
Connection cn;
factinfo() {
addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent we) {


dispose();
} });
tk = Toolkit.getDefaultToolkit();
setSize(tk.getScreenSize());
setBackground(new Color(255, 255, 220));
setLayout(null);
L = new Label("ITM UNIVERSITY GWALIOR 2024 FACULTY Information System");
add(L);
L.setBounds(60, 50, 650, 25);
l1 = new Label("Faculty ID");
add(l1);
l1.setBounds(50, 150, 100, 25);
t1 = new TextField();
add(t1);
t1.setBounds(150, 150, 100, 25);
l2 = new Label("Faculty Name");
add(l2);
l2.setBounds(300, 150, 100, 25);
t2 = new TextField();
add(t2);
t2.setBounds(400, 150, 100, 25);
l3 = new Label("Address");
add(l3);
l3.setBounds(50, 200, 100, 25);
t3 = new TextField();
add(t3);
t3.setBounds(150, 200, 100, 25);
l4 = new Label("City");
add(l4);
l4.setBounds(300, 200, 100, 25);
t4 = new TextField();
add(t4);
t4.setBounds(400, 200, 100, 25);
l5 = new Label("Phone NO.");
add(l5);
l5.setBounds(50, 250, 100, 25);
t5 = new TextField();
add(t5);
t5.setBounds(150, 250, 100, 25);
l6 = new Label("Mobile No.");
add(l6);
l6.setBounds(300, 250, 100, 25);
t6 = new TextField();
add(t6);
t6.setBounds(400, 250, 100, 25);
l7 = new Label("E_mail");
add(l7);
l7.setBounds(50, 300, 100, 25);
t7 = new TextField();
add(t7);
t7.setBounds(150, 300, 100, 25);
l8 = new Label("Designation");
add(l8);
l8.setBounds(300, 300, 100, 25);
t8 = new TextField();
add(t8);
t8.setBounds(400, 300, 100, 25);
L1 = new Label("Operation");
add(L1);
L1.setBounds(610, 130, 90, 20);
L1.setBackground(Color.black);
b1 = new Button("Add");
b1.setBackground(new Color(255, 168, 81));
b1.setBounds(600, 150, 100, 25);
add(b1);
b2 = new Button("Delete");
b2.setBackground(new Color(255, 168, 81));
b2.setBounds(600, 180, 100, 25);
add(b2);
b3 = new Button("Display");
b3.setBackground(new Color(255, 168, 81));
b3.setBounds(600, 210, 100, 25);
add(b3);
b4 = new Button("Refresh");
b4.setBackground(new Color(255, 168, 81));
b4.setBounds(600, 240, 100, 25);
add(b4);
b5 = new Button("Edit");
b5.setBackground(new Color(255, 168, 81));
b5.setBounds(600, 270, 100, 25);
add(b5);
b6 = new Button("Report");
b6.setBackground(new Color(255, 168, 81));
b6.setBounds(600, 300, 100, 25);
add(b6);
b8 = new Button("Datagrid");
b8.setBackground(new Color(255, 168, 81));
b8.setBounds(600, 330, 100, 25);
add(b8);
b9 = new Button("Next");
b9.setBackground(new Color(255, 168, 81));
b9.setBounds(600, 450, 100, 25);
add(b9);
b0 = new Button("Previous");
b0.setBackground(new Color(255, 168, 81));
b0.setBounds(250, 450, 150, 25);
add(b0);
Font ft = new Font("ARIAL", Font.ITALIC + Font.BOLD, 18);
L.setFont(ft);
Font ft1 = new Font("ARIAL", Font.ITALIC + Font.BOLD, 18);
L1.setFont(ft1);
setTitle("Faculty Information");
setVisible(false);
this.dispose();
L.setForeground(Color.white);
L1.setForeground(Color.white);
l1.setForeground(Color.white);
l2.setForeground(Color.white);
l3.setForeground(Color.white);
l4.setForeground(Color.white);
l5.setForeground(Color.white);
l6.setForeground(Color.white);
l7.setForeground(Color.white);
l8.setForeground(Color.white);
L.setBackground(Color.black);
l1.setBackground(Color.black);
l2.setBackground(Color.black);
l3.setBackground(Color.black);
l4.setBackground(Color.black);
l5.setBackground(Color.black);
l6.setBackground(Color.black);
l7.setBackground(Color.black);
l8.setBackground(Color.black);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
try {
Class.forName("com.mysql.cj.jdbc.Driver");
System.out.println("Driver Loaded successfully");
cn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/JAVA", "root",
"sumit1021");
System.out.println("Connection established successfully");
}
catch (ClassNotFoundException e) {
System.out.println("Driver Not Avilable" + e.getMessage());
} catch (SQLException e) {
System.out.println("Connection error" + e.getMessage());
} }
public void actionPerformed(ActionEvent e) {
try {
if (e.getActionCommand() == "Add")
{
String sql = "insert into factinfo values(?,?,?,?,?,?,?,?)";
PreparedStatement pst = cn.prepareStatement(sql);
pst.setString(1, t1.getText());
pst.setString(2, t2.getText());
pst.setString(3, t4.getText());
pst.setString(4, t4.getText());
pst.setString(5, t5.getText());
pst.setString(6, t6.getText());
pst.setString(7, t7.getText());
pst.setString(8, t8.getText());
int x = pst.executeUpdate();
if (x > 0) {
System.out.println("record inserted successfully");
javax.swing.JOptionPane.showMessageDialog(null,"Record Inserted
Successfully");
}}

else if (e.getActionCommand() == "Delete")


{
String sql =" delete from factinfo where Faculty_ID ='"+t1.getText()+"'";
PreparedStatement pst = cn.prepareStatement(sql);
//pst.setString(4,t4.getText());
int x = pst.executeUpdate(sql);
if( x > 0)
{
javax.swing.JOptionPane.showMessageDialog(null,"Record Delete Successfully");
}
else{
javax.swing.JOptionPane.showMessageDialog(null,"Record is not Available");
}}
else if(e.getActionCommand() == "Display")
{
String sql = "select * from factinfo where Faculty_ID = '"+t1.getText()+"'";
PreparedStatement pst = cn.prepareStatement(sql);
ResultSet re= pst.executeQuery();
if(re.next()){
t2.setText(re.getString(2));
t3.setText(re.getString(3));
t4.setText(re.getString(4));
t5.setText(re.getString(5));
t6.setText(re.getString(6));
t7.setText(re.getString(7));
t8.setText(re.getString(8));
}
else{
javax.swing.JOptionPane.showMessageDialog(null,"Record is not Available");
}
}
else if(e.getActionCommand()=="Refresh")
{} }
catch (SQLException f)
{ }}
public static void main(String s[]) {
factinfo mp = new factinfo();
mp.setVisible(true);
}
public void paint(Graphics g) {
g.setColor(new Color(128, 128, 0));
g.drawRoundRect(30, 110, 510, 330, 15, 15);
g.fillRoundRect(30, 110, 510, 330, 15, 15);
g.drawOval(570, 110, 165, 310);

g.fillOval(570, 110, 165, 310);


}
}

OUTPUT:-

5. Consider the Design in Question -2: and Write a


Swing+JDBC program to establish connection with oracle
and perform following operation on emp table. And active
all mentioned JBUttons
a. Display the table data

b. Insert a new record into emp table

c. Delete record by emp no. From emp table.

d. Update emp data using emp number.


6. Implement Following GUI Design and onclick of Button A
color palate to be shown and change the background color
according color selected by user.
CODE:-
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class JColorChooserDemo extends JFrame {
JPanel panel;
Color bgColor = Color.LIGHT_GRAY;
public JColorChooserDemo() {
panel = new JPanel(new BorderLayout());
JButton btnColor = new JButton("Change Color");
panel.add(btnColor,BorderLayout.SOUTH);
btnColor.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
Color color = JColorChooser.showDialog(JColorChooserDemo.this,
"Choose a color", bgColor);
if (color != null) { // new color selected
bgColor = color;
}
panel.setBackground(bgColor);
}
});
setContentPane(panel);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("JColorChooser Demo");
setSize(300, 200);
setLocationRelativeTo(null);
setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new JColorChooserDemo();
}
});
}
}
OUTPUT:-

You might also like