package timerApp; import java.util.Scanner; import java.util.Timer; import java.util.TimerTask; import sun.audio.*; import java.io.*; public class timerDriver { static int interval;
[Code]...
So I'm trying to make a program that plays an mp3 file after a timer reaches 0, but i keep receiving the error "could not create audio stream from input stream" the audio file is 3.44 MB and 00:03:45 minutes long if that's a problem
I have a Stream instace which produces values using an infinite Supplier (it supplies values taken from an electronic sensor -- so unless the battery is low, the sensor will provide "for ever").
The stream is processed by a Collector using Stream.collect() (e. g. imagine that the values from the sensor should be averaged; in fact what it does is a bit more compliacted maths).
The problem is that the collector does not produce a result but hangs up, as the supplier does never stop providing more sensor values.
So what I need is a limitation rule that stops the stream. While there is a Stream.limit(long) method, it actually does not solve my problem as in my case it is not practical to stop after a particular count, while I actually want to stop streaming when the sensor value exceeds a particular limit etc. (hence, voids an arbitrary rule).
To sum up, what I need is Stream.limit(Predicate), i. e. the stream will stopped once the predicate becomes true.
Unfortunately I did not find anything like that in JRE 8.
Is that planned for JRE 8.1 or JRE 9.0? Or is there a known (and sophisticated) workaround?
i need a java library function that searches the stream of tcp packets coming to my computer from a particular ip address, so i can perform regular expressions on the contents of those packets.
i've got this code that i cant get to work as i want it to. when its exported and i run it the file i wants gets created but when i open the file there is a single number like 999998000001
import java.io.IOException; import java.io.PrintWriter; public class mainHej { public static void main(String arg[]){
Following is the code on the click of a button, id like to know how do i close the current jframe on which the jButton4 is currently placed. I know how to send it to the next Jframe i.e JobCard. But need to close the current one. I tried using this.setVisible(true); But it does not work.
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: this.setVisible(false); JobCard jobCard = new JobCard(); jobCard.setVisible(true); }
I didn't know about right method for correct close operation for JFrame component or kill the object. I found out few, which of them you are using usually???
How to make a Jframe close without closing the whole operation, I started off using exit on close and changed it to hide on close and i also tried dispose on close for some reason it wont work. Here is what I have.
import java.awt.*; import javax.swing.*; public class GUILauncheralt{ public static void main(String[] args){ RetrieveWindow gui = new RetrieveWindow(); gui.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); gui.setSize(400, 200);
I am writing a console application that is to make use of the system editor on *NIX. For that I have written a method which writes a string to a file, launches an editor to change that file, and then reads the file again. The problem is the call to run the editor doesn't wait for that application to have closed.
Java Code: Runtime.getRuntime().exec(editorcmd + " " + tmpfn); mh_sh_highlight_all('java'); I need the program to wait for the editor to have finished.
I have a practice exercise here wherein I will add a JOptionPane to a program. When the close button is clicked, the JOptionPane will appear asking the user to exit the program. If the user clicks "Yes," it'll, of course, close the entire program and not just the JOptionPane, but if the user clicks "No," it will return to the program. Please refer to my code below:
try { output = new DataOutputStream(new FileOutputStream("ProjSixExe4.dat")); } catch(IOException ex) { this.dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING)) } final JOptionPane optionpane = new JOptionPane("Are you sure you want to quit this program?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
The exercise said it must be placed before the EXIT_ON_CLOSE portion.
I am making a simple battleship program, you have the menu and click Start to get the board with the bombs (4 buttons as of now) Each button has either a bomb or a defualtbutton. I created my button so it can't be unselected. The problem is I have the button in a Class.java and I want that to close in a period of time. What do you recommend using?
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package battleship; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.GridBagLayout;
[code]....
I can call the clas in my main jFrame but I want to close the class after a certain time.
I made UpdateInmateDisplayer a Singleton so that I could access it from the private class ButtonHandler. It works to display the first inmate's number on the screen but when I close out the window and click the Book Inmate button in CurInmatesDisplayer again, it only shows a blank window. I've tried adding the components again from the ButtonHandler in CurInmatesDisplayer but it doesn't work.
soo, is there a way to (via sockets or something like that) connect to a stream via the streamers url (or just via anything) and then get the actual stream? like the images that keeps updating? so that i can display the images/stream on a jframe?
I have added a windowListener to my JFrame but for some reason it is not being called when I click X to close the window. I need to send a message to a server to notify it that the client window is closed. Some code snippets below (some lines excluded for brevity):
public class ChatGUI extends javax.swing.JFrame { .... setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); // I have all the window constants here but has no effect other than closing the window without calling the listener... addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosed(java.awt.event.WindowEvent evt) { formWindowClosed(evt); } }); .... private void formWindowClosed(java.awt.event.WindowEvent evt) {
My code runs correctly when i run the clients one after another without using threads.I am getting this following error when i run my multi-threaded server. When a server accepts a client connection, ClientHandler is the thread that handles that client.Exception in thread "main"
java.io.StreamCorruptedException: invalid stream header at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:737) at java.io.ObjectInputStream.<init>(ObjectInputStream.java:253) at comm.DOMTransfer.<init>(DOMTransfer.java:25) at ClientHandler.<init>(ClientHandler.java:18) at GridInfo.main(GridInfo.java:34)This is where the error occurs:input = new ObjectInputStream(socket.getInputStream());
I have a filechooser that works how it should and if anyone enters anything with a dot that isnt .xml it shows an invalid file name message. However when I dont choose a file and press cancel it still says that because when my boolean hits false it's the first thing it hits in that section of code.
if(!writeSuccess) { //display output messages in JOptionPane JOptionPane.showMessageDialog(null,"Error, file name invalid", "Error", JOptionPane.ERROR_MESSAGE); } else { JOptionPane.showMessageDialog(null,"Export successful", "Success", JOptionPane.INFORMATION_MESSAGE); //close the form me.dispose(); }
If I want it to just close down without it saying anything is there sort of if statement I could do that would prevent this? But if it is an invalid file name it will still show that message?
I am making a java swing program. I have a main window that opens a JForm window when the user clicks a menu option. Then I have a button on the JForm that closes the window on click. However, I would also somehow like to make the JForm return values to the main window (according to the states of the selector components) when it is closed. How would I go about this? Currently my jForm is a seperate class called "NewGame", and inside the menu item mouse clicked method, I have the following code:
//open new game jform window NewGame newGameWindow = new NewGame(); newGameWindow.setVisible(true); newGameWindow.setLocationRelativeTo(null); //center window
Is there something I can add here to get the object's values upon the window's close? Or is there a way I can add that into the button clicked method on the actual jForm?
I use the right term, release resources because after clicking the close button, the DOS prompts becomes unresponsive. So I have to close the DOS prompt, then reopen it, then type in the path again for the Java folders. Can you check where did I go wrong with my code? Is my placement of the WindowListener and WindowAdapter incorrect? Please refer to my code below:
I have other programs where the placement of the WindowListener and WindowAdapter are as exactly like this (within the class constructor block) where they close correctly and some that behave like this, that renders the DOS prompt unresponsive.
I've got a simple main routine that instantiates two structurally identical classes, and attempts to write them both out to System.out with an XMLEncoder:
package xmlencoding; import java.beans.XMLEncoder; public class Twice { public String name; public static void main(String[] args)
[code]....
I expected Line 16 and Line 24 to both write some XML-formatted output, looking very similar to each other. But here's my output:
Now, if I change Line 24 so that the second call to writeObject is to a different stream("23. XMLEncoder e2 = new XMLEncoder(System.err);"), I do get both outputs:
So, I am inferring that this means two XMLEncoder objects can't both hold references to the same OutputStream, even if the first object is closed before the second is created. In actual practice, I guess I can live with that, since I wouldn't write the XML-encoded version of two objects to the same stream (I'd get the header twice in the same file, and I believe that's a no-no). But I am surprised that this doesn't generate some kind of exception, either when the second XMLEncoder is constructed, or when its writeObject method is called. But, it just silently dies.