Question: What is a widget in Swing? a. a gui component to provide a single interaction point for the direct manipulation of a given kind of
What is a widget in Swing?
| a. | a gui component to provide a single interaction point for the direct manipulation of a given kind of data | |
| b. | a small interactive application to display information or access a function | |
| c. | Both a and b are correct | |
| d. | None of these are correct |
If we want to ensure a selection of only 1 option from among many is guaranteed what should we do?
| a. | For each category of options, you need to create a ButtonGroup instance and add radio buttons for each option to it | |
| b. | You need to create check boxes for each option and add it to your GUI to see it | |
| c. | You need to create the radio buttons for each option and add it to your GUI to see it | |
| d. | None of these are correct |
If you wish to display text using multiple fonts and styles in the same component, with the option to initialize it with HTML from a separate source, you should use which of the following?
| a. | JFormattedTextField | |
| b. | JEditorPane | |
| c. | JTextField | |
| d. | JTextPane |
A JMenuItem object is technically viewed as what?
| a. | Distinctly different from buttons | |
| b. | None of these are correct | |
| c. | A subclass of JMenu | |
| d. | A type of button |
Font Metrics and Imageable Area are only determined within what section of code?
| a. | The print method | |
| b. | None of these are correct | |
| c. | The paintComponent method | |
| d. | The PageFormat Object at any time |
To display a menu you must first have which of the following?
| a. | A menu item | |
| b. | A menu object | |
| c. | A panel | |
| d. | A menu bar |
What is the root of any Swing based standalone application's containment hierarchy?
| a. | A JFrame | |
| b. | A JPanel | |
| c. | A JTextPane | |
| d. | The content pane |
Take a look at the following code snippet: public class Main extends JPanel implements ActionListener { JLabel message = new JLabel(); boolean onOff = true; public void actionPerformed(ActionEvent e) { if(onOff) message.setText("Hello"); else message.setText("Goodbye"); onOff = !onOff; } public Main() { JButton b = new JButton("Click Me!"); Timer t = new Timer(1000, this); t.setInitialDelay(1000); t.start(); add(b); add(message); } private static void createAndShowGUI() { System.out.println("Created GUI on EDT? "+ SwingUtilities.isEventDispatchThread()); JFrame f = new JFrame("Basic JFrame"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Main m = new Main(); f.add(m); f.pack(); f.setVisible(true); } ... }
| a. | Nothing, the action listener was not correctly registered on the button. | |
| b. | The user will see a label display "Hello" after 1000 seconds, and then say "Goodbye" after 1000 seconds, and constantly alternate between the two. | |
| c. | Nothing, the action listener was not correctly registered on the timer. | |
| d. | The user will see a label display "Hello" after 1 second, and then say "Goodbye" after 1 second, and constantly alternate between the two. |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
