Java GUI With CRUD Elements
Jun 22, 2014
I would like to create a java gui (with CRUD elements) that connect to MySQL server DB and display a table records (also insert, edit, delete data to table), and I want to know how create such a gui.
View Replies
ADVERTISEMENT
Aug 12, 2014
I am trying to work with a SQL database and some JSF pages that were created with/for CRUD. The data comes up just fine but all my foreign keys show the primary key for the key not the data. So instead of having the actual Zone I get the number (my primary key) that matches the Zone.
example:
4717A Cool ReceptionTitle: Gatherer of Cool Companycom.vancowboy.lotor_db.LotroZones[ id=11 ]
The last item should read "All" not "com.vancowboy.lotor_db.LotroZones[ id=11 ]"
This was straight from a tutorial so I can learn this but the FK has got me baffled...
View Replies
View Related
Mar 28, 2014
I'm using Netbeans IDE and Glassfish application server. I have a JSF CRUD application running with a MySQL database and everything was fine until I was asked to be able to sort a column whose MySQL datatype was Varchar.
Here is my Model for Vehicles:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package entities;
import java.io.Serializable;
import java.sql.Date;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Locale;
[Code] ....
So I changed the datatype to Integer and updated my source code to change the column from String to Integer. When the list displays every thing seems good and the rows are sorted according to the column whose datatype I changed to Integer.
However when I then tried to edit nothing works and I get HTTP Status 505 from Glassfish with the error message
javax.servlet.ServletException: HV000030: No validator could be found for type: java.lang.Integer
View Replies
View Related
Feb 5, 2015
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class array
{
public static void main(String[] args)
[Code] ...
Is there a way to write this, where, alpha is one array.
Write a program that declares an array "alpha" of 50 elements of type "double". Initialize the array so that the first 25 elements are equal to the square of the index variable and the last 25 elements are equal to three times the index variable. Output the array so that 10 elements per line are printed.
If I have an array of 50 integers, can I break that to read in lines of 10?
View Replies
View Related
Jan 12, 2015
I am trying to make a 2d array that keeps track of comparison counts. what I have so far works ok but writes over the previous elements with 0. can't seem to find where I am re-initializing the previous elements.
//this is one of my fill sort arrays
public void fillSelectionArray(int index, long countSum) {
//rand = new Random( );
//for ( int i = 0; i < listsize; i++) {
selectionList[ index -1] = countSum;
// }
[Code] ....
I know I am missing something just not sure what.
View Replies
View Related
Oct 15, 2014
I have tried to print array elements using standard print statement. I am getting errors. How to print them. Here is my code:
class arrayEx1{
public static void main(String args[]) {
int a[]=new int[3]; //Declaring Single Diomentional Array
a[0]=10;
a[1]=20;
a[2]=30;
int total=a[0]+a[1]+a[2];
System.out.println("Values stored in a[0],a[1],a[2]elements are :" + a[0] a[1] a[2]);
System.out.println("Total values of a[0],a[1],a[2]elements is :"+ total);
}
}
if i give comma (,) in between above print stament (print statement 1) stil i am getting errors.
View Replies
View Related
Apr 30, 2014
remove duplicate elements in array using with java
View Replies
View Related
Mar 14, 2014
I know there was a change in the later versions of Java where the C++ equivalent of a <template type> was added. Unfortunately the change has 'broken' my older code. If I have a JList and I want to add elements to it then now I should specify the type e.g., the list will store Strings. When I do this and then add data to the list (or actually the list model) the code is ''fixed". However if after adding those new elements to the list I later need to add more elements, which isn't unreasonable for a list...to have elements added dynamically at run time then I again get the same compiler error message that I haven't correctly specified the type:
// Error message during compilation
Note: Driver.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
// My code
// Problem here: I try to add new elements to the list. It's the very last line of the method that results in the error. I tried various things such as:
// model.addElement(<String> s);
// but so far nothing has worked. How do I add new elements to the list (model)?
public static void m2(JList <String> list)
{
String s;
int i;
String [] array = new String[10];
[Code] ....
// Code is OK: Create the array of strings to add to constructor of the JList
public static String[] m1(){ String s;
int i;
String [] array = new String[10];
for (i = 0; i < 5; i++)
array[i] = i + "*"; return(array);
[Code] ....
// The change I had to make when compiling under the newer version of Java to indicate that the list would store strings
// Things are okay here now but then when I try to add new elements to the model via method 'm2' that's where I get the compiler error
View Replies
View Related
Oct 29, 2014
how to change the color of an output element in Eclipse? Can't seem to find it anywhere on the internet.For example, a response to my question 'What color do you want?' could be 'red'. I added an if-statement, which states if input = red, start using a red colored 'X' as string for further output.How do I obtain the color red for my X?? Or isn't it possible changing the color of output elements?
View Replies
View Related
Feb 2, 2015
I am trying to sum up the elements of an array. When I test my code the sum is always off by one. For example if I input: 20, 40,30 it gives me 89 instead of 90.
This is what I have so far:
public static void main(String[args]){
int size = kbd.nextInt();
int [] myArray = new int [size]
//user inputs the elements of array
[Code]....
View Replies
View Related
Mar 15, 2014
how to search array elements present or not using command line argument in java
View Replies
View Related
Feb 5, 2014
I have a project I am currently working on using Primefaces and MySQL. I have a page that will display information queried from the database. I have textfields that will display the data from a given record. But I want to ensure that the displayed data cannot be altered. I decided on disabling the textfields unless the create or edit button were clicked. At which point all textfields will be enabled for editing, and cleared if create button was clicked. I want to push the disabling/enabling of the elements back to a managed bean, but I want to have the bean take in two lists or arrays, one containing all elements by ID and one containing a list of exempt elements. Is there a way I can create a List or Array of the ID's that I can send to the bean? I know little in Javascript and previous attempts to implement it have met with little success.
A short example of the code:
<p:tabView>
<p:tab id=pmDBTab title="PM Database Tab">
<p:panelGrid id="projectInfo">
<p:row id="rowOne">
<p:column id="r1c1" colspan="2">
<p:outputLabel id="searchLabel" for="searchField" value="Search: " style="font-weight: bolder"/>
[Code] ....
I want to create a list that would contain all and another that would contain the exemptions such as searchField, searchCriteria, searchButton, projectList and viewButton. The actual exemption list is far smaller than the list of all children. I have found sources that can disable the elements with a java bean, but I have not been able to find one that would allow me to define those that should and should not be disabled, then vice versa for enabling.
View Replies
View Related
Aug 25, 2014
I need to write a java program to find the index of the element whose value is the sum of the remaining elements. Recently I have been asked this question in an Interview which I couldnt solve properly.
View Replies
View Related
Mar 13, 2015
I have a requirement to add elements to a map. But for, First iteration it inserts fine and for next iteration elements are overrided.
I am just wondering if there were append() in map or in any collections?
View Replies
View Related
Aug 1, 2014
public void createPersons() {
Random rand = new Random();
for(int index = 0; index < persons.length; index++) {
Person person = new Person(rand.nextInt(maxAge), persons[index]);
setOfPersons.add(person);
[Code] ....
setOfPersons is a TreeSet, persons[] is an array of strings that contains 10 names. Why printPersons() prints only the half names of setOfPersons?
Note. I do get the size of the TreeSet as 10...
View Replies
View Related
May 4, 2015
What is the sum of the array ar elements after executing the following code?
int[] ar = {1,2,3,4,5};
for (int i=0; i<ar.length-1; i++)
if (i%2==0) ar[i]=i;
My professor says the answer is 12 i dont know how he got that answer
View Replies
View Related
May 17, 2014
I cant get this code to work if wont find the right min and range and its printing out my max three times . This is what I got
public static void main(String[] args)
{
double [] Rainfall = new double[12];
Rainfall[0] = 77.4;
Rainfall[1] = 56;
Rainfall[2] = 61.8;
Rainfall[3] = 62.1;
Rainfall[4] = 57.1;
[Code] ....
View Replies
View Related
Mar 29, 2015
I have two arrays
private ReservedBook[] reservedBooks;
private LibrarySystem[] libraryBooks;
The library array has two books and I want to copy one of them to the reserved books when you type in the ISBN
public void borrowBook(String ISBN)
{
int i = 0;
if(numberOfBooks < MAX_BOOKS-1)
{
if(libraryBooks[i].getBookISBN().equals(ISBN))
{
for(i=0;i<MAX_BOOKS-1;i++)
reservedBooks[i] = libraryBooks[i];
}
else System.out.println("There is no such book");
}
else System.out.println("You have reached the maximum number of allowed books");
}
It shows me error: incompatible types - LibrarySystem cannot be converted into ReservedBook. How can I fix it?
View Replies
View Related
Aug 24, 2014
Referring Code 1, the book says line 16 of the code removes the element "Three" but line 17 does not remove the element "Four" because of Statement 1. The question is does remove(Object o) method invoke the == or the equals method because statement 1 and 2 seem to be in conflict
Statement 1:
Two objects are equal if their object references point to the same object. (which is nothing but definition of ==)
Statement 2:
The author refers to Statement 1 and says "As mentioned earlier, the method remove compares the objects for equality before removing it from ArrayList by calling method equals."
Java Code:
import java.util.ArrayList;
public class DeleteElementsFromArrayList {
public static void main(String args[]) {
ArrayList<StringBuilder> myArrList = new ArrayList<>();
StringBuilder sb1 = new StringBuilder("One");
[Code] ....
View Replies
View Related
Oct 27, 2014
So I am trying to create a code that searches if a word is square free. The user inputs a word (into an array) and then the code is suppose to see if it is square free. A word being square free means that the word doesn't contain any consecutive sub words. For example, "abcabc" is not a square free word because abc is repeated, but "abcdabc" is a square free word because there is a "d" separating the "abc".
So far I have this :
import java.util.Scanner;
public class A3Q2 {
public static void main(String[] args) {
// part (a) of the main
Scanner keyboard = new Scanner(System.in);
[Code] ....
I've been trying to experiment with different ways such as checking to see if there any duplicate elements such as,
public static char isSquareFree(char[] word){
for(char i = 1; i < word.length; i++) {
if(word[i] == word[i - 'a']) {
System.out.println("Duplicate: " + word[i]);
}
}
return word; }
}
And other methods but I'm just not getting it.
View Replies
View Related
Feb 6, 2014
Here is a small part of my program
Java Code:
// for every attribute not mentioned in the rule r
enumAtt = ruleE.enumerateAttributes();
while (enumAtt.hasMoreElements()) {
Attribute attr = (Attribute) enumAtt.nextElement();
if (isMentionedIn(attr, r.m_test)) {continue;}
int M = attr.numValues();
[Code] ....
It repeats only the last rule , why is that !!!!!!
View Replies
View Related
May 11, 2015
I have a 2D arraylist, named as adjLists, which contains arraylists, containing values like these. Each two values are a "pair" and each third is a "flag" for the pair.
[278, 106, 0, 397, 36, 0, 59, 208, 0, 366, 221, 0]
[366, 221, 0, 397, 36, 0, 132, 390, 0, 278, 106, 0, 295, 0, 0]
I use code above to search for specified value pairs in these lists. vertexnum is the number of "sub arraylists" in adjLists.
for (int l = 0; l < vertexnum; l++) {
if (adjLists.get(l).get(0) == p.x && adjLists.get(l).get(1) == p.y) {
for (int h = 0; h < adjLists.get(l).size(); h += 3) {
for (int g = 0; g < vertexnum; g++) {
if ((vertexSprite[g].getX() + vertexSprite[g].getWidth() / 2) == adjLists.get(l).get(h)
[Code] ....
This code is to search exact values and replace their flag in every occurences. It can not find all the occurences of the values/pair in the lists, it replaces flag value only a few time. Value of score should be incremented with plus 1 after each found occurence, but this code increments it more than the number of matches.
View Replies
View Related
Feb 14, 2014
i have the following code to reverse the elements of the list but i only print the last element each time
public void reverse(OrderedList<T> lister) {
OrderedList<T> listerCopy = lister;
for(int i=0;i<5;++i) {
T removed=removeFromBack(listerCopy);
System.out.printf("%s ", removed);
[Code] .....
View Replies
View Related
Mar 25, 2015
I'm currently in the process of creating a shopping cart simulation. The main GUI consists of two lists, one is a list of the inventory. (products stored within a .dat file which is automatically loaded upon launch) The other is blank and is to model my shopping basket. The idea is to be able to scan items from my inventory into the checkout basket. As this is happening i want a text field i created to dynamically update with the cost of all the items in the basket.
Below is the method for my scan button, which is supposed to perform the above :
public void actionPerformed(ActionEvent evt) {
//Get the newly added list values.
JList list = productList.getSelectedValuesList();
double totalAddedValue = 0.0;
double oldCartValue = 0.0;
[code]...
View Replies
View Related
Apr 27, 2014
ok so for class I'm supposed to Write a class DeleteElements that prints out an array and asks the user which number should be deleted and then deletes that number, if it exists from the array.
The first part tells me to
Step 1
o Start by simply searching the element.
o Pseudocode:
-Create an array and populate it with random positive integers.
-Print the array to show the user which elements the array contains.
-Use a WHILE loop to search the element—a WHILE loop is better than a FOR loop because you can stop when the element is found by using a Boolean value in the loop condition—and also keep track of the location where the
element might be found.
-If the element is not found, output the error message, “Number not found.”
-Otherwise output the message, “Number found at index #.” where # is the index where the element is.
-Print out the array.
Example of output:
34 65 12 76 45 39 86 71 67
Number to delete: 76
Number found at index 3
This is what I've got so far but I can't seem to get the "number not found part to print out only once".
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;
public class DeleteElement {
public static final int ARR_LENGTH = 10;
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Random ran = new Random();
[Code] ....
Current output result if value does not exist:
61 89 52 16 20 71 37 91 4 36
Number to delete:
23
Number not found.
Number not found.
Number not found.
Number not found.
Number not found.
Number not found.
Number not found.
Number not found.
Number not found.
Number not found.
Current output result if value exists:
97 48 51 22 89 5 42 97 43 96
Number to delete:
89
Number found at index 4
Maybe I'm not understanding the part about the boolean value.
View Replies
View Related
Nov 19, 2014
Currently I am having difficulties styling a particular prime faces element in a JSF application for work. I'm tasked with giving the ui a styling and color scheme acceptable to our project design. However I am finding myself unable to "hook" a particular pf element with an ID so that I can proceed with styling a imported .css file.
I'm trying to style the commandLink button to display in Orange 20px font with Italic but when I inspect the element in chrome after being rendered It doesn't even show its style linked to the assigned ID. The class style for mainMenuItem is being applied to the commandlink but is immediately over written by ui-widget. I'm trying to style that one single component(override/replace ui-widget with the properties in the #loggedInUserID)
Current .XHTML code and the css file has been linked with
<h:outputStylesheet library="css" name="masterPW.css"/>
<div class="mainMenuItem"><p:commandLink id="loggedInUserId" styleClass="maserPW.css" value="#{loginController.userFullName}"/>
</div><!--End of mainMenuItem-UserID div -->
[Code] ....
View Replies
View Related