Disabling Audio With JButton

Oct 11, 2014

I am having right now is that I don't know how to stop my music from playing? I am making a Connect 4 game with some audio to make it intuitive. Below is my code. This is my Music method.

public static void Music() {
try {
File music = new File("C:\Users\Ken\workspace\Assignment1\src\Mario1.wav");
AudioInputStream audioIn = AudioSystem.getAudioInputStream(music);
Clip clip = AudioSystem.getClip();
clip.open(audioIn);

[Code] ....

I called this method into a JButton i implemented into my main GUI.

if (e.getSource() == SoundOn){
Music();}
if (e.getSource() == SoundOff){
//What do I put here?
}

There is the method and my JButton.

View Replies


ADVERTISEMENT

Program Which Compares Audio File With Real Time Captured Audio

Nov 23, 2014

I wanted to know some hints on where to begin if I wanted to create a program which compares an audio file with real time captured audio. I found this website "[URL]...", but I think this would not do the job, so what are the basics of audio in java and how to compare audio files and see if they are compatible.

View Replies View Related

Disabling All Screen Buttons

Apr 29, 2014

I'm having an issue with a swing application I'm working on. Java version is 4 (I know...). I have a main screen panel with multiple sub-panels (rows). Each of these row panels contains an additional 2 sub-panels. One of these 2 sub-panels contains buttons. When 1 button is pressed, I want to disable all of the buttons on-screen (or any other way of blocking user input) until a background event finishes. The row panels do not know about each other.

The first thing I have tried doing is, when a button is pressed, getting the parent. Using the parent I then iterate through its components, and so on until I'm iterating through the buttons. For each button, I am doing a .setEnabled(false); However, this does not work, why. I've also tried wrapping this process in SwingUtilities.invokeLater() out of desperation, but that didn't work either.

What would be the cleanest way to disable all buttons? Or block all user input? I've also tried adding an opaque dialog which hasn't worked. Last resort would be maintaining some sort of button list, but I'd rather not.

View Replies View Related

Swing/AWT/SWT :: Disabling JPanel And All Its Components?

Oct 8, 2001

Let me explain by simplifying the GUI to a simple frame in which I have a JCheckbox and a JPanel mypanel.mypanel has a Textfield tf,JComboBox cmb as it's components.So now if I deselect the JCheckbox, all the components in the mypanel should be disabled. I used a code like:

[code]mycheckbox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
if(mycheckbox.isSelected())
mypanel.setEnabled(true); else
mypanel.setEnabled(false); } });[code]

but the components inside the panels are not disabled. In my actual program I have a large number of different kinds of components in mypanel.So disabling/enabling each of them on each actionPerformed of the mycheckbox will be laborious. Isn't there any way by which I can disable/enable the mypanel to disable/enable all the components in it?

View Replies View Related

Jbutton Act Like A Wall That Will Not Allow A Moving Jbutton To Pass Through

Apr 7, 2014

I am trying to have a Jbutton (blocker02) act like a wall that will not allow a moving Jbutton to pass through. I tried using " if (blocker02. getBounds (). intersects(r_wall)) but it hasn't been successful.

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.geom.Rectangle2D;

[code]....

View Replies View Related

Servlets :: Disabling Cookies In Firefox Does Not Create Session

Mar 4, 2014

I'm experimenting the basic concepts of Servlet technology with my below simple setup.

I have a welcome.jsp defined under webContent in eclipse and my welcome.jsp looks like

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" [b]session="false"[/b]%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

[Code] ....

Now I have few questions based on the above setup

1) As you see session="false" in jsp, and when I used scriptlet like <%= request.getSession(false) %>, I see "null" being printed but if I use pageContext.request.session.id, the session is not null. How does session = "false" influences scriptlets and implicit objects and why the behavior is different

2) If session really exists, even when session=false is used, when I disabled cookies in FireFox browser and click on "click Me" hyperlink, the control goes to Controller, but in the servlet, I see 'No Session Created" being displayed. Which means session was not created and probably because I used false is getSession(false). But if I enable cookies, with the same setup, I get Session ID = << some value>> being printed and this is same as the session what printed through pageContext.request.session.id in the jsp.

So when cookies disabled, how can pageContext.request.session.id actually printed session id , but not in servlet and when cookies enabled, the same session id is displayed in both cases.

My question is why there is no impact in jsp, when cookies are disabled.

View Replies View Related

JSF :: Enabling And Disabling ComboBox / TextBox Based On Actions

Apr 24, 2014

This is my modalPanel code:

<rich:modalPanel id="createManagedObject" moveable="false" autosized="true" width="500" rendered="true" domElementAttachment="form">
<f:facet name="header">
<h:panelGroup>
<h:outputText value="Create Managed Object"></h:outputText>
</h:panelGroup>
</f:facet>
<f:facet name="controls">
<h:outputLink onclick="#{rich:component('createManagedObject')}.hide(); return false;">

[Code] ....

As shown in the above code:

I have following components in ModalPanel:

1) ComboBox
2) Instance
3) Save and Cancel

I wanted some validation here :

For example:

- The Instance Text box and SAVE button should be disabled. When the pop up appears.
- The Instance Text BOX gets enabled only when any selection happenes in COMBO Box
- The SAVE button gets enabled only when COMBO BOX and INSTANCE TEXT BOX is filled.
- Let the CANCEL button be enabled always.

View Replies View Related

How To Read Audio File In Java

Mar 20, 2015

How to read an audio file in java?

View Replies View Related

Applets :: Pause / Resume Audio?

Jul 22, 2014

I'm trying to learn how to Pause/Resume audio in an applet .

View Replies View Related

Managing Audio Files In Java

Apr 18, 2014

I'm doing a little game in Java and I would like to insert a background music managed by a JButton. When the button is pressed, the music starts and then, to stop it, the button is pressed again. If you don't press the button to stop the music remains in the loop until the player plays.

View Replies View Related

Audio-system Can't Find Any Mixers

May 13, 2014

I've moved working code over to a different computer, a 32 bit Dell PC running Win7 under Netbeans and Java 8. I can't get it to play or synthesize any sounds because it can't get any Mixers. I tried adding the standard provider entries to the sound.properties file (they aren't needed in my other computer, but I had to try), and it made no difference. I've tracked down the problem farther by getting the source code for these classes and stepping through.

The system seems to have the Mixer providers, but in java.util.ServiceLoader.LazyIterator$nextService() it is looping through a set of javax.sound.sampled.spi.MixerProviders and it hits the following error:

try {
S p = service.cast(c.newInstance());
providers.put(cn, p);
return p;
} catch (Throwable x) {
fail(service,
"Provider " + cn + " could not be instantiated",
x);
}

why this is happening?

View Replies View Related

IOException - How To Play Audio File

Apr 17, 2015

I used the following but there's an IOexception. How can I set it up so that it can play audio even after the jar is built?

public void play(){
InputStream in = null;
try {
in = new FileInputStream(new File(filename));
AudioStream audioStream = new AudioStream(in);
AudioPlayer.player.start(audioStream);
in.close();

[Code]...

View Replies View Related

Streaming Audio Files Over Web Using JMF Plugin

Feb 18, 2015

I've been experiencing problems with the JMF extension when used in an Applet on the web. The program has worked fine previously but not returns the following error...

PackageManager: error reading registry
javax.media.NoPlayerException: Cannot find a Player for : [filename]
at javax.media.Manager.createPlayerForContent(Manager .java:1412)
at javax.media.Manager.createPlayer(Manager.java:417)

[Code] .....

However the program works fine in Eclipse with no errors. I have tried reinstalling the JMF package and setting the CLASSPATH and JMFHOME but it still does not work. I am using the jmf-2_1_1e-alljava version. I have also tried putting the player code in an AccessController.doPrivileged() block but this still does not seem to work.

My code for the player is as follows....

private void play(final String track) {
Thread dispatch = new Thread() {
public void run() {
try {
if(player!=null)
player.close();

[Code] .....

View Replies View Related

How To Play Audio In A Stand Alone Application

Jun 26, 2014

how to play audio in a stand alone application.

View Replies View Related

How To Play Downloaded Audio File

Dec 15, 2014

I am making a little game for my friend based on HTML and javascript and i was wondering how to play an audio file that i downloaded on to my computer without the user interacting. like a buzzer you would hear on jeopordy or something like that, creating a Wrong answer buzzer and a right answer buzzer into an if/else statement.

View Replies View Related

Swing/AWT/SWT :: Continuous Audio Data Stream Not Working

Oct 15, 2014

I am trying to make my audio loop and i tried the code below

public void audioloop() {
AudioPlayer MGP = AudioPlayer.player;
AudioStream BGM;
AudioData MD;
ContinuousAudioDataStream loop = null;
try {

[Code] ....

But is not working. I was thinking may be API is not work with java 7 because i got the following warning (AudioStream is internal proprietary API and may be removed in a future release);

View Replies View Related

Android Audio Decoding For Morse Code And PSK31

Jan 6, 2014

I have some software I need to write. I am planning to write two apps for Android, one of which will send and receive Morse code, and the other to send and receive PSK31 data.

Programming is not my strong point, and I am currently struggling on how to do this. I have researched the software, and I am having a hard time finding out how to decode the audio streams on Android. I have also had difficulty finding examples and source code as what I have found is mostly written in C/C++, whereas I need examples in Java.

View Replies View Related

Basic Translation Software - Adding Audio To Words

Jan 30, 2015

I am a visual effects artist not a programmer but I wanna create a very basic translation software to improve english language in primary school students in my country. I cannot program at all except html and css but I am willing to do and learn whatever it takes to make this work. I don't know where to start from or what language to use. The structure of the program is to type an english word and then it must give out a translation of my local language and vice versa and I would like to add audio to the words.

View Replies View Related

Java App / Audio Producer - Multiple Consumer Design

Jun 1, 2014

I am planning to develop an application that does the following:

1) Receiving an audio streaming from a shoutcast server
2) Decode and push it throught producer to a shared buffer
3) Share audio data to as many consumers are interested to this feed.

What is the best practive for doing this? I tried several things without success.

View Replies View Related

Simple Client Server Audio Streaming Code In Java

Apr 18, 2014

I worked on this simple client server chat app and it worked now for my project i needed to work on client server audio streaming broadcast but i dont really know much bout audio api and methods on java...

View Replies View Related

Unable To Create Audio Stream From Input Stream

Jan 18, 2015

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

View Replies View Related

How To Use Timer With JButton

Apr 26, 2015

[attachment=38859:bcourt.jpg]I/m not used to Timers, so this will be my first time using it and I don't know how. I've been searching the internet for an hour but I can't find an answer into it. I'm currently doing a basketball game which has a Buttons (Shoot,Dribble,Hold) and I need those timers for my buttons to work. Her's the code:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class BasketBall extends JPanel implements ActionListener
{
JButton shootButton = new JButton("SHOOT");
JButton drbblButton = new JButton("DRIBBLE");
JButton holdButton = new JButton("HOLD");

[Code]...

View Replies View Related

How To Go From One Method To Another When Jbutton Is Clicked

Apr 2, 2014

Is it possible to go from one method to another when a jbutton is clicked?

View Replies View Related

Swing/AWT/SWT :: Key Listener On Jbutton

May 25, 2014

I have a Jbutton in my application named as SUBMIT,on clicking SUBMIT the text of jButton changes to ABORT. I wish to apply enter key listener on both the SUBMIT and ABORT button in my applcation, however I am not able to get the text of the button in key listener,so that i can apply my code based on the current text of Button.

View Replies View Related

Swing/AWT/SWT :: JButton Does Not Do All Tasks

Aug 3, 2014

I have a jButton that when the action perform runs it only does part of the tasks some of the code doe not appear to run and i just can not figure out why i have tried wrapping parts of it in an if statement and it still do not run so here is the code behind the button:

in the code the parts that do not run are jTextField10.setText("Working Please Wait"); and jButton15.setVisible(false);

what i am expecting to happen is the text field has the words Working Please Wait placed in it , this does not happen and the button should be hidden to prevent it being clicked a second time again this does not happen

the rest of the code works as expected

InputStream inStream;
OutputStream outStream;
try {
File afile = new File("C://templates//amendments.xls");
File bfile = new File("C://amendments.xls");
inStream = new FileInputStream(afile);
outStream = new FileOutputStream(bfile);

[code]....

View Replies View Related

JButton In A JTable Cell

Aug 19, 2014

How do i parse a String of text in a JTable Cell to work as a button?For example lets say a row of IDs such as 1,2,3,4,5,6 id like the whole column to parse as JButtons that are titled 1,2,3,4,5,6..Id like to then use these buttons to call a function with the title as a parameter.Its just a simple row of entries where the button will open up an edit screen to edit the corresponding clicked entry.So how do i parse them as buttons for a start?

View Replies View Related







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