So I have to create an arraylist that is connected to check boxes. Here are my current codes that I am working with. I am just focusing on making the GUI before I get into making the price calculator and everything along with that.
I need to apply the check boxes that are in the listener to the arraylist that is in the original class
Java Code:
PizzOrderPA3 toppings2 = new PizzaOrderPA3
JCheckBox toppings2 = new JCheckBox();
toppings2.addTopping("Pepperoni");
toppings2.add("Sausage");
toppings2.add("Mushroom");
toppings2.add("Bacon");
toppings2.add("Extra cheese"); mh_sh_highlight_all('java');
That is the code that I am working with but how to go along with this.
I am writing a program with different screens. At first you have to log in to access the program. So I have a problem with the variables username and password. I can't seem to get theme from the DbConnection class. I suppose it is a basic problem?
In the DbConnection class i have a problem with the returns.
In the Login class i have a problem with the connection.getUsername(); and connection.getPassword();
Here is some code:
class DbConnection package kim.contracts.database; import java.sql.*; public class DbConnection { private Connection conn; private Statement st; private ResultSet rs;
I used Primefaces 4.0.7.I has trouble with checkboxes, which are not change,with unselected checkboxes when I press . I mean, i selected someone from selectone menu in my bsPanel(first panel) and then the datatable fills with his/her duty.Then I select all the duties in the datatable to assign to someone else in bilgiPanel. Then duties assign this person and then i choose same person in the top panel(bsPanel),then datable seems with selected sutiesHere xhtml file;
I was tasked to do a 2-4 player network card game. Before I jumped into doing the card game. I decided to try out an a simple program which is the clients taking turns to type in their textfield.
I have a server that listens to 3 incoming client connections. once all 3 clients is being connected,
Steps
1) The first client will send the message first while the second and third client will wait for the first client to finish sending.
2) After the first client finished sending the message, it will be second client turn to send the message and the third client will wait for the second client to send finish.
3) After the third client finished sending the message, it will be third client turn to send the message and the first client will wait for the third client to send finish and (go back to step 1))
**The first client can only start typing once all 3 clients is being connected**
In my server class,I spawn a new Thread once a client is connected, I do a wait() on each time the client is being connected, I stored the thread in a arraylist as well. I have an id to keep track how many clients is currently connected. once the id reaches 3, I used notifyall() to notify all the threads and set the first position of my arraylist as my currentThread so that I can keep track which is the currentThread running.
I started 3 clients. and I typed the textfield of the first client but my server isn't receiving any messages.
class Server implements Runnable { private List<SpawnNewThread> sntList = new ArrayList<SpawnNewThread>(); private SpawnNewThread currentThread; private int id = 0;
How to store the images captured from a system using web cam(from where the web application accessed) to a folder of system(where the web application is deployed) connected through lan......?
Through this applet I am capturing the image and saving in the application deployed directory and accessing this image through a servlet. Every thing works fine in my system but when i try to capture from other systems connected through lan the image not saving in my system.
I'm trying to create a server which sends the clients connected to it its local time. Looking at a few tutorials I've managed to connect the clients to the server, but can't send data to the clients. I've successfully done easier examples, without threading. I guess the problem might be im me not knowing what exceptions are for.
Client: When running the code "AAAAAAA" does execute but "BBBB" doesn't, so I guess the problem should be in fraseRecibida = entradaDesdeServidor.readLine();
import java.io.*; import java.net.*; import java.util.Scanner; public class Client { public static void main(String[] args) throws Exception{ String fraseRecibida;
[code]....
I don't understand the exceptions, maybe I should give them a look before continuing with sockets. Being frank I'm not really sure why the while(true) is there.
import java.io.*; import java.net.*; import java.util.Calendar; public class ServerThread extends Thread{ Socket socket; ServerThread(Socket socket){ this.socket = socket;
private int [] selectedAnimals; ... public int[] getSelectedAnimals() { return selectedAnimals; } public void setSelectedAnimals(int[] selectedAnimals) { this.selectedAnimals = selectedAnimals; }
I would like to know how to display the values of selected checkboxes on the JSF page after submitting the form? I tried outputtext, however it displays the object and not the values. I cannot even frame the outputformat for the same.
i am very new to Java and i need to create a code that includes check-boxes, radio-buttons, and drop down menus. I decided to make a server order form and listed choices of appetizers, entrees, and desserts. I also need to create a button that combines all selected menu items and outputs the final food order. I also need to create a reset button.
I have stumbled onto a problem with ArrayLists (not sure if nested ArrayList objects would be a more accurate description) ....
As simply put as I can describe it, I have an Inventory class which creates an ArrayList of a Product superclass, which has two subclasses, PerishableProduct and ItemisedProduct.
By default, the program is meant to have a starting inventory, which is why I have added them in the constructor
public class Inventory { private List<Product> products; public Inventory() { addProduct(new Product("Frying pan", 15, 20)); addProduct(new PerishableProduct("Apple", 5.8, 30, 7)); addProduct(new ItemisedProduct("Cereal", 5.8, 0)); // this is where I am having problems. Wanting to add // objects to the ItemisedProduct's ArrayList for cereal. }
Within the ItemisedProduct subclass is yet another ArrayList which is meant to hold serial numbers.
public class ItemisedProduct extends Product { private ArrayList<String> serialNumbers = new ArrayList(); public ItemisedProduct(String name, double price, int qty) { super(name, price, qty)
[Code] .....
My problem is that I do not know how to populate the serialNumbers ArrayList from the Inventory class' constructor. Because technically, quantity is defined by how many serial numbers are created.
I have an ArrayList of employee and ArrayLsit of bosses, and I want to keep those people in a temporary ArrayList , then ordain alphabetically by name, to sort I use the interface comparator.
The problem comes when I will order 2 ArrayList(workers and bosses), because every time I call I use these functions or not is ordered (sortByNameAlphabetical())
public class Employee { private String name; public String getName() { return name; } @Override public String toString() { return name ;
I'm creating a card game assignment... so i have an arraylist called cards that has 20 cards and every card has contains 2 objects, suit and the point Value.
I shuffled the deck, now i want to add half of it to player 1 and the rest of the cards goes to the bot or computer.
how can i add the cards to the player one arraylist and have all the information of the cards?
here is my Deck class code :-
public class Deck { private ArrayList cards; private int size; private ArrayList player1; private ArrayList bot;
[code]....
the problem i have is this one doesn't work
size = cards.size() / 2; for (int i = 0; i < size - 1; i++) { player1.add(cards.get(i)); } for (int s = size; s < cards.size() - 1; s++) { bot.add(cards.get(s)); }
Right now, i'm trying to do is when a user clicks on my GUI button, it would display a text of information on the button they selected. I'm using an arraylist of objects and i'm trying to input the function inside the mouse click function. But I'm not sure how to properly display that information. Here is my GUI code. I'm working on the raven button. I have animal interface, with a parent class of Bird, and child class of Raven. How I could display this correctly...
public class AnimalJF extends JFrame { private JPanel contentPane; private JTextArea textArea = new JTextArea(); /** * Launch the application. */ public static ArrayList<Bird> Birdlist = new ArrayList<Bird>(); public static void main(String[] args) { Birdlist.add(new Eagle());
I am currently working on a program that will read from a .txt file to create an arraylist. I will be working with the objects in the list to perform computations and display the data. The .txt file is in the following format: lastName firstName hoursWorked hourlyRate
With no delimiters. I've messed with this thing way too much in the last 12 hours (only day off for the week ) so variable names etc have changed often. At present the error I am receiving is "error: constructor GrossPayService in class GrossPayService cannot be applied to given types".
import java.util.*; import java.io.*; import java.text.*; class AryListObjects { public static void addEmployee(String firstName, String lastName, double hoursWorked, double hourlyRate) { ArrayList<GrossPayService> employees = new ArrayList<GrossPayService>();
I've this "program" that shall manage to register a dog, show a list of all registerd dogs and delete dogs from the list.. And I'm stuck at the latter one. So I've to classes, one for the dog and one for register/program. This is my main program
package hundRegister; import java.util.Scanner; import java.util.ArrayList; public class HundProgram { private static Scanner tangentbord = new Scanner (System.in); private static ArrayList<Hund> hundlista = new ArrayList<>();
[Code] ......
So, when I enter a name on a dog that exist on my list, it just jumps down to } else { and write that dog can't be found even if I write the exact name on the dog.
I can't see what I'm doing wrong, been trying out different methods now.
I'm making a program for my class's chapter on classes. I need to make a program that makes a grocery list using an array. Here's the assignment from the book.
Write a class named GroceryList that represents a list of items to buy from the market, and another class named GroceryItemOrder that represents a request to purchase a particular item in a given quantity (example: four boxes of cookies). The GroceryList class should use an array field to store the grocery items and to keep track of its size (number of items in the list so far). Assume that a grocery list will have no more than 10 items. A GroceryList object should have the following methods:
public GroceryList() Constructs a new empty grocery list. public void add(GroceryItemOrder item) Adds the given item order to this list if the list has fewer than 10 items. public double getTotalCost() Returns the total sum cost of all grocery item orders in this list.
The GroceryItemOrder class should store an item quantity and a price per unit. A GroceryItemOrder object should have the following methods:
public GroceryItemOrder(String name, int quantity, double pricePerUnit) Constructs an item order to purchase the item with the given name, in the given quantity, which costs the given price per unit. public double getCost() Returns the total cost of this item in its given quantity. For example, four boxes of cookies that cost 2.30 per unit have a total cost of 9.20. public void setQuantity(int quantity) Sets this grocery item’s quantity to be the given value.
I have the assignment mostly done, but the JUnit test case our teacher gave us to test it tests add() an array instead of an array list. For this reason, I need to change my program to use an array. My code is below.
import java.util.*; public class GroceryList { private ArrayList<GroceryItemOrder> list; int num; public GroceryList() { list = new ArrayList<GroceryItemOrder>(10);
How can i sort my ArrayList, which contains cars, with year and used year, i want to sort them first from year, and then from used year . what should i use?
I am trying to add the contents of the iterator to an arraylist so I can do other stuff to it, however I am getting an error when I actually try adding it to the list, stating that
"The method add(Map.Entry<String,myObject>) in the type ArrayList<Map.Entry<String,myObject>> is not applicable for the arguments (myObject)"
Here is what I have tried doing:
Iterator<Map.Entry<String, myObject>> iterator = hash.entrySet().iterator();//hash is my HashMap object ArrayList<Map.Entry<String, myObject>> list = new ArrayList<Map.Entry<String, myObject>>(); while(iterator.hasNext()){ Map.Entry<String, myObject> entry = iterator.next(); list.add(entry.getValue());//error here }
I am trying to read a file into an array list, change some things about it, and then write it to another file. Files are getting written with what was read repeating a second time. I've tested the read method by having it print everything which goes into the ArrayList object. I then did the same with the write method which seems to write everything twice, as if everything is in the ArrayList twice, but I'm not sure how this is possible, since the read clearly did everything only once. Perhaps the ArrayList isn't the best collection to use for this purpose.
The read method:
Java Code:
private ArrayList<String> read(File in) { String line; ArrayList<String> data = new ArrayList<String>(); try { BufferedReader r = new BufferedReader(new FileReader(in));