Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
3rd Edition
ISBN: 9780134038179
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 13, Problem 2FTE
Explanation of Solution
Given code:
// Create a black 1-pixel border around list, a JList component.
list.setBorder(Color.BLACK, 1);
Error in the statement:
In java swings, the border is given using the method “createLineBorder()” of class “BorderFactory”. Here the code should read “list.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));”
Corrected statement:
// Create a black 1-pixel border around list, a JList component...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
the android code is like this
ublic class PlayerActivity2 extends AppCompatActivity { ListView simpleList; String SerialNo[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}; int flags[] = {R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6, R.drawable.image7, R.drawable.image8, R.drawable.image9, R.drawable.image10}; String Names[] = {"mmm", "nnn", "aaa.", "bbb", "ccc", "ddd", "eee jk", " ijk", "Virgil jk", "gil jklk"}; String Score[] = {"1", "2", "3", "5", "4", "3", "5", "5", "5", "5"};
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity2); simpleList = (ListView) findViewById(R.id.simpleListView);
CustomAdapter customAdapter = new CustomAdapter(getApplicationContext(), simpleList, SerialNo, flags, Names, Score); simpleList.setAdapter(customAdapter);…
Using Java programming language create a linked list named Cars with four elements: "SUV cars", "Pickup cars", "Sport cars", and "Sedan cars".
Apply the following activities on the code you’ve created and provide screen shot of each result:
Add a new element “Classic car” at the beginning of the linked list using iterator.
Add a new element “Economic cars" after the element "Sedan Cars" using iterator.
Print the LinkedList backward from the last element to the first element using hasPrevious()
How does the map react when a new entry is added with an already existing key?
Chapter 13 Solutions
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Ch. 13.4 - How do you make a text field read-only? In code,...Ch. 13.4 - Prob. 13.2CPCh. 13.4 - Prob. 13.3CPCh. 13.4 - Prob. 13.4CPCh. 13.4 - Prob. 13.5CPCh. 13.4 - Prob. 13.6CPCh. 13.5 - Prob. 13.7CPCh. 13.5 - Prob. 13.8CPCh. 13.5 - Prob. 13.9CPCh. 13.6 - Prob. 13.10CP
Ch. 13.6 - Prob. 13.11CPCh. 13.8 - Briefly describe each of the following menu system...Ch. 13.8 - Prob. 13.13CPCh. 13.8 - Prob. 13.14CPCh. 13.8 - Prob. 13.15CPCh. 13.8 - Prob. 13.16CPCh. 13.8 - What class do you use to create a menu? What do...Ch. 13.8 - What class do you use to create a menu bar?Ch. 13.8 - Prob. 13.19CPCh. 13.8 - Prob. 13.20CPCh. 13.8 - Prob. 13.21CPCh. 13.8 - Prob. 13.22CPCh. 13.9 - Prob. 13.23CPCh. 13.9 - Prob. 13.24CPCh. 13.9 - Prob. 13.25CPCh. 13.9 - Prob. 13.26CPCh. 13.9 - Prob. 13.27CPCh. 13.9 - Prob. 13.28CPCh. 13.10 - Prob. 13.29CPCh. 13.10 - Prob. 13.30CPCh. 13 - Prob. 1MCCh. 13 - Prob. 2MCCh. 13 - Prob. 3MCCh. 13 - Prob. 4MCCh. 13 - Prob. 5MCCh. 13 - Prob. 6MCCh. 13 - Prob. 7MCCh. 13 - Prob. 8MCCh. 13 - Prob. 9MCCh. 13 - Prob. 10MCCh. 13 - Prob. 11MCCh. 13 - Prob. 12MCCh. 13 - Prob. 13MCCh. 13 - Prob. 14MCCh. 13 - Prob. 15MCCh. 13 - Prob. 16MCCh. 13 - Prob. 17MCCh. 13 - Prob. 18MCCh. 13 - Prob. 19MCCh. 13 - Prob. 20MCCh. 13 - Prob. 21MCCh. 13 - Prob. 22TFCh. 13 - Prob. 23TFCh. 13 - Prob. 24TFCh. 13 - Prob. 25TFCh. 13 - Prob. 26TFCh. 13 - Prob. 27TFCh. 13 - Prob. 28TFCh. 13 - Prob. 29TFCh. 13 - Prob. 30TFCh. 13 - Prob. 31TFCh. 13 - Prob. 32TFCh. 13 - Prob. 33TFCh. 13 - Prob. 34TFCh. 13 - Prob. 35TFCh. 13 - Prob. 1FTECh. 13 - Prob. 2FTECh. 13 - Prob. 3FTECh. 13 - Prob. 4FTECh. 13 - Prob. 5FTECh. 13 - Prob. 6FTECh. 13 - Prob. 7FTECh. 13 - Prob. 1AWCh. 13 - Prob. 2AWCh. 13 - Prob. 3AWCh. 13 - Prob. 4AWCh. 13 - Prob. 5AWCh. 13 - Write code that stores the image in the file...Ch. 13 - Prob. 7AWCh. 13 - Prob. 8AWCh. 13 - Prob. 9AWCh. 13 - Prob. 10AWCh. 13 - Write the code that creates a menu bar with one...Ch. 13 - Prob. 12AWCh. 13 - Prob. 1SACh. 13 - Prob. 2SACh. 13 - Prob. 3SACh. 13 - Prob. 4SACh. 13 - Prob. 5SACh. 13 - Prob. 6SACh. 13 - Prob. 7SACh. 13 - Prob. 8SACh. 13 - Prob. 9SACh. 13 - Prob. 10SACh. 13 - Prob. 11SACh. 13 - Prob. 12SACh. 13 - Prob. 1PCCh. 13 - Prob. 2PCCh. 13 - Dorm and Meal Plan Calculator A university has the...Ch. 13 - Skateboard Designer The Skate Shop sells the...Ch. 13 - Shopping Cart System Create an application that...Ch. 13 - Prob. 8PCCh. 13 - Prob. 9PC
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Q2 Answer Q2(a)-Q(d) based on the information given in Figure Q2. to record daily information of at Liney Restaurant. The program creates a linked list in /"This program is meant the menu available which each node contains data such as menu name, price per unit, preparation time, quantity ordered and a pointer. The declaration of the structures MenuData and MenuNode are given in the program.*/ tinclude tinclude tinclude #define SIZE 20 struct Menubata char menuName (20]; double price PerUnit; double prepzime; int quantityordered, typedef struct Menubata MenuData; struct MenuNode MenuData data; struct MenuNode *next; typedef struct Menutode MenuNode, void showPrepTime (MenuNode *fftr): int main () MenuNode *front = NULL, *newNodePtr; MenuData input Data, for (int i=l; i<=SIZE, i++) printf ("\nEnter menu name: "): gets (inputData.menuName): printf ("\nEnter price per unit: "); scanf ("$lf", 5inputData.pricePerUnit); printf("\nEnter preparation time (hours): "): scanf ("lf", &input…arrow_forward3. Create an ArrayList of strings to store the names of celebrities or athletes. Add five names to the list. Process the list with a for loop and the get() method to display the names, one name per line. Pass the list to avoid method. Inside the method, Insert another name at index 2 and remove the name at index 4. Use a foreach loop to display the arraylist again, all names on one line separated by asterisks. After the method call in main, create an iterator for the arraylist and use it to display the list one more time. See Sample Output. SAMPLE OUTPUT Here is the list Lionel Messi Drake Adele Dwayne Johnson Beyonce Here is the new list * Lionel Messi * Drake * Taylor Swift * Adele * Beyonce Using an iterator, here is the list Lionel Messi Drake Taylor Swift Adele Beyoncearrow_forwardthis is an android app with android studio . package com.example.myapplication;import androidx.appcompat.app.AppCompatActivity;import android.os.Bundle;import android.widget.ListView;public class PlayerActivity2 extends AppCompatActivity {ListView simpleList;String SerialNo[] = {"1", "2", "3", "4", "5", "6","7","8","9","10"};int flags[] = {R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6, R.drawable.image7, R.drawable.image8, R.drawable.image9, R.drawable.image10};String Names[] = {"mmm", "nnn", "aaa.", "bbb", "ccc", "ddd","eee jk"," ijk","Virgil jk","gil jklk"};String Score[] = {"1", "2","3", "5", "4", "3","5","5","5","5"};@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity2);simpleList = (ListView)findViewById(R.id.simpleListView);//ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, R.layout.activity_listview,…arrow_forward
- in this android app package com.example.myapplication;import androidx.appcompat.app.AppCompatActivity;import android.os.Bundle;import android.widget.ListView;public class PlayerActivity2 extends AppCompatActivity {ListView simpleList;String SerialNo[] = {"1", "2", "3", "4", "5", "6","7","8","9","10"};int flags[] = {R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6, R.drawable.image7, R.drawable.image8, R.drawable.image9, R.drawable.image10};String Names[] = {"mmm", "nnn", "aaa.", "bbb", "ccc", "ddd","eee jk"," ijk","Virgil jk","gil jklk"};String Score[] = {"1", "2","3", "5", "4", "3","5","5","5","5"};@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity2);simpleList = (ListView)findViewById(R.id.simpleListView);//ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, R.layout.activity_listview, R.id.textView,…arrow_forwardArray Lists & Graphics: Create a project in Eclipse named Blinds. Include two classes: Rainbow and RainbowViewer. Using the colours in Table 1 in any order you want, create a 13 rows x 1 column arrangement of Rectangles (width = 500, height = 50) starting at x = 50, y = 50 with the BLACK square. Use an ArrayList to store the 13 rectangles that form the blinds. [Hint: While creating each rectangle, you can use a for loop. When ready, use the .fill method to paint them onto a JFrame (600x800) with title: “My ColourfulBlinds”.]arrow_forwardJava OOParrow_forward
- When you print an instance of the class Food in Question 1, you get something like this: Building up your answer coder in Question 1, write a str 0 method for the class Food so that printing an instance of the class results in a string that is a combination of the value of the attributes taste and name, separated by a blank: DO NOT call the function. For example:arrow_forwardAssume ArrayList productList contains 10,000 items. Which operation is performed fastest? Group of answer choices productList.remove(999) productList.remove(0) productList.add(0, item) productList.add(item)arrow_forward//arrow_forward
- PLEASE REFER TO THE IMAGES FOR INSTRUCTIONS PLEASE USE STARTER CODE - CODE IN PYTHON3 ### starter code import random def spider_web(web_map, starting_place, destination): pass def spider_web_rec(web_map, starting_place, destination, visited): pass def make_spider_web(num_nodes, seed=0): if seed: random.seed(seed) web_map = {} for i in range(1, num_nodes + 1): web_map[f'Node {i}'] = [] for i in range(1, num_nodes + 1): sample = random.sample(list(range(i, num_nodes + 1)), random.randint(1, num_nodes - i + 1)) print('sample', i, sample) for x in sample: if i != x: web_map[f'Node {i}'].append(f'Node {x}') web_map[f'Node {x}'].append(f'Node {i}') return web_map if __name__ == '__main__': num_nodes, seed = [int(x) for x in input('Input num_nodes, seed: ').split(',')] the_web = make_spider_web(num_nodes, seed) print(spider_web(the_web, 'Node 1',…arrow_forwardCreate an ArrayList of strings to store the names of celebrities or athletes. Add five names to the list. Process the list with a for loop and the get() method to display the names, one name per line. Pass the list to a void method. Inside the method, Insert another name at index 2 and remove the name at index 4. Use a foreach loop to display the arraylist again, all names on one line separated by asterisks. After the method call in main, create an iterator for the arraylist and use it to display the list one more time.arrow_forwardIs there a consequence for adding a new key-value pair to an existing map entry?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT