I have code which query value from database,the use case is the user can enter value as 1,01,11 in database but when the user enter value in xml file he can only enter 11,01,12 in database there is two columns lets say column test1=1 and test2=2 combination of this is 12,which is the value the use will enter in xml, but sometime the use can enter test1=04 than column test2=00 ....
I need to display a list of environment id's out of my xml file into a JComboBox. I understand fine how to make lists and what not but examples are always hard coded.
I have a practice program (written with NetBeans IDE 7.4) that calls methods to:
(1) fill an array with user input values
(2) sort the array values into ascending order
(3) print the array in assorted order.
(4) print the array without any duplicates
Method (4) prints the contents of the array without printing any duplicates. That is, if a number in the array has already been printed, it will not be printed again.
Method (4) seems to work, but may be inefficient or I may have done too much work making it difficult on myself or making the logic too confusing.
Is there a better way to do this WITHOUT using built-in functions in Java's library?
(Such as writing this method using for loops and counter variables: As practice I am supposed to avoid using Deleting functions for duplicates)
Here is my code:
public static void Duplicates(int [] array){ int duplicates = 1; String Output = ""; for(int i = 0; i < array.length -1; i++) { if (array[i] != array[i+1]){ duplicates ++;
I have a colour coded table, the JComboBox has items that are also colour coded to correspond to the colours on the table.
My ComboBox contains:
comboBoxSFMotor.addItem("Select a Value"); comboBoxSFMotor.addItem("Electric"); comboBoxSFMotor.addItem("DC Shunt"); comboBoxSFMotor.addItem("Combustion");
How can I set a background colour for each of the items in the JComboBox that will correspond to the table so that the user can make an easy selection?
How to print database report in hard copy. I have try to do this with the code below but it only print empty plain paper. Find the code below:
printbtn.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ Vector columnNames = new Vector(); Vector data = new Vector(); String host = "jdbc:odbc:staffsalary";
I just installed java on my computer because i was getting messages that it was no longer there. And I figured out how to solve my problems on my browsers. but i don't see how to enable java in my applications on the hard drive. in particular, i want to use the database in open office but don't see how to enable it.
I have been playing around with my code, but how to avoid NullPointerexception.. So my program's point is simple, use Jsoup to scrape html of certain webpage, then i search the things i want and print them out. Problem is, when scraped html doesnt contain even 1 thing on my search list, i get NullPointerException... i understand why, Heres part of my code:
Java Code:
//Things i need to search from html String[] MySearchArray = new String[]{"138","146","474"}; //Search things contained in MySearchArray and print them out for (String Ml : MySearchArray) { Element flights = doc.select(String.format("tr:contains(%s)", Ml)).first(); Elements flights2 = flights.select("td"); System.out.println(flights2.get(4).text() + " " + flights2.get(0).text()+ " " + flights2.get(3).text()); } mh_sh_highlight_all('java');
I have a HashMap with multiple values at runtime. In that map one key has empty value , how to avoid this value to add in a list. some code sample is below:
public HashMap getLoop2Map(Map map, String xslFile , int sheetNo){ HashMap hashMap = new HashMap(); try{ ArrayList list = new ArrayList(); System.out.println("-------Map : " +map); list.add(map.values()); //System.out.println("------- boolean : " +val); System.out.println("------List : " +list); }
I do not want to add the empty value in a list ...
result in map
-------Map : {Free Text Entry={}, Mouth / Throat={Free Text Entry={Free Text Entry=<FORMFILENAME>EditChartPhysicalExamText.form </FORMFILENAME><TAG>"<MUSCULOSKELETAL.PE>"</TAG>}, Salivary Glands Condition={Salivary Glands Condition=MouthAttribute}, Examination Overview- Mouth / Throat={Examination Overview- Mouth / Throat=MouthAttribute}, Tonsils={Tonsils=MouthAttribute},
I'm struggling with that piece of code, my intention is to check for the object I want to add before adding it, so there won't be any duplicate on my list. I'm not sure how could I do that, since I'm working with objects.
Person is a class with few parameters such as id, name, and few others.
I guess I should search for a person with the same id, since that has be unique, but can't get it right.
private ArrayList<person> model= new ArrayList<>(); //... if (model.contains(person))throw new IllegalArgumentException("duplicate"); else model.addElement(person);
I wanted to make a small program to move a small rectangle by pressing the WASD keys. The program works, except that when I hold a key to move the rectangle, after a second, auto-repeat starts up, and the rectangle motion accelerates. I want to prevent automatic repeat to activate, so that the rectangle moves at a constant speed when I hold a key and stops when I released. Here is the ButtonMotion classe :
I'm using EclipseLink, WildFly, EJB, postgresSQL and JSF.I'm trying to persist some countries and their localities.So I've:
- Two entities Countries and Localities in which I specify respective columns and relations. - Abstract Session beans for entity classes: AbstractFacade providing basic crud methods and entity manager. - Two concrete session bean for entity classes: CountriesFacade and LocalitiesFacade. - A JSF managed bean named geoJSF. - A JSF page with a form allowing to insert new country and localities.
In geoJSF I'm injecting via EJB CountriesFacade as property named cf and LocalitiesFacade as property named lf.For the actual inserting country and locality I'm using geoJSF.country and geoJSF.locality. When the form is submitted I'm simply doing:
this.cf.create(this.country); this.locality.setCountry(this.country); //<- this throw an exception (unique constraint violation) due to the attempt to reinsert this.country this.lf.create(this.locality);
I disabled all cascade among relations definitions.Based on what I know this.country should appear detached to entity manager so, setting relation the entity manager try to re-persist it.
The method I am trying to successfully write is startsWith(String s1, String s2)
The intention of the code is to return true if s2 starts with the string s1, and false otherwise. For example,
x.startsWith("Maplestory","Maple"); Should return true.
This code partially works, depending on the values entered into it. When it is supposed to return true, it does do this. When it is meant to return false, I get a StringIndex OutOfBounds Exception.
public class CC02{ String remove1(char c, String s){ String to_return=""; while(true){ if(s.equals("")) return to_return;
[Code] ....
The method I have written uses one other method from my code, which is "reverse". Any way to return false without getting this error.
I'm writing an IRC server in Java, however when a client tries to connect I get a ConcurrentModificationException trying to add them to an ArrayList. My code is Here: [URL]
I don't understand why I am getting a ConcurrentModificationException or what one is.
I want to create a ScrollPane where I can scale the contents. Think of a simple drawing program that allows you to zoom in and zoom out.
If I create a ScrollPane in SceneBuilder and then drop a couple of Circles into the AnchorPane all looks good.
If I then set a scale of 0.5 for the AnchorPane Scale X and Scale Y the AnchorPane gets scaled about its centre leaving space between the left and top edge of the AnchorPane and the left and top edge of the enclosing ScrollPane.
The only way to get the AnchorPane so that it aligns with the top left of the ScrollPane seems to be to add a negative amount to Translate X and Translate Y.
In my application I would like the user to be able to adjust the zoom (Scale) continually and also the size of the AnchorPane must be allowed to change as the user add/deletes/edits content.
Does this mean I have to continually monitor the AnchorPane properties and set compensating Translate X and Translate Y values each time? Or is there an easier way to achieve what I want?
We have developed a java application, whose primary objective is to read a file(input file), process it and convert it into set of output files. (I have given a generic description of our solution, to avoid irrelevant details).
This program works perfectly fine when the input file is of 4 GB, with memory settings of -Xms4096m -Xmx16384m in a 32 GB RAM
Now we need to run our application with the input file of size 130 GB.
We used a linux box with 250GB RAM and with memory setting of -Xms40g -Xmx200g (also tried couple of other variations) to run the application and hit OutOfMemory Exception.
At this stage of our project it's very hard to consider redesigning the code to accommodate hadoop ( or someother large scale data processing framework), also the current hardware configuration which we can afford is 250GB of RAM.
Any ways to avoid OutOfMemory Exceptions, what is the general practice when developing these kind of applications.?
I need a way to store the pixels values currently on the screen and compare them to the values on the first frame. Right now I'm using glreadpixels as follows:
currentBuffer= BufferTools.reserveByteData(mapSize); glReadPixels(mapStartX, mapStartY, mapWidth, mapHeight, GL_BLUE, GL_UNSIGNED_BYTE, currentBuffer); for (int i = 0; i < mapSize; i++) { if (currentBuffer.get(i) != baseBuffer.get(i)) { //Do nothing continue; } //Do something }
This works perfectly fine but turns out to be a real bottleneck, dropping the fps to a third of what it was. Is there any quicker way? All I'm after is speed, I don't even need to show it on the screen if the comparison is made "behind the scene".
I have a question in mind that this is my registration form. I am sending these values from HTML form to server and database. I have question that in my case if I click next to Add Another Mobile no in HTML.then a block is genereated and each time a new name is generated.
My Question is if I click 6 times then 6 name attribute are generated. How can I send and differentiate them on my server side.
Because at their I will use something request.getAttribute("Attr_Name");
I have a JScrollPane with two coulmns. In the first column I have an image pane JTable, and in the second a list with names of sections. This second column I try to divide in two columns, one (the second column) to display the names of the sections (each row contains one name), and in the other column (the third) I want to show some values for every section in the row respectively. But, instead of displaying the desired values in the third column, I get the same names of the sections as in the second column.
I'm doing an aggregation exercise that's suppose to find the volume and surface area of a cylinder. What I'm trying to do is pass values from one class, to a second class, and that second class passes values to a third class.
This may be a clearer explanation: The first class is the main program which sends values to the second and third class. The second class is used do calculations for a circle (a pre-existing class from another assignment). The third class grabs the values that the second class calculated and calculates those values with the one that was passed from the first class to the third class. The first class then prints the outcome.
Problem is when the program gets to the third class, it just calculates the value from the first class with the default constructor from the second class. It's like the second class never received the values from the first class. I think I'm missing a step, but I don't what it is.
First Class:
package circle; import java.util.Scanner; public class CylinderInput { static Scanner in = new Scanner(System.in); public static void main(String[] args) { //user defined variable