Java Netbeans - JCombobox With Two Lists
Feb 9, 2014
I have two JComboBox the first contains a list of patients, the second a list of antibiotics I want to make a button when I chose an antibiotic and a patient they will be added in my database (sql server)
View Replies
ADVERTISEMENT
Nov 27, 2014
I currently don't understand how the node's work.
private static class Node<AnyType>
{
private AnyType data;
private Node<AnyType> next;
public Node(AnyType data, Node<AnyType> next)
{
this.data = data;
this.next = next;
}
}
Why do I make private Node<AnyType> next;And why do I have an inner class of Node for a linked list?I had the same topic in C, but there it was somehow easier than in java. Because there you have pointers.
View Replies
View Related
Oct 25, 2014
I'm working with Doubly Linked Lists and using Java Generics..
My nodes looks like this:
class DNode<E> {
DNode<E> previous;
DNode<E> next;
E element;
//and all methods inside
}
My list of Nodes looks like this:
class DLL<E>{
private DNode<E> head;
private DNode<E> tail;
private int size;
[code]....
As you can see, as arguments they get "E o"...I need to write a program, which from the main function asks the users how long is the list, and after they type it's length, I ask them to start typing the elements (integers)...and this is how my main method is written, but I can't seem to make it work, specialy when I call the "insLast" method,I guess it's because the arguments i'm giving to the function...how to read the elements and write them into the list?
public static void main(String[] args) throws IOException {
DLL<Integer> lista=new DLL<Integer>();
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
String s = stdin.readLine();
int N = Integer.parseInt(s);
s = stdin.readLine();
String[] pomniza = s.split(" ");
for (int i = 0; i < N; i++) {
lista.instLast(Integer.parseInt(pomniza[i]));
}
}
View Replies
View Related
Oct 9, 2014
I am trying to write a code that allows you to input 2 lists and it tells you if they are identical or not. However, when I enter my fist list I can only enter two values and then it asks for the next list. How would I fix this to allow me to enter more than two values?
Also, If the second list is different it has me enter more values that list one.
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// Enter values for list1
System.out.print("Enter list1: ");
int size1 = input.nextInt();
int[] list1 = new int[size1];
for (int i = 0; i < list1.length; i++)
list1[i] = input.nextInt();
// Enter values for list2
System.out.print("Enter list 2: ");
[code]...
My output looks like this:
Enter list1: 1
2
Enter list 2: 2
3
2
Two lists are not identical
View Replies
View Related
Aug 27, 2014
I have a student class with fields names and Gender. Now, I have a students' array. such that I can create multiple students' classes: student a, student b, student c e.t.c and store them into the students' array. Now, I store this students' array in a JComboBox and want to only display the names of these students in the array. Such that the JComboBox lists only the names of student a, student b and student c. . When a user clicks on a selected Item on the JComboBox, even though, it was a student's name that was selected, I want the selectedItem to be a object of the Student class. This, I have learnt works with JList by writing your own custom JList models and then DefaultListCellRenderer. Is there anyway, one could also do this with JComboBox?
//Main Method
import StudentList;
import Student;
import ViewGui;
import Controller;
public class SwingMainMethod {
[code]....
View Replies
View Related
Nov 15, 2014
Java Code:
createConnection();
try{
String str = "select * from Stocks";
stmt = conn.prepareStatement(str);
ResultSet rs = stmt.executeQuery();
while(rs.next())
jcbStock.addItem(rs.getString("stockID"));
}catch(Exception e){
e.printStackTrace();
} mh_sh_highlight_all('java');
I want to put this code in a class then call it in another class , but i do not how to do that. This code is working fine in my main class , but i want to write this code to another class for call it in main class.
View Replies
View Related
Sep 7, 2014
I am developing an application using Java Swing on Netbeans using Java DB, In which i want to create a form using Jtextfields & JComboBox.
I already added data in the JcomboBox to select. I already create a database and table for this application. Now i want to insert the data in Jtextfield and selection of Jcombobox to insert into the table i designed for it. How to link the form with the table and insert the data of form in table...
View Replies
View Related
Dec 3, 2014
If this is the C Programming codes for disabling the USB port:
system("reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetSer vicesUSBSTOR /v Start /t REG_DWORD /d 4 /f");
How can I use the codes below in Java using Netbeans?
View Replies
View Related
Mar 9, 2015
Create a Java Application in NetBeans with the following two classes.
1. A Java class College
o Use the following data fields:
College Name
College City
Number of Tracks
Number of Students
Number of Faculty
Number of Staff
o Implement an empty constructor
o Implement a full constructor
o Implement Setters and Getters (Mutators and Accessors)
o Implement SetAll() method with all data members as parameters
2. Another Java class called CollegeDemo with the main() method:
o In the main():
o Read the values of the fields of 3 colleges from a text file and for
each create a College object.
Filename: colleges.txt
IT Dubai 7 200 50 20
ENG Abudhabi 4 400 60 20
SCIENCE Sharjah 3 300 40 20
First with empty constructor then uses setters.
Second with full constructor (no need to use setters).
Last one with empty constructor and SetAll() setter.
o Display the average number of students for all the 3 colleges.
o Change the value of ‘Number of Students’ in the SCIENCE College to
500, and display the average number of students again.
here my code :
public class Demo {
private String name ;
private String city;
private String cname ;
[code]....
View Replies
View Related
May 2, 2015
I would like a small box to be able to enter a contacts information and I started with building it thru netbeans. Now I am thinking I should start from scratch so I understand everything. What should I do? I am having trouble making the buttons at the bottom work. All I would like to be able to do is setFrameVisible(false); but I can't seem to be able to do that without loosing the whole project not just the frame I am working on.
The buttons I am referencing are the Cancel & Accept
public class pa4GUI extends javax.swing.JFrame
{
String ph;
String ln;
String fn;
String em;
String or;
[code]....
View Replies
View Related
Aug 1, 2014
I'm reasonably new to Java and NetBeans.
I'm developing an SE Java application which allows the user to view a database that I've created. I've done the data binding to a JTable but don't see any data. I've read the Derby/Java DB manual and it seems that I need to put data into this Embedded database (single table). All I want to know is how to put the data in - can I copy the files from '.netbeans-derby' folder or do I have to utilise another method?
View Replies
View Related
Mar 3, 2014
I would like to use java se api names like, undo, redo, stylededitorkit, htmleditorkit in editorpane swing. So, I don't understand how to use these apis.
View Replies
View Related
Jun 22, 2014
The naming conventions for coding Java applications are clear to me. I'm wondering what the best practices are for naming Java projects e.g. when creating a new project in NetBeans IDE or in BitBucket?
View Replies
View Related
May 10, 2014
I am suppose to submit my project as a WAR file but not sure how to do it.
View Replies
View Related
May 12, 2015
I have a couple .java examples I want to mess with but don't know how to get them into Netbeans so I can work with them. What is the process in loading a .java into Netbeans so I can work with the code and run it in Netbeans?
View Replies
View Related
Sep 10, 2014
I am developing a program in netbeans forms. I've got to a point where I will click a jButton to print the content of either JFrame or JPanel. I am using Netbeans forms to develop the project....
View Replies
View Related
Jun 15, 2014
I need to copy my neatbean code to word, (school stuff) now I know this is possible, cause I see it on internet often.
I tryed copying it to notepad++ and then to word... wont work the code will still all black.
View Replies
View Related
Jan 26, 2014
how to send emotions in a chat application built in java using netbeans ?
View Replies
View Related
Feb 26, 2015
try {
File configFile= new File("C: Documents and SettingsstudentMy DocumentsNetBeansProjectsCDASsrcconfig.xml ");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fXmlFile);
doc.getDocumentElement().normalize();
NodeList nList = doc.getElementsByTagName("config");
[Code] .....
This code is working properly but i have use path like this
File configFile= new File("srcconfig.xml");
Instead of system directory path i have to use path inside of project but i am getting an error-cannot find the specified file...
View Replies
View Related
Aug 6, 2014
public void myFunc(MyNode n, ArrayList<MyNode> path) {
boolean hasChildren = false;
path.add(n);
int index = path.indexOf(n);
ArrayList<MyNode> statefulPath = new ArrayList<MyNode>();
[Code] ....
I have similar code that I stepped through in a debugger. After running the code I found that it built the desired tree, in this case a root node H with left child L and right child P. I want list of lists to contain all paths from root to leaf. I expected [H, L] and [H, P]. I discovered that statefulPath is not stateful; after a recursive stack frame pops, statefulPath still contains n! But that stack frame just popped! I expected to see statefulPath be [H] in the debugger and it was [H, L]! So I later have a list [H,L,P] which I don't want. How do I make the statefulPath list I want for my algorithm?
View Replies
View Related
Mar 25, 2015
List list1 = query1.list();
List list2 = query2.list();
for (Iterator itr = list1.iterator(); itr.hasNext();) {
Object[] row = (Object[]) itr.next();
}
View Replies
View Related
Apr 27, 2014
Write a Java function Sum2List that takes two lists L1 and L2 of the same size and returns list L that contains the sum of data inside the corresponding nodes of lists L1 and L2.
ex: L1 = {1,2,3}
L2 = {4,5,6}
L = {5,7,9}
I do not know how to iterate through two different lists >>
public LinkedList Sum2List(LinkedList l1, LinkedList l2){
LinkedList l3 = new LinkedList();
ListNode Current1 = L1.getFront();
ListNode Current2 = L2.getFront();
while(Current1 != null){
l3.Add(Current1.getItem() + Current2.getItem());
[Code] .....
This my attempt to write the code , but the dr. side that we have not to use the build in methods ( getNext()...etc)
in the function .
View Replies
View Related
Jun 1, 2014
I have big problem with mergesort in Java. I can't figure out why it do not works. I need write it on lists using Comparable. Here is piece of code:
Java Code:
class MergeSort{
Comparator _comparator;
List lista = new ArrayList<>();
List list_temp = new ArrayList<>();
MergeSort(Comparator comparator){
[Code] ....
I have tried everything, still no results. It's return list with random placed numbers.
View Replies
View Related
Mar 10, 2014
I have an XML sheet and my project is top retrieve the required elements from XML sheet. So my format of XML was like follows:
<Class>
<Employees>
<EMPLOYEE>
<ENum> Abc123</ENum>
<Ename> John<?Ename>
<EType>Mathematics</EType>
[Code] ....
I have used unmarshalling concept to retrieve the data elements... I have to check whether the elements satisfy few regulations when compared with data in Database. So, i thought of grouping the employees depending on EType. I have created a Map with linkedlist of employees. Say Map<String, LinkedList<Employe>>EmpMap=new Map<String, LinkedList<Employe>>();
I have already created a class named Employee which has all the setter and getter methods for employee.
Here am going to take Etype(Employee type) as key and linkedlist(list of employees of certain type) as value. How to iterate these linked lists and place them in my Map.
View Replies
View Related
Dec 6, 2014
What is going on here in the main class is a zoo that requires information to be read from and saved to a .txt file. I have made three arrayLists for each .txt file, I am getting errors for illegal start to an expression
import java.io.*;
import java.util.*;
public class ColumbusZoo
{
public static void addHelper(ArrayList<DomesticAnimal> a){
Scanner s = new Scanner(System.in);
System.out.println("What species");
[code].....
View Replies
View Related
Apr 1, 2014
I am working on a assignment that has to do with array lists, it mainly has to do with adding new elements, telling then where it is it located, if the memory block is empty , ect. so far i have been having problems with my indexOf method which should display the array cell number that a input element E is in, and if it is not in there it should display a -1.
public class MyArrayList<E>
{
private E[] data_store = (E[])new Object[2];
private int sizeofa = 0;
private void resize()// makes the array list bigger if need {
E[] bigspacemaker = (E[])new Object[data_store.length * 2];
for(int x = 0 ; x< sizeofa ; x++)
[Code] ....
Error message:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 512
at MyArrayList.indexOf(MyArrayList.java:28)
at MyArrayListDemo1.main(MyArrayListDemo1.java:26)
View Replies
View Related