Losing Control Of The Console
Jun 14, 2014
I have a multithreaded java program. I have a few worker threads which process data over a udp server. Then I have another thread for console input. The problem is when there is an error with one of the worker threads, and it prints to the console, my console thread loses "focus", that is, the while loop seems to no longer run. Here is the console thread:
Java Code:
public void run() {
Console c = System.console();
if (c == null) {
Logger.writeError("No console.");
System.exit(1);
}
while(true){
String login = c.readLine(">>>: ");
System.out.println("You entered: " + login);
}
} mh_sh_highlight_all('java');
When an exception is raised, it prints it to the console, and suddenly the program no longer shows the >>> prompt from above.
View Replies
ADVERTISEMENT
Mar 30, 2014
I am trying Single signon to a different application from my application. i use redirect to open the new URL in a separate window. MY single signon works well. But i am losing the session values in my application.
Because of this when i close the new window and click on any link in my application, i am getting error sicne all application objects inside session are reset to null. how to retain the session values after Redirect.
View Replies
View Related
Jan 20, 2015
I've been using Java Advanced Imaging to convert tiff images to jpeg. The code I'm using is pretty simple, and I'll include it below:
Java Code: private static void convertImage(File tiff_src, File jpg_dest)
{
if (tiff_src == null || !tiff_src.exists()) throw new IllegalArgumentException();
try
{
SeekableStream stream = null;
[code]...
The problem when I run this code is that during conversion, the decoder or encoder seems to drop a good deal of black. I'd like to include examples, but the tiff images are about 30 MB...I've tried configuring the decode parameters, as well as the encode parameters, but like I said, somewhere during conversion I drop a good deal of the black from the image.
View Replies
View Related
Jun 20, 2014
A team of programmers is reviewing a proposed API for a new utility class. After some discussion, they realize that they can reduce the number of methods in the API without losing any functionality. If they implement the new design, which two OO principles will they be promoting?
A. Looser coupling
B. Tighter coupling
C. Lower cohesion
D. Higher cohesion
E. Weaker encapsulation
F. Stronger encapsulation
View Replies
View Related
Oct 31, 2014
I have a case where I have a TreeView and I use it to select items from the tree. After I select each item I then clear the TreeView selection. Then, when I select outside of the window, the setFocused is called which in turn selects item 0 from the tree. I see in the TreeView.java the code,
private InvalidationListener focusedListener = observable -> {
// RT-25679 - we select the first item in the control if there is no
// current selection or focus on any other cell
MultipleSelectionModel<TreeItem<T>> sm = getSelectionModel();
FocusModel<TreeItem<T>> fm = getFocusModel();
[Code] .....
Is there anyway to suppress this behavior?
View Replies
View Related
Oct 11, 2014
Is there a way you can control user input?
For example, is it possible to only allow the user to enter digits?
View Replies
View Related
Nov 18, 2014
how am i supposed to make line1B with "1f" and line2B with width of "10f"?
PHP Code:
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
[code]....
View Replies
View Related
Sep 2, 2014
So I'm working on some networking code and I have the Server running as its own thread, then I have a PacketListener which is contained in the Server, that is running on its own thread too. As of right now, the PacketListener waits for packets via DatagramSocket.receive() and then adds them to a queue. The Server runs in a loop and it checks that queue for packets and then polls the most recent and process it before sleeping for 1 millisecond. Here is my question though, I'm considering changing the program to a more observer pattern structure in that when the PacketListener would receive a packet, rather than add it to the queue, it'd notify the server which would process it. However, wouldn't this cause additional time required within the PacketListener thread dedicated to processing the packets rather than listening for them?
View Replies
View Related
Jul 24, 2014
I'd like to ask is there way to control the RMI lookup timeout through programming or network configurations.
In a testing environment, I have purposely disconnect or plug out the cable between two testing servers to check the reliability.
It took very long time for the RMI API to throw out java.rmi.ConnectException which used Naming.lookup(givenURL).
I have tried to set system properties like sun.rmi.transport.tcp.handshakeTimeout, but it didn't take effect at all.
View Replies
View Related
Apr 1, 2014
I'm a student designing and developing an Air Traffic Control (ATC) system for incoming aircraft, mainly implementing the part which handles the queuing system for approaching aircraft.
View Replies
View Related
Apr 4, 2014
I'm trying to implement a functionality which will control the visibility of three outputText. I'm using a selectOneMenu, which has three options. Each option will enable visibility of one outputText, and rest will be invisible.
I used the following code
<h:selectOneMenu id="search" styleClass="select-box" value="#{empMB.showHide}" required="true" requiredMessage="Please Select an Option" >
<f:selectItem itemLabel="-----Select----"/>
<f:selectItem itemLabel="By Name" itemValue="1"/>
[Code] ....
Initially all outputText s is invisible as rendered value is false, but when I select different options, their respective outputText s are not visible.
View Replies
View Related
Apr 23, 2014
Java code to build control flow graph of any user program in jframe...
View Replies
View Related
Feb 24, 2015
How to Write Program with out using control structures
IMG_4216.JPG
View Replies
View Related
Aug 18, 2014
I am having a problem with the SelectOneMenu control. I want the the selected item to be be displayed via the valueChange Ajax event listen. But this is not happening.
However, when I change the value in the SelectOneMenu and then click on the Submit button, then selected value is getting displayed via the 'save' bean function
The relevant xhtml code is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<style type="text/css">
[Code] .....
View Replies
View Related
Jul 22, 2014
I have developed JavaFx application with playback option using JavaFx Media player and slider controls. I am updating slider value using javafx mediaplayer.currentTime().addListener() method by adding Change/Invalidate listener.
While playing MP4 video, slider values are not updating (Change/Invalidate listener not getting triggered while playing video) on Mac OS(version : 10.9.1). Below is the sample code snippet.
mediaPlayer.currentTimeProperty().addListener(new InvalidationListener() {
@Override
public void invalidated(javafx.beans.Observable o) {
updateSliderValue();
}
});
View Replies
View Related
Dec 5, 2014
I am currently building a java music player and need getting the volume control to work. I want to be able to set the computers volume directly using an integer. I've created a slider and put the value into an integer. The part that I am having trouble with is getting the volume to work.
View Replies
View Related
Mar 11, 2014
I am writing a program where i am trying to control a rectangle and determine where it moves, everything is working fine it is moving but i am trying to figure out how to change direction using the "WASD" keys. This is what I have and I am not sure why its not working.
Java Code:
addKeyListener( new KeyAdapter() {
public void keyReleased(KeyEvent event) {
for (MoveableShape creature : creatures) {
if (((Creature)creature).isPlayer()) {
if (event.getKeyCode() == KeyEvent.VK_W) //up
[Code] ....
View Replies
View Related
Jul 26, 2014
I am going to to develop an app for my final year project. basically the app is to show live video streaming on android phone from remote CCTV . The project is just in design phase i know the networking part i.e static ip for dvr etc but i dnt know how to get stream of data from dvr and how to control the CCTV camera i.e camera movement....
View Replies
View Related
Jan 26, 2015
How can I set the default stylesheet for a user control that I have created? I want to make the control available for anyone to use and I want it to use a stylesheet by default without the user of the control having to do anything. I also want it to be possible for the user of the control to override the definitions set on the default stylesheet if he wants to.
View Replies
View Related
Feb 4, 2015
My question is regarding the the Inversion of Control (IoC) and Dependency Injection (DI) patterns, when learning about Spring i saw that people keep talking about Ioc and Dependecy Injection like if its the same thing!
View Replies
View Related
Nov 5, 2014
TabPane and Pagination controls. However, I would like to be able to create a vertical toolbar that controls page or tab display.
Is it possible to create a Pagination with no page control? Or is my guess of sizing the Pagination control so that the lower section is off of the displayed window, thus hiding the page info? Or, is it possible to create a TabPane with panels, but no tabs?
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
Apr 2, 2014
When I am watching scjp mock test, I am getting error about security.
I am trying to add www.javaranch.com to site exception list in java control panel. I can see security tab in java control panel, there I find field for Site Exception List. When I am add [URL] .... to this site exception list, list is not getting populated.
Why is that ? Why am I unable to add this site to list ?
I am using 64-bit system and have downloaded and installed 64 bit update patch 51.
View Replies
View Related
May 21, 2014
If I use an instance of Tooltip in my custom-control, it can not be imported to SceneBuilder any more. Using Tooltip in my custom-control skin works - is that the way it is supposed to be?
Background: I have a control (ValidatedTextField) which uses Tooltips to inform about unwanted characters. It works in SceneBuilder1.x.
SceneBuilder 2 does not "accept" this control unless I take out all Tooltips. I have verified this behavior with some other working controls.
I have found a workaround to use the Tooltip in the Skin.
View Replies
View Related
Feb 13, 2015
Trying to run my program after getting rid of code errors (I think) and now it doesn't produce anything but <terminated> in the console window. The produce is suppose to analyse text from a file and produce the percentage of words used
package com.project;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.math.BigDecimal;
[Code] ....
erfrf.jpg
View Replies
View Related
May 21, 2014
This is my program. All is working fine except stopping reading from console. Problem is that even after you write done if you are fast enough you are able to write more. As you can see I can't close scanner because of two inputs. Even so I tried to close it but problem was still here.
public static void main(String...args) {
System.out.println("Write first input:");
System.out.print(streamToString(System.in, ""));
System.out.println("Write secondinput:");
System.out.print(streamToString(System.in, ""));
[Code] .....
View Replies
View Related