Write A Program Using Swing To Demonstrate Creation of File Edit Menu With Submenu?
Write A Program Using Swing To Demonstrate Creation of File Edit Menu With Submenu?
import javax.swing.*;
import java.awt.event.*;
JFrame f;
JMenuBar mb;
JMenu file,edit;
JMenuItem cut,copy,paste,selectAll;
JTextArea ta;
SwingNew(){
f=new JFrame();
cut=new JMenuItem("cut");
copy=new JMenuItem("copy");
paste=new JMenuItem("paste");
selectAll=new JMenuItem("selectAll");
cut.addActionListener(this);
copy.addActionListener(this);
paste.addActionListener(this);
selectAll.addActionListener(this);
mb=new JMenuBar();
mb.setBounds(5,5,600,20);
file=new JMenu("File");
edit=new JMenu("Edit");
edit.add(cut);edit.add(copy);edit.add(paste);edit.add(selectAll);
mb.add(file);mb.add(edit);
ta=new JTextArea();
ta.setBounds(5,30,460,460);
f.add(mb);f.add(ta);
f.setLayout(null);
f.setSize(500,500);
f.setVisible(true);
if(e.getSource()==cut)
ta.cut();
if(e.getSource()==paste)
ta.paste();
if(e.getSource()==copy)
ta.copy();
if(e.getSource()==selectAll)
ta.selectAll();
new SwingNew();
}
13. Write a Program to implement a
swing program to demonstrate JTree
with atleast 3 tree node and sub nodes?
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
JFrame f;
jtree(){
f=new JFrame();
style.add(color);
style.add(shape);
style.add(size);
f.add(jt);
f.setSize(200,200);
f.setVisible(true);
new jtree();
}}
19. Write a Program to implement swing
program to demonstrate the use of JColor
chooser?
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
JButton b;
Container c;
ChooseColor(){
c=getContentPane();
c.setLayout(new FlowLayout());
b=new JButton("color");
b.addActionListener(this);
c.add(b);
Color initialcolor=Color.RED;
c.setBackground(color);
ch.setSize(400,400);
ch.setVisible(true);
ch.setDefaultCloseOperation(EXIT_ON_CLOSE);