Font size
WorksheetsCS26L 3RD EXAM
Total questions: 79
Worksheet time: 1hrs 12mins
The object of (blank) class is a single line input field that allows the user to select a number or an object value from an ordered sequence.
(a)
is a software intermediary that allows two applications to talk to each other
(a)
import java.awt.*;
import javax.swing.*;
public class PanelExample {
PanelExample(){
JFrame f= new JFrame("Panel Example");
JPanel panel=new JPanel();
panel.setBounds(40,80,200,200);
panel.setBackground(Color.gray);
JButton b1=new JButton("Button 1");
b1.setBounds(50,100,80,30);
b1.setBackground(Color.yellow);
JButton b2=new JButton("Button 2");
b2.setBounds(100,100,80,30);
b2.setBackground(Color.green);panel.add(b1);
panel.add(b2);
f.add(panel);
f.setSize(400,400);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String args[]){new PanelExample();
}}
- To change−the look and feel of the frame.
JFrame.setDefaultLookAndFeelDecorated(true);
UIManager.getCrossPlatformLookAndFeelClassName()
UIManager.setLookAndFeel()
API stands for
(a)
- (blank) inherited the properties of JComponent class and implemented them with an Accessible interface.
(a)
Creates acolor chooser pane with the specified initial color.
(a)
(blank) is the period of time when a program is running and generally occurs after compile time.
(a)
is the last phase of the program lifecycle also known to be the execution phase of the program
(a)
- To set the look and feel of UI−components.
UIManager.setLookAndFeel()
UIManager.getCrossPlatformLookAndFeelClassName()
JFrame.setDefaultLookAndFeelDecorated(true);
is the period when the programming code (such as C#, Java, C, Python) is converted to the machine code(i.e. binary code).
(a)
- It is used to create a new JPanel with a double buffer and a flow layout.
(a)
To get the Look and Feel of Java.
UIManager.getCrossPlatformLookAndFeelClassName()
UIManager.setLookAndFeel()
JFrame.setDefaultLookAndFeelDecorated(true);
Change the look and feel of a window Following example showcase how to change the look and feel of a window in Swing based application.
(a)
refers to the way the widgets behave.
(a)
What type of declaration: javax.swing.JColorChooser class.
(a)
are generated (as events) every time an (blank) invocation happens. (blank)Transactions may contain the details about the invocation such as request and response headers, request and response payloads, consumer applications and soon.
(a)
(blank) does not appear until you explicitly make it visible.
(a)
(blank) is a top level window
(a)
Constructs a JFileChooser utilizing the given current catalogand FileSystemView.Example program on JFileChooser(File currentDirectory,FileSystemViewfsv)
(a)
Creates a color chooser pane with an initial color of white
(a)
is a lightweight component
(a)
import javax.swing.*;
public class SpinnerExample {
public static void main(String[] args) {
JFrame f=new JFrame("Spinner Example");
SpinnerModel value =new SpinnerNumberModel(5, //initial value0, //minimum value10, //maximum value1); //step
JSpinner spinner = new JSpinner(value);
spinner.setBounds(100,100,50,30);
f.add(spinner);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}}
- It doesn't have title bar.
(a)
A (blank) is a Swing container that provides a third dimension for positioning components: depth, also known as Z order. When adding a component to a (blank), you specify its depth as an integer. The higher the number, closer the component is to the "top" position within the container.
(a)
is a software application used for payment data transmission between two systems.
(a)
refers to the appearance of GUI widgets
(a)
(blank) class is used to add depth to swing container. It is used to provide a third dimension for positioning component and divide the depthrange into several different layers.
(a)
import java.io.*;
importjavax.swing.*;
importjava.awt.event.*;
importjavax.swing.filechooser.*;
classHelloWorld{public static void main(String[] args) {
// creating object to the JFileChooser classJFileChooser
jf = new JFileChooser("c:",FileSystemView.getFileSystemView());
// parameterisedconstructor JFileChooser(File currentDirectory,FileSystemViewfsv) is called.
jf.showSaveDialog(null);
// opening the saved dialogue}}
is an external library that is used to change the look and feel of Java Swing Components
(a)
Choose the correct implement for JColorChooser
public class JColorChooser extends JComponent implements Accessible
public class JDialog extends Dialog implements WindowConstants, Accessible, RootPaneContainer
public class JSpinner extends JComponent implements Accessible
public class JColorChooser extends JComponent implements JComponent
(blank) is a lightweight container used behind the scenes by JFrame, JDialog, JWindow, JApplet, and JInternalFrame.
(a)
- It is used to create a modeless dialog without a title and without a specified Frame owner.
(a)
public class JRootPaneExample {
public static void main(String[] args) {
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JRootPane root = f.getRootPane();
// Create a menu bar
JMenuBar bar = new JMenuBar();
JMenu menu = new JMenu("File");
bar.add(menu);
menu.add("Open");
menu.add("Close");
root.setJMenuBar(bar);
// Add a button to the content
paneroot.getContentPane().add(new JButton("Press Me"));
// Display the
UIf.pack();
f.setVisible(true);}}
- (blank) is a simple and successful method for inciting the client to pick a file or a directory.
(a)
What declaration is this: public class JDialog extends Dialog implements WindowConstants, Accessible, RootPaneContainer
(a)
- Constructs a JFileChooser highlighting the client's default directory. Example program on JFileChooser()
(a)
(blank) is a mechanism used in the JavaSwing widget toolkit allowing to change the look and feel of the graphical user interface at runtime
(a)
- The object of a (blank) class is a text component specialized for password entry. It allows the editing of a single line of text. It inherits JTextField class.
(a)
import java.io.*;
importjavax.swing.*;
importjava.awt.event.*;
importjavax.swing.filechooser.*;
classHelloWorld{public static void main(String[] args) {
// creating object to the JFileChooser class
JFileChooserjf = new JFileChooser();
// default constructorJFileChooser is called.
jf.showSaveDialog(null);
}}
- (blank) class is used to create a simple text editor window. This class has setContentType() and setText()methods.
(a)
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DialogExample {
private static JDialog d;
DialogExample() {
JFrame f= new JFrame();
d = new JDialog(f , "Dialog Example", true);
d.setLayout( new FlowLayout() );
JButton b = new JButton ("OK");
b.addActionListener ( new ActionListener(){
public void actionPerformed( ActionEvent e ){
DialogExample.d.setVisible(false);
}
});
d.add( new JLabel ("Click button to continue."));
d.add(b);d.setSize(300,300);
d.setVisible(true);
}
public static void main(String args[]){new DialogExample();
}}
- It is used to create a new JPanel with FlowLayout and the specified buffering strategy.
(a)
import javax.swing.*;
import javax.swing.event.*;
public class SpinnerExample {
public static void main(String[] args) {
JFrame f=new JFrame("Spinner Example");
final JLabel label = new JLabel();
label.setHorizontalAlignment(JLabel.CENTER);
label.setSize(250,100);
SpinnerModel value =new SpinnerNumberModel(5, //initial value0, //minimum value10, //maximum value1); //step
JSpinner spinner = new JSpinner(value);
spinner.setBounds(100,100,50,30);
f.add(spinner);
f.add(label)f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
spinner.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
label.setText("Value : " + ((JSpinner)e.getSource()).getValue());
}
});
}}
is a class that is present in thejava Swing package. The java Swing package is essential for JavaTM Foundation Classes(JFC).
(a)
import java.io.*;
importjavax.swing.*;
importjava.awt.event.*;
importjavax.swing.filechooser.*;
classHelloWorld{public static void main(String[] args) {
// creating object to the JFileChooser class
JFileChooserjf = new JFileChooser("c:");
// parameterisedconstructor JFileChooser( File currentDirectory) is called.
jf.showSaveDialog(null);
// opening the saved dialogue}}
import javax.swing.*;
import java.awt.*;
public class LayeredPaneExample extends JFrame {
public LayeredPaneExample() {
super("LayeredPane Example");
setSize(200, 200);
JLayeredPane pane = getLayeredPane();
//creating buttons
JButton top = new JButton();
top.setBackground(Color.white);
top.setBounds(20, 20, 50, 50);
JButton middle = new JButton();
middle.setBackground(Color.red);
middle.setBounds(40, 40, 50, 50);
JButton bottom = new JButton();
bottom.setBackground(Color.cyan);
bottom.setBounds(60, 60, 50, 50);
//adding buttons on
panepane.add(bottom, new Integer(1));
pane.add(middle, new Integer(2));
pane.add(top, new Integer(3));
}
public static void main(String[] args) {
LayeredPaneExample panel = new LayeredPaneExample();
panel.setVisible(true);
}}
Creates a color chooserpane with the specified ColorSelectionMode
(a)
- The (blank) control represents a top level window with a border and a title used to take some form of input from the user. It inherits the Dialog class.
(a)
is a simple and successful method for inciting the client to pick a file or a directory.
(a)
Constructs a JFileChooser highlighting the client’s default directory
(a)
Constructs a JFileChooser involving the given File as the way.Example program on JFileChooser(File currentDirectory)
(a)
- can be used to turn on or turn off the text input part of a combo box.
(a)
contains many elements that assist in building a graphical user Interface in java. Java Swing gives components like buttons, panels, dialogs, etc.
(a)
What is this declaration: public class JPanel extends JComponent implements Accessible
(a)
What decleration is this: public class JSpinner extends JComponent implements Accessible
(a)
- It is used to create a new JPanel with the specified layout manager.
(a)
- (blank) can be editable or read- only depending on the choice of the programmer.
(a)
- The object of a (blank) is a multi-line region that displays text. It allows the editing of multiple line text. It inherits JTextComponent class.
(a)
- is a part of JavaSwing package.
(a)
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ColorChooserExample extends JFrame implementsActionListener{
JFrame f;
JButton b;
JTextArea ta;
ColorChooserExample(){
f=new JFrame("Color Chooser Example.");
b=new JButton("Pad Color");
b.setBounds(200,250,100,30);
ta=new JTextArea();
ta.setBounds(10,10,300,200);
b.addActionListener(this);
f.add(b);
f.add(ta);
f.setLayout(null);
f.setSize(400,400);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
Colorc=JColorChooser.showDialog(this,"Choose",Color.CYAN);ta.setBackground(c);
}
public static void main(String[] args) {new ColorChooserExample();
}}
- is a component that displays a set of Objects and allows the user to select one or more items . (blank)inherits JComponent class.
(a)
- A (blank) can be editable or read-only. An ActionListener, ChangeListener or ItemListener interfaces can be used to handle the user actions on a JComboBox.
(a)
- It is used to return the current value of the model.
(a)
- (blank) inherits Component class. JComboBox shows a popup menu that shows a list and the user can select a option from that specified list.
(a)
- It is used to create a modeless dialog with specified Frame as its owner and an empty title
(a)
- can be used to get the selected or entered item from a combo box.
(a)
- (blank) contains many elements that assist in building a graphical user Interface in java. Java Swing gives components like buttons, panels, dialogs, etc.
(a)
- We can create a JComboBox instance from an array or vector. Most of the time, we will useComboBoxModel to manipulate ComboBox’s elements.
(a)
- It is used to construct a spinner for a given model.
(a)
- Unlike JFrame, it doesn't have maximize and minimize buttons.
(a)
- The (blank) is a simplest container class. It provides space in which an application can attach any other component. It inherits the JComponents class.
(a)
Give the two JSpinner Constructors
(a)
- It is used to add a listener to the list that is notified each time a change to the model occurs.
(a)
- It is used to create a dialog with the specified title, owner Frame and modality.
(a)
- (blank) is a class that is present in the java Swing package. The java Swing package isessential for JavaTM Foundation Classes(JFC).
(a)
- It is used to construct a spinner with an Integer SpinnerNumberModel with initial value 0 and no minimum or maximum limits.
(a)
The (blank) class is used to create a color chooser dialog box so that user can select any color. It inheritsJComponent class.
(a)
package jcolor;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Jcolor extends JFrame implements ActionListener {implements ActionListener
{
JFrame f;
JButton b;
JTextArea ta;
Jcolor(){
f=new JFrame("Color Chooser Example.");
b=new JButton("Pad Color");
b.setBounds(200,250,100,30);
ta=new JTextArea();
ta.setBounds(10,10,300,200);
b.addActionListener(this);
f.add(b);
f.add(ta);
f.setLayout(null);
f.setSize(400,400);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
Colorc=JColorChooser.showDialog(this,"Choose",Color.CYAN);ta.setBackground(c);
}
public static void main(String[] args) {new Jcolor();
}}
