Illegal State Exception Thrown From RequestFocus In JavaFX

May 2, 2015

I am attempting to create a very simple game where two squares move around and each can see the other square moving. This is a multi-player game over a TCP network using JavaFX. I am getting an illegal state exception when I call requestFocus(). This is my server:

public class GameServer extends Application {
ObjectOutputStream p1out;
ObjectOutputStream p2out;
int PLAYER1 = 1;
int PLAYER2 = 2;

[Code] .....

View Replies


ADVERTISEMENT

Thread Java - Illegal State Monitor Exception

May 30, 2014

Class A{
Public static synchronized void main(String args[]){
Thread t= new thread();
t.start();
Sysout("hi");
t.wait(1000);
Sysout("hello");
}}

Illegal state monitor exception. Why?

View Replies View Related

Custom Jtable Cell Editor Throwing Illegal Component State Exception

Jul 10, 2014

I've come across an interesting problem when using a Jcombobox as a custom cell editor(and renderer) in a jtable. I was hoping to add a keybinding in order to display the dropdown of the combobox instead of having to click on it however, when I make a call to showPopup() I get:

Exception in thread "AWT-EventQueue-0" java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location Which is strange as my jtable is visible and the editor/renderer seems to be working fine.

Here's the cell editor + renderer I'm using:

class MyComboBoxRenderer extends JComboBox implements TableCellRenderer {
public MyComboBoxRenderer(String[] items) {
super(items);
} public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
if (isSelected) {
setForeground(table.getSelectionForeground());

[code]....

View Replies View Related

JSP :: Navigating When Exception Is Thrown

Oct 10, 2014

need to navigate/render a jsp when a custom exception is thrown from a code block in my app.for that in web.xml I have configured the error handling

<error-page>
<exception-type>com.exampl.RecordNotFoundException</exception-type>
<location>/WEB-INF/errorpages/recordnotfound.jsp</location>
</error-page>

Code block

@RequestMapping(value = "/record", method = RequestMethod.GET)
public ModelAndView getPages() throws RecordNotFoundException{

throw new RecordNotFoundException("E888", "This is custom message X");
}

My questions are:

Is this the correct way to invoke a jsp when my code throws an exception?Do I need a try catch block to handle the thrown RecordNot Found Exception, if yes how would I navigate to the jsp from the catch block?

View Replies View Related

Socket Closed Exception Being Thrown

Feb 10, 2014

I have been working with socket programming. I was trying to develop a two way communication from server to client. The data is being received when sent from server to client but there is a problem when I am sending from client to server.

I am getting an error as "Socket is closed" pointing to the line where I have created a BufferedReader. I have simplified some part of my code to be very specific.

Code attached.

import java.io.*;
import java.net.*;
import java.util.*;
public class Server
{
public static void main(String args[])
{
String id="policeone";
int hashcodeid=0;

[Code] ....

Error::

Receiving string from client: 'java.net.SocketException: Socket is closed
at java.net.Socket.getInputStream(Socket.java:872)
at Server.main(Server.java:51)

View Replies View Related

Why Is Exception Not Thrown When Connection Is Terminated

Jul 27, 2014

Below is a code of a simple file downloader in java. I want to detect an exception when the connection is broken in the middle of downloading a file. Now, I run the code and in the middle of downloading the file, i turn off my wifi with keyboard wifi off button. Doing this the program hangs forever without throwing any exceptions and without terminating. It seems it blocks forever.why is exception not thrown? Secondly, in the following code you can see this line //con.setReadTimeout(2000); which is currently commented out. Removing the comment and running the program, now if connection breaks in the middle by turning off wifi then it waits for 2 seconds and then if it cannot read then it terminates without throwing exception. So, again in this case why is it just terminating and not throwing any exception?

Java Code:

import java.io.FileOutputStream;
import java.net.URL;
import java.net.URLConnection;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.*;

[code]...

View Replies View Related

Unreported Exception - Must Be Caught Or Declared To Be Thrown

Oct 4, 2014

I am getting the above error and am not sure which direction to proceed. In the class, the only way we have discussed getting user input is by System.in.read. I have searched and apparently found better methods for getting user input, but wanted to stick with what has been presented thus far.

Assignment Directions:

1. Create a new class named “valuemethod”

2. Create a new method named “Main”

3. In Main Write the code that will call the method EnterPay and YearlySal

4. Create a new method named “EnterPay”

5. In the EnterPay method Write the code that asks the user to input their hourly wage. Use the formula to calculate their yearly salary: wage * 2040. Return the yearly salary to the main method

6. In the main method write the code that will display this: “Your yearly salary is:

Java Code:

package valuemethod;
public class Valuemethod
{
public static void main(String[] args)
//throws java.io.IOException -- moved to EnterPay

[Code] .....

View Replies View Related

Servlets :: Filter Behavior When Exception Is Thrown

Apr 21, 2014

I just wanna confirm that when a certain processing throws an exception even when said exception happens inside doFilter, any servlet container will never proceed to the next filter right?

View Replies View Related

Null Is Easily Printed As Value Of Variable Without Exception Being Thrown

May 27, 2014

Sometimes a nullpointerexception is thrown, in some cases null is easily printed as a value of a variable without an exception being thrown.

View Replies View Related

Stale Object State Exception

Aug 17, 2014

Caused by: javax.persistence.NonUniqueResultException: result returns more than one elements
at org.hibernate.ejb.QueryImpl.getSingleResult(QueryI mpl.java:109)

What are the common reasons for the above exception and the suitable fixes?

View Replies View Related

Exception Thrown If User Enters Negative Number - Program Gets Suspended

Oct 19, 2014

In my cs class, we have to write a program that throws an exception if the user enters a negative number, the program should prompt the user to enter only positive numbers and then let them retype the number. But everytime I throw an exception, my program gets suspended.

What am I doing wrong, or is there no way to continue a program if an exception is thrown? Does the program automatically get suspended when an exception is thrown?

try{
do
{
N = kb.nextDouble();
if(N<0) {
throw new NegativeArraySizeException();
}
else
j++;
}
while(j==0);
fill.size(N);
}
catch(NegativeArraySizeException e) {
System.out.println("The number you entered must be positive. Please try again.");
}

View Replies View Related

How To Change State Of Object - Main Method Exception Error

Jan 8, 2015

The error I get when I execute my java file.

Exception in thread "main" java.lang.NullPointerExceptionat DogTestDrive.main(DogTestDrive.java:19)

Here is the source

class Dog {
int size;
String name;
void bark () {
if (size < 60) {
System.out.println("Woof woof");

[code]....

Some background: I'm reading "Head first Java 2nd edition" and I'm going through the examples which is showing me how to change the state of an object. The original code looks like the code below, however the previous chapter went over creating array's of an object, so I created an array of the object "Dog" and wanted to re-write it this way. To my understanding, it should work but it's giving me that error when I execute it. The error itself isn't very clear, if I could get a line number pointed to, that would work.

class Dog {
int size;
String name;
void bark() {
if (size > 60) {
System.out.println(“Wooof! Wooof!”);
} else if (size > 14) {
System.out.println(“Ruff! Ruff!”);
} else {
System.out.println(“Yip! Yip!”);

[code]....

View Replies View Related

Enum Class Throwing Illegal Argument Exception?

Mar 4, 2015

I have a enum class which contains some string which i am comparing to a string i get from a user

Java Code:

public enum Compare {
a, b, c, d, e, f
} class SomeClass {
String method(String letter){
Compare word= Compare.valueOf(letter);
}
} mh_sh_highlight_all('java');

Everything works fine but when I added a new word to it like "g" it throws the IllegalArgumentException ?

View Replies View Related

JavaFX 2.0 :: Stage From Iconified State To Regular Size Via Shortcut

Jan 23, 2015

I would like to ask you about possibility to restore javafx 8 app from iconified mode (setIconified(true)) to regular size via shorcut for example: Ctrl + Shift + Ins I use Windows 7 and jdk 1.8.0_40 beta.

View Replies View Related

JavaFX 2.0 :: Security Exception When Executed Over Web

Oct 6, 2014

I have an FX application which invokes a REST JSON webservice. It works perfect if I run it standalone. But if I try to run it over browser, it throws java security exception.

It also works fine in web if I comment some lines that invokes the webservice (code that calls the webservice using jackson.)

Java version used is JDK 1.7u67
IE plugin version  : 7.0.670.1
 
Error log :
java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessDeclaredMembers")
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)

[Code] .....
 
Jnlp File:
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0" xmlns:jfx="http://javafx.com" href="uibuilder.jnlp">
  <information>
    <title>UI Builder</title>
    <vendor>javafx.com</vendor>
    <description>XEye UI Builder</description>
 
[Code] ....

View Replies View Related

Compute Standard Deviation For A Set Of Numbers - ClassCastException Being Thrown?

Apr 20, 2015

Basically I'm trying to compute the standard deviation for a set of numbers and I'm using previously know data to compute this. The data I'm working with is here (note all of this is fake as its for an assignment):

Id,First Name,Last Name,Quiz1,Quiz2,Quiz3,Lab1,Lab2,Assignment1,Exam1,Exam2
58136,Wade,Andrews,5,8,2,2,20,47,20,40
59759,Jacqueline,Simmons,9,4,1,16,13,2,82,41
28056,Frederick,Castro,8,0,6,3,6,29,53,63
15532,Annette,Myers,2,6,0,14,13,4,77,43

Next this is the code that I know is producing the error:

/**
* Pass in original data from files, and pass in computed grades as arraylist. this returns all of the standard deviations to be printed
*/
public static ArrayList calcStandDev(String data1[], ArrayList<Double> grades, ArrayList<Integer> averages)
{
double standDev = 0;
int j = 0;
//gets rid of first element in string array, makes processing MUCH easier
String[] data = Arrays.copyOfRange(data1, 1, data1.length);
 
[Code] ....

Look for the line with all the ***'s, it is producing the "java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer".

The reason I dont undersand why its producing this error is because temp.get(i) should be a integer - averages.get(i) (is type double), I do believe automatic up casting is present here making them both a double then I multiply it by itself producing a double? I dont understand where the casing is occurring. And just incase you want the formula I'm using for standard deviation here it is:

((x1 - ave)^2 + (x2 - ave) ^2 + (xn - ave) ^ 2) / (n-1)

then squareroot above

Why I'm getting this error! I tried changing a few dataTypes but I just cant avoid exceptions being thrown everywhere .

View Replies View Related

Display Result Of Two Dice Thrown Five Times And Total Of Those Results

Sep 12, 2014

I need to create a simply application that would display the results of two dice thrown five times and the total of those results. This is shown below in the attached file.

The problem is, I have a do-while loop that loops 6 times. Inside the loop, I have 2 random.nextInt(5) that generate random numbers. But how can I output the total? How can I make a variable equal to the sum of the two random numbers if the two random numbers are located inside a do-while loop?

Attached below is also the code I have thus far.

(Attached below is both files: what it needs to look like, and what it currently looks like)

View Replies View Related

Store A State Of A Project

Sep 23, 2014

Hello World program. We had to build it. Write a basic Java program that will implement one class to store a state of a project. The class should have one property to store a textual name of the state. When a object of this class is created the initial state should be "Open".

1) Class should have one method next() which will move the project to the next step in the sequence: Open - In progress - Closed.If next method is called for a project in the Closed state it should do nothing.

2) Class should have a method close() which will move the project into the Closed state.

3) Class should have a method print() that will output a current state of the project.

Submit a java code file as your assignment. Do not hesitate to contact me if you have any troubles with the assignment.

I have been working on this thing for almost a week, and really don't have a clue on what to do. I know I have to use a string = open, and I know I have to create an object. I don't have a clue on how to do this. I have read the chapter so many times, I almost memorized it, but what he wants is nothing like our demo in the book. the Book used set and get, and utility scanner, but he doesn't want any of that. Just a basic code that will move from Open --- in progress --- closed.

The best I can tell what he wants is when I set the object to open it will display " project is open", then when I set it to " in progress" it will read project is "in progress". I don't have a clue what close is suppose to do, or the print method.

View Replies View Related

State Machine Compiler

Oct 19, 2014

I am working in software testing, specifically automatic test cases generation. Among the existing forms of test cases, my focus is on the test cases that are composed of sequences of events such as _.event1.event2 eventx()

However, the events can be classified into: sensitive and insensitive. The latter does not affect the system's states, and hence, it can be ignored; while the former affects the states. Anyhow, the sensitive events in the test cases may lead to states explosion and there is a need to prevent that. Therefore, some techniques suggest using one variable to present states and group all similar states together such as using len variable in circular queue. Relatively, the states can be represented by using specific drawings such FSM.

For example, the test cases for circular queue may look like:

add(0).remove().add(1).Front()
add(0).add(1).remove().Front()

which produce the following states:

len=1, rear=0, front=0 and dataQ[0]=0
len=0, rear=0, front=1 and dataQ={0}
len=1, rear=1, front=1 and dataQ[1]=1

len=1, rear=0, front=0 and dataQ[0]=0
len=2, rear=1, front=0 and dataQ[1]=1
len=1, rear=1, front=1 and dataQ={1,0}

As can be seen, every addition/deletion produces a new state. A state is composed of 4 variables: len, rear, front and dataQ. The 1st three variables are integers while the dataQ is an integer array. Nonetheless, the states produced by different test cases can be identical which wastes effort and time. So, there is a need to optimize these states. The search techniques were suggested where the problem can be represented as a search problem and the technique is applied. If we consider Len as a state, then we will have: len=0; 0QSize. However, this does not represent the state but it suits for classifying the states into groups.

In terms of states representation, State Machine/Map Compiler (SMC) was suggested as a modeling mechanism that takes the state machines (i.e. FSM) drawing and generates the code in any preferred language. In SMC, the FSM is represented in a specific syntax (state---transition----next state) and saved in a file (.sm). This file will be compiled by SMC to generate a context class which includes definitions of states, transitions and actions in FSM but still need to be triggered by another class. This class has to call the transitions that modifies the state.

We had created that class and implemented all the methods with their transitions. However, the FSM used was based on 1 variable only (i.e. len). Besides, we are still looking for the SMC results as they will be the input for any search technique to be applied. Supposedly, the states generated by SMC can be used directly in the search technique but this is still questionable.

View Replies View Related

JSF :: Server-side State Saving

Nov 25, 2014

in my web.xml the.STATE_SAVING_METHOD setting is server

<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>

for measurement of application security isn't not allow to change this parameter to client , so the problem when I access for application and I open a new page via linker for print for example and I would access for my initial page to make change or modify my initial page it s no possible to make any modification because I have a empty bean , but if the state saving is a client I haven't a problem because a tree map is stored in client browser, so my version of JSF is 1.1.1 ,

View Replies View Related

How To Set State Of Radio Button Based On Configuration File

Apr 10, 2014

I am using Java Swing to create a GUI. I have some radio buttons on a JFrame that gets opened when the user makes a certain selection. I want to read a config file to have the radio buttons selected or deselected when the form is opened to indicate the current state of the radio button based on the saved config file.

How do I go about setting the radio button as selected (visibly selected) when I open up the JFrame?

I was trying to use RadioButton.setSelected(True); but this doesn't actually visibly select the radio button.

View Replies View Related

How Does Threads Come Back To Ready State After Executing The Task

Mar 21, 2014

When a thread completes its execution, it will be destroyed.In Java thread pool implemenation, how does threads come back to ready state after executing the task.?

View Replies View Related

Extracting Kerala State Vehicle Number Plate From Image

Mar 25, 2015

code for extracting kerala state vehicle number plate from an image

View Replies View Related

Allow User To Change And View State Of Credit Card With Menu Driven Program

Apr 20, 2015

I am new to OOP, i am not sure if this is the correct approach or not. Write a class named CreditCard that has (at least) the following member variables:

- name. A String that holds the card holder's name.
- cardNumber. A field that holds the credit card number.
- balance. A double that stores the current credit card balance.
- spendingLimit. A double that stores the spending limit of the card holder.
- Bonus: additional fields that you can think of.

In addition, the class should have the following member functions:

- Constructor. The constructor should accept the card holder's name and card number and assign these values to the object's corresponding member variables. The constructor should initialize the spending limit to $2,000 and the balance to $0.
- Accessors. Appropriate accessor functions should be created to allow values to be retrieved from an object's member variables.
- purchase. This function should add the amount specified as a parameter to the balance member variable each time it is called.
- increaseSpendingLimit. This function should add 500 to the spendingLimit member variable each time it is called.
- payBill. This function should reset the balance to 0.
- Input validation: Whenever a credit card number is modified, verify that it is of reasonable length.

Demonstrate the class in a program that creates a CreditCard object and allows the user to change and view the state of the credit card with a menu driven program.

View Card Information.

- Purchase an Item: ask the user the purchase amount and increase the card balance accordingly.
- Pay Bill: call payBill method to set the balance to 0.
- Increase Spending Limit: ask the user how much the spending limit should be, and call the increaseSpendingLimit function the appropriate number of times.

[CODE]

import java.io.*;
import java.util.Scanner;
public class CreditCard
{
Scanner input = new Scanner(System.in);
//data members
private String holderName;
private int cardNumber;
private int accountBalance;
private double spendingLimit;

[Code] ....

View Replies View Related

Illegal Start Of Expression?

May 4, 2015

package com.example;
import com.example.domain.Admin;
import com.example.domain.Director;

[Code]....

View Replies View Related

Illegal Start Of Expression

Jul 30, 2014

How that's possible

import java.util.*;
public class Stars {
public static void main(String[] args) {

line (13);
line (7);
line (35);

System.out.println();
box(10,3);

[Code] ....

View Replies View Related







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