Applets :: 2 Jlists / Second One Depends On Selection In First One?

Jun 2, 2014

So I have an applet and in the first ScrollPane you have a number of options of businesses

The Centre

IMAX

etc ..

and when you click one , the other scrollpane shows office

so when i choose "The Centre" for example , in the right scrollpane it shows : "Head Str." "Downtown" etc

i can fill in the first scrollpane with:

void myInit() {
DefaultListModel model = (DefaultListModel)businessList.getModel();
model.removeAllElements();
try {
ArrayList<Business> bussinesses = contr.getBusiness();

[code]....

but this gives me a NullPointerException on

ArrayList<Office> offices= business.getOffices(name);

which i don't understand, since business isn't null .. it's the selected value.

View Replies


ADVERTISEMENT

Swing/AWT/SWT :: JLists Are Not Appearing In JPanel

Apr 12, 2015

I need to add 2 JLists inside a JPanel for a crossword. The JPanel is located SOUTH and I'm using BorderLayout in the constructor to locate the JPanel.

The problem is, I can't see the 2 JLists inside the JPanel. For some strange reason the JLists appear in the center where the crosswordPanel is, even though the clues JPanel method is located SOUTH.

package crossword;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;

[code]....

View Replies View Related

Use If / Else Statement That Depends On Which Of 2 ArrayLists Contain Object

Sep 9, 2014

I have two arraylists. One is personalContactList. The other is businessContactList.

1. I want to take user input that references an object attribute (int),
2. Use it to determine which object is referenced,
3. Find the "type" attribute of that object,
4. Determine which arraylist the object belongs to, based on that type,
5. Use the if else/statement to print out some attributes that depends on which arraylist the object is in.

I believe the code successfully does 1-3, and probably 4. But there is a hangup on 5. I get an indexoutofbounds execption. Which I'm not sure I understand very well.

Here is the code--it's part of a switch statement:

case "c": {
//some code here prints out a list
boolean b = false;
int g; 
while (b == false) {
  Scanner detailScanner = new Scanner(System.in);
System.out.print("Enter a number to see details: ");
 
[Code] ....

View Replies View Related

Jtable Cell With Search Depends On Value Entered?

May 31, 2014

I am trying to do the fallowing ,

Jtable cell with search (% like) depends on the value entered

if i enter "mi" it should show all data begin with "mi" from my data set

View Replies View Related

Applets :: SecurityException When Using Applets

Dec 26, 2013

I am new to applets, and my manifest file is:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.3
Permissions: all-permissions
Created-By: 1.6.0-internal (Sun Microsystems Inc.)

Name: com/myPackage/test/client/TaskApplet.class
SHA1-Digest: pLmraui35IkgfAq+v3WGj1LwCYQ=

The error I get is as follows...When the page is loaded I get the following error: java.lang.SecurityException: class "com.myPackage. test.client. TaskApplet" does not match trust level of other classes in the same package

View Replies View Related

Recursive Selection Sort

Oct 21, 2014

How would I modify this version of a selection sort into a recursive method?

public static void selectionSortRecursive(Comparable [] list, int n)
{
int min;
Comparable temp;

[code]....

View Replies View Related

Using Multiple Selection Choices?

May 28, 2014

This program allows the user to select one of each different type of skateboard/accessories items. Then it allows the user to select as many misc items as he or she chooses. The program works fine for the single choices, but I cannot solve the latter part. I have a get method in the misc class that is trying to pull out any selection or selections that were made by the user, but it simply does nothing...

Here's my program, I have four panel classes for each skateboard type, and then I have one class that takes care of adding each panel to the content pane, and calculating the total cost of the item.

Decks Panel Class:

import java.awt.event.*;
import javax.swing.*;
// The DecksPanel class allows the user to selects a specific type of skateboard
public class DecksPanel extends JPanel

[Code]....

View Replies View Related

Selection Sort Method?

Mar 5, 2014

I'm trying to make a selection sort method that will sort a list of Strings alphabetically.

I have a test list of Strings like so:

Joe, Steve, Oscar, Drew, Evan, Brian, Ryan, Adam, Zachary, Jane, Doe, Susan, Fred, Billy-Bob, Cindy, Mildred, Joseph, Hammer, Hank, Dennis, Barbara

However, whenever I run the method, the element that should go last, Zachary, in this case, ends up getting moved to the front for some reason. I'm not sure why.

I tried changing what the first element was initialized to, to the variable i as that would logically work as well, but it ends up missing the first element in the list.

Java Code:

public static void selectionStringAscendingSort (String[] words){
int i, j, first;
String temp;
for ( i = 1; i < words.length; i++ ) {
first = 0; //initialize to subscript of first element
for(j = i; j < words.length; j ++){ //locate smallest element between positions 1 and i.
if( words[ j ].compareTo(words[ first ]) <0 )
first = j;
}
temp = words[ first ]; //swap smallest found with element in position i.
words[ first ] = words[ i ];
words[ i ] = temp;
System.out.println(Arrays.toString(words));
}
System.out.println(Arrays.toString(words));
} mh_sh_highlight_all('java');

View Replies View Related

Selection Does Not Contain A Main Type

Mar 23, 2014

I'm trying to run a simple code which is to just print out "Hello World", but whenever I run it, a message appears that reads: "Select a way to run Project_1(Which is the Java Project)"

The selections for it are: Java Applet and Java Application.Whenever I click Java Applet it reads: Selection does not contain an applet.When I click Java Application: Selection does not contain a main type.Here is the code which I believe is correct:

package packag_1;
public class Num_1 {
public static void main(String args){
System.out.println("Hello World");
}
}

View Replies View Related

Design Pattern Selection

Mar 27, 2015

I need selecting which design pattern to use in my case.

I am creating a list of objects "items" to be presented in a list for the user to choose from, all objects have a title and a check box. Some objects have additional textbox for user input, some objects have additional image for illustration, and some objects have additional textbox and image as well.

I read and saw online videos but not sure if my selection "Factory Design Pattern" is the best match.

View Replies View Related

Graphically Displaying Selection Sort

May 20, 2014

I am trying to write a program that graphically displays a selection sort. It needs to sort bars of various heights, and the bars heights are generated from an array of random integers. The program needs to show the bars swapping as they are being sorted, I am having trouble getting the bars to draw, it needs to look like a bar graph. Here is my code thus far (not counting my boiler plate):

import java.util.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.Timer;
import java.awt.*;
import java.util.Random;
public class SelectionSortPanel extends JPanel

[Code] ....

Also right now it is giving an error from the compareTo method?

View Replies View Related

How To Do Selection Sort Of ArrayList By Customer Last Name

Nov 8, 2014

I have an arrayList with these values:

Mike Smith with a customer id of 100 has an account number of 1000 and a balance of $5,000.00
Hank Jones with a customer id of 101 has an account number of 1001 and a balance of $45,000.00
Sam Overstreet with a customer id of 102 has an account number of 1002 and a balance of $45,000.00
Hank Jones with a customer id of 101 has an account number of 1003 and a balance of $48,000.00
and so on .....

I am trying to do a selection sort by the account holders last name. I understand how to do if the Arraylist holds integers, but my arraylist holds multiple fields. I am not allowed to use collections as this is a homework assignment.

here is the Account Class

public class Account implements Comparable<Account> {
private int acctNum;
private double balance;
private Customer cust; // note we are putting a Customer object in the Account clas
private static int nextAcct = 1000;// used to keep track of the next available account number

[Code] ....

View Replies View Related

Graphic Array Selection Sort?

May 21, 2014

This is a lab for one of my CS classes, and the assignment is to create a randomly filled array (values 10-100) and use these values as the height of an array of rectangles (essentially a bar graph)that will be drawn on a page. After that's done, the code should use the selection sort method to sort the bars least to greatest, being repainted as it's sorted.

I'm receiving no errors, the original draws just fine, and the code sorts the first position and then...it just hangs. Like it's in an infinite loop but I have all of the modifiers in place (I think. I've been staring at this code for three days straight and I don't think I really see it anymore). I've tried talking to my professor and I get that her private life is really busy right now, but she just keeps blowing me off and I don't know what to do. Anyway, done with back story and whining so here's the code.

Rectangle class:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Rectangle

[code]....

View Replies View Related

Text Adventure - Cannot Use Menu Selection

Apr 30, 2015

I cannot use menu selection 4 5 6 7 8 9 10 ... Why NO_EXIT has been declared and used in defining the contents of the map array, rather than just directly using the value 99999 in the map array definition

I don't understand map[][], objectName[] and objectLocation[]

package Assignment;
import java.util.Scanner;
public class GameWorld
{
// the map array holds details on which paths lead to which other rooms. NO_EXIT indicates no valid exit.
// each element holds the details of all paths leading out from a single-room in the order n ,e, s, w, ne, se, sw, nw
private final int NO_EXIT = 99999; // indicates that there is no exit in that direction
private int map[][] ={{NO_EXIT,NO_EXIT,NO_EXIT,1},{2,0,NO_EXIT,NO_EXIT},{NO_EXIT,3,1,NO_EXIT},{NO_EXIT,NO_EXIT,NO_EXIT,2}};

[Code] .....

View Replies View Related

Used Selection Sort Method On Array

Nov 11, 2014

I have a question about selection sort. If I had an array of numbers, 1 2 3 4 100 0, and used the selection sort method (below) on the array,would the 0 slowly work it's way down to the end?

Nest loop = full rotation of nest loop

Nest loop 1: 1 2 3 4 100 0
Nest loop 2: 1 2 3 4 100 0
Nest loop 3: 1 2 3 4 100 0
Nest loop 4: 1 2 3 4 100 0
Nest loop 5: 1 2 3 4 0 100
Nest loop 6: 1 2 3 0 4 100
etc.

METHOD:

static void selectionSort(int[] arr){
int n = arr.length;
for(int i = 0;i<n;i++){
int min = i;
for(int j = i+1;j<n;j++){
if(arr[j]<arr[min]){
min = j;
}
}
int temp = arr[i];
arr[i] = arr[min];
arr[min] = temp;
}
}

View Replies View Related

How To Make Green Selection Box To Move Around

Feb 16, 2014

I'm making a simple game where there's a 10x10 grid and you can move around a selection box and you can move around. I've been trying to make the green selection box to move around but it won't move! I only have right movement in the code but it won't work so far. Here are the classes that have to do greatly with each other.

import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.image.BufferStrategy;
import java.util.Random;
 
public class Game extends Canvas implements Runnable{
private static final long serialVersionUID = 1L;
 
[Code] ....

I also tried an approach where you click with the move and it snaps to a tile grid but that didn't work either.

View Replies View Related

JavaFX 2.0 :: Turn Off ListView Selection

Jul 21, 2014

I have a ListView with ListCells that are complicated things containing other nodes. I want to turn of ListView selection behavior (so not allow selections) without turning of events to the ListCell nodes in the ListView.

View Replies View Related

JavaFX 2.0 :: How To Inhibit Changing Selection

May 25, 2014

I have a Master/Detail application with a TreeView as Master Selection. I need to inhibit leaving a page if the contents are "invalid". How can I do that?

I tried to force the page again in a ChangeListener, but that doesn't work well, not even using Platform.runlater().

What's the "Best Practice" in this case?

View Replies View Related

Applets :: Tic Tac Toe Does Not React

Sep 4, 2014

this is what I clobbered together for the O'Reilly Java 2 Course, final assignment. There may well be several issues still with this code, my main grief at the moment is: The mouseReleased does not react (it did in the assignment I lifted it from and made only minor changes). No matter where I click on the grid, nothing happens.

import java.awt.event.MouseAdapter;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.Container;

[code]....

View Replies View Related

Swing/AWT/SWT :: How To Access Elements Of TreeViewer Selection

Dec 27, 2014

I have a hierarchical data structure (Machine, Component, Measurement, Fault are classes) displayed in a TreeViewer. I have added SelectionChanged and DoubleClick listeners, but can't find a way to get to the data stored in the selected instance of the data structure class. For example, the selection is a Measurement which has a String name field. I can see the data in the Element in Debug-Variables, but I can't find any getters to access it. I tried casting the selection as a Measurement but it is an ISelection, or TreeSelection class and it won't accept the cast.

It seems there should be get methods to access the data in the selection, but there aren't, so I'm must be missing something fundamental.

View Replies View Related

JSF :: Selection Of 0 Index Of Dropdown Chrome Browser

Jul 17, 2014

I have a jsf form which has a drop down. When I select any value in drop down it shows related details. When I use chrome browser, and I press back space key it comes back to the page, it keeps the value selected which was selected earlier, but in the firefox, IE it keeps the zero index selected. The same code is not working for chrome browser.

I would like the zero index to be selected in the drop down in previous page in chrome browser also when back space key is pressed...

View Replies View Related

Roulette Wheel Selection In Genetic Algorithm

Feb 7, 2014

I want java coding for roulette wheel selection in genetic algorithm with some explanation. I can't understand the algorithm clearly to implement in my project ...

View Replies View Related

Selection Sort / Binary Search And Recursion

Nov 26, 2014

Here is the code I have at the moment:

/**
* Use selection sort to sort the tracks by name. Return a new, sorted ArrayList of tracks.
*
* @return an ArrayList containing the tracks sorted by name, or null if no tracks exist
*/
public ArrayList<Track> getTracksSortedByName() {
// YOUR CODE HERE
if(tracks == null)
return tracks;

[Code] ....

Here are my 2 issues (there are 2 lines with compiler errors): I feel like I understand selection sort and binary search, but am not sure how to apply it to the more abstract idea of a Track ArrayList (hence the 2 compiler errors). What should I use to make it work. Lastly, I'm very uncomfortable with recursion, so my guess is there is also probably some logical issue with it in the getTracksSortedByName method.

View Replies View Related

JSP :: How To Display Only Text File In Selection Window

Apr 7, 2014

I am trying to upload the text file in specific location in my disk but when I open selection window it displays all type of files while it should display the files only having .txt extensions

I am writing the code below,

<%@page import="org.apache.commons.fileupload.*,java.util.*,java.io.*"%>
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<%
// JSP to handle uploading
// Create a new file upload handler

[code]....

View Replies View Related

JSF :: Relational Database Working With Selection Dropdowns

Jun 23, 2014

I'm and having troubling figuring out how to work some JSF magic on a Relationship that I crated on my database. Here is what I have coded.

My stateless Bean

//..
public void setmoney(Money money)}
em.presist(money);
//..
}

My JSF bean process (moneyJSF.java)

//..
public void addMoney(){
money_bean.setMoney(money_entity);
//..
}

[Code] .....

NOTE: typeJSF in the HTML code just grabs the data from the database in the table called typesOf. Money and types have a many to one relationship.

When I submit the selections, I get the following error:

Conversion Error setting value 'com.serveftp.wigm.entities.Types[ typeOfID=1 ]' for 'null Converter'

I understand that I need to convert from a string object to a Types object using the types entity, however I am not sure where to start on this one.

View Replies View Related

Making Selection Sort Into A Recursive Method

Oct 21, 2014

How would I modify this version of a selection sort into a recursive method?

public static void selectionSortRecursive(Comparable [] list, int n)
{
int min;
Comparable temp;
for(int index =0; index < n-1; index++){
min = index;

[code]....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved