Java Test Quarter 2

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Finish the following like of code that would find in the ActionEvent section of the code. Assume the user clicked on a button called,"wrap text" (e.getSource_____________

()==wraptext)

Finish the following like of code that would find in the ActionEvent section of the code. Assume the user clicked on the "New" file menu. (e.getActionCommand()_______________

.equals("New"))

How many elements (Label, JPanel, etc.) can fit into one region when using the border layout?

1 element

What is an inner class?

A class that is defined inside another class

What does AWT stand for?

Abstract window toolkit

What is the line of code to make all the crust buttons work together?

ButtonGroup crustButtonGroup = new ButtonGroup();

How do you create submenus?

By adding a menu to a menu

What does GUI stand for?

Graphic user interface

Write the line of code to create a Button that says, "Click Me."

JButton button; button = new JButton("Click Me.");

Create a check box called pepperonibox that is not selected when you create it.

JCheckBox Pepperonibox = new JCheckBox("pepperoni", false);

Create a Frame called frame

JFrame frame; frame=new JFrame("title");

Create a Label that has the message,"Click the buttons below."

JLabel label; label=new JLabel("Click the buttons below.");

Create a File menu and add it to the menubar

JMenu File = new JMenu("File"); menubar.add(File);

Write the two line of code to creat a menubar and add it to the frame.

JMenuBar menubar = new JMenuBar(); frame.add(menubar);

Create a menu item called "New".

JMenuItem New = new JMenuItem("New");

Write the line of code used to create a JPanel called panel

JPanel panel; panel= new JPanel("title");

Create a radio button called Deep-Dish and make sure that it is not selected when you create it

JRadioButton Deep-Dish = new JRadioButton("Deep-Dish", false);

Create a JTextArea called bottomText that is 10x25

JTextArea bottomText; bottomText=newJTextArea(10,25);

How does Java determine the order of menus in the menu bar?

Menus are placed from left to right in the order that they are added to the menu bar

Add an action listener to your new menu item called New

New.addActionListener(this);

What is the following line of code used for? System.setProperty("apple.la.useScreenMenuBar","true");

Puts the menu bar at the top of the screen like apple does

Write the line of code you would need to add a scroll area to the JTextArea you created in #16(bottomText)

ScrollPane scrollarea; scrollarea.add(bottomText);

Finish the following line of code that will execute commands when button1 is clicked. if(e.get______()==button1)

Source

If you use the getText() method to retrieve the text in a JTextArea, what kind of data type is it save at?

String

How many menus can you put on a menu bar?

There is no fixed limit

There are 3 ways to finish the following line of code: scrollArea.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR a. _ b._ c._

_ALWAYS, _NEVER _AS_NEEDED

Write the line of code if you wanted to add the text, "Button 2 was clicked" to the text are you created in #16(bottomText)

bottomText.setText("Button 2 was clicked");

Write the line of code to creat a JTextField called buffaloWingsText that has no text in it and is two columns wide.

buffaloWingsText = new JTextField("",2);

Write the line of code to add an action listener to a button called button1.

button1.addActionListener(this);

What does the following line of code do? System.exit(0);

closes the window and quits the program

Connect the JPanel called panel to the north region when using the border layout with contentPane

contentPane.add(panel.NORTH);

Write out the line of code to make the contentPane have the border layout.

contentPane.setLayout(new BorderLayout());

Write out the line of code to make the contentPane have the box layout along the x axis

contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.X_AXIS));

Write out the line of code to make the contentPane have the flow layout

contentPane.setLayout(new FlowLayout());

Write out the line of code to make the contentPane have the grid layout with the dimensions 3x3

contentPane.setLayout(new GridLayout(3,3));

Before you can add a radio button to a JPanel, what do you need to add it to first? Write the line of code using regularcrust and crustbuttongroup.

crustButtonGroup.add(regularCrustButton);

What does the following line of code do? System.exit(0);

exits the program

Make the frame only large enough to fit all the elements you want to display

frame.pack();

Make the size of the frame

frame.setSize(300,300);

Write the line of code you need to make the frame visible

frame.setVisible(true);

Finish the following line of code that will help select the "New" menu item. if(e.get_______()._____(_____))

if(e.getActionCommand().equals("New"))

Write the line of code to change the JButton above to say, "I've been clicked."

if(e.getSource()==button) button.setText("I've been clicked");

Which of the following is needed when you implement ActionListener? a. import java.awt.*; b. import javax.swing.*; c. import java.awt.event.*;

import java.awt.event.*;

Write the line of code that will create an inner class called newOrder inside the action listener

new.addActionListener(new newOrder());

How many menus can you have?

no fixed limit

How many menu bars can there be per GUI?

only 1 menu bar

What does this line of code do? frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

terminates the program on close


संबंधित स्टडी सेट्स

Chapter 14: Gene transcription and RNA modification

View Set

AZ 900 Fundamentals Exam Prep 2023

View Set

PNE 103. Ch. 7: The Nurse-Client Relationship. Intro. Med-Surg. Nursing. Timby/Smith. 12th. Ed.

View Set

Real Estate Law- Chapter 6 Real Estate Contracts

View Set