| Could you write this sound applet? |
|
 |
Index ‹ java-programmer
|
- Previous
- 2
- paintImmediately()Is there a reason NOT to use paintImmediately()? It seems to solve a
problem that I've been having with repaint(), but it seems like this
is too easy a solution. Am I looking a gift-horse-in-the-mouth, or is
there some "gotcha" that I haven't run into yet?
Thanks
tom
- 3
- JTextPane: Workaround for invisible text with hanging indents?Hi all,
I have a hanging indent requirement for paragraph formatting:
<http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/text/StyleConstants.html#FirstLineIndent>
"The amount of space to indent the first line of the paragraph. This value
may be negative to offset in the reverse direction. The type is Float and
specifies the size of the space in points."
A search of Sun's bug database for [set]FirstLineIndent indicates that Sun
has fixed a number of bugs related to rendering negative first line
indents. Does the code I've written below demonstrate another rendering
bug? I'm typing invisible text on multiple platforms with the latest
stable JDK and Mustang beta:
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
public class InvisibleText extends JFrame {
public InvisibleText() {
JTextPane tp=new JTextPane();
SimpleAttributeSet attrs=new SimpleAttributeSet();
StyleConstants.setFirstLineIndent(attrs, -150.0f);
StyleConstants.setLeftIndent(attrs, 150.0f);
tp.setParagraphAttributes(attrs, true);
JScrollPane sp=new JScrollPane(tp);
sp.setPreferredSize(new Dimension(300, 200));
getContentPane().add(sp);
}
public static void main(String[] args) {
InvisibleText frame=new InvisibleText();
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
While typing text finally appears at the left indent position of
subsequent lines.
Assuming my code correctly invokes this API, can anyone come up with a
workaround to make the text appear while it is typed?
Many thanks,
Adam
- 4
- JRE versionsWe have in our company several applications that require JRE to work.
They have been developed by different people and some require specific
versions of Java to work correctly.
Normally the applications work well individually but sometimes, when we
need to work with some of them that require different JRE versions, we
are in trouble.
How can we deal with this problem? Why last versions of JRE are not
full compatible with the previous ones?
Greetings,
Samu
- 4
- Beginner question about JDO best practiceDear all,
this is the first time I'm using JDO/ORM (the JPOX implementation) and
so have a question about best practice.
Let's assume we have a class "Tag" with the only property "String
name" and according setters and getters. The related table has two
columns "PRIMARY BIGINT tag_id" and "UNIQUE VARCHAR name". Note that
the column "name" is unique.
Let's further assume that we manually create some Tag objects during
application runtime. We now want to persist these objects but we don't
care if they are already persisted in the database. If this is the
case, JDO should just attach the object to the database instance. What
is the best practice to accommodate this? Do I have to manually check
every object for existence first? I would like to avoid this.
Let's say the tag "coffee" is already available in the database. I'm
looking for something which works like this:
--8<-snip->8--
Tag tag1 = new Tag( "java" );
Tag tag2 = new Tag( "means" );
Tag tag3 = new Tag( "coffee" );
// no problem
pm.makePersistent( tag1 );
// no problem
pm.makePersistent( tag2 );
// throws SQLException DUPLICATE KEY but should just attach/update
tag3 to database instance
pm.makePersistent( tag3 );
--8<-snip->8--
Thanks for any hint!
- 5
- File Persistence In the Session ObjectI am developing a Struts1.1 based application, that returns an Excel
File generated by Jakarta's POI classes. One of the requirements is
that the file be stored in the SESSION ONLY, not on the file system.
Is this even possible? Doesn't a file need to be physically present
before a reference to it can be stored in the session?
prompt insight would be most appreciated, as I'm working against a
deadline.
Thanks!
PK
- 5
- Java and avoiding software piracy?On Jul 23, 6:12 am, "Dag Sunde" <email***@***.com> wrote:
> Oh, for God's sake stop it already!
>
> Twisted/nebulous99 is a well-known [insult deleted].
Your claims are incorrect.
> I am really suprised[sic] that the reasonably sensible Java community
> haven't just [death threat deleted]
You are under arrest. You have the right to remain silent. Anything
you say can and will be used against you in a court of law. You have
the right to an attorney. If you cannot afford an attorney, one will
be appointed to you at no cost.
You will confine yourself to your current workstation area until
police arrive. Law enforcement has been notified of your illegal act
and should appear shortly to take you into custody.
- 6
- Is native 1.4 jdk useless (SCSL license does not allow internalHi,
I hope that I have understood this wrong, but
if one reads the SCSL license when downloading
sources needed to compile native FreeBSD JDK 1.4,
the attachment "C" that tells about "internal deployment use"
says:
"INTERNAL DEPLOYMENT USE
This Attachment C is only effective for the Technology
specified in Attachment B, upon execution of Attachment D
(Commercial Use License) including the requirement to pay
royalties."
Doesn't this mean that I cannot use the native 1.4 JDK for
anything real without getting commercial license ?
If so, the native 1.4 jdk is useless - one
has to use diablo-jdk 1.3 (no hotspot....) or linux jdk (is
this stable with emulation).
Please, please correct me if I'm wrong.
Ari S.
--
Ari Suutari
Lemi, Finland
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 6
- Submission Deadline - Call for Papers VM 2004 (San Jose, 5/04)The VM'04 Program Committee invites you to contribute refereed papers
and work-in-progress reports to the third USENIX Virtual Machine
Research and Technology Symposium (VM'04). The Program Committee also
welcomes ideas, proposals, papers for invited talks, and suggestions for
birds-of-a-feather sessions.
Third Virtual Machine Research and Technology Symposium 2004 (VM'04)
May 6-7, 2004
San Jose Hyatt, San Jose, CA
http://www.usenix.com/events/vm04
Paper submissions are due October 13, 2003
The scope of the symposium will expand beyond that of the first and
second Java (TM) Virtual Machine symposia (JVM'01 and JVM'02) to
encompass other virtual machines, such as Microsoft's .NET initiative,
and low-level virtual machines/environments such as VMware, Connectix
Virtual PC, and SWSoft Virtuozzo.
Relevant topics for VM'04 include, but are not limited to the following:
VM implementation
Hardware implementation of standard VMs
Compilation techniques
Security
Garbage Collection
Embedded VM systems
Large VM and Server Issues (scalability and availability)
Interactions and trade-offs with static compilation
VMs and Grid Computing
Porting Experiences
Performance Issues and Tuning Techniques
Multiple VM environments and interactions
Proposed standards, particularly empirical studies Alternate VM
implementation
The complete call for participation and submission information can be
found at http://www.usenix.org/events/vm04/cfp/
The symposium will have 2 days of technical sessions. Sessions will
include presentations by invited speakers and authors of refereed
papers, the popular Work-in-Progress session, and birds-of-a-feather
sessions. VM '04 will continue to emphasize research and advanced
engineering techniques applicable to the development of virtual
machines, with an emphasis on experimental results. A Symposium
Proceedings will be printed and distributed to attendees.
Awards for the best paper and the best paper that is primarily the work
of a student will be presented at the Symposium.
We look forward to seeing you in May 2004 in San Jose!
Tarek Abdelrahman, University of Toronto VM'04 Program Chair
=====================================================================
The Virtual Machine Research and Technology Symposium is sponsored by
USENIX, the Advanced Computing Systems Association, in cooperation with
ACM Sigplan.
=====================================================================
If you have questions about this mailing or USENIX or SAGE membership,
please send e-mail to email***@***.com or phone 510 528 8649 and ask
for membership.
- 6
- Java programmer Job openingInternational company has 2 job openings for Java programmers. Requirements:
3 years experience java programming, self-sufficient, responsible, able to
lead extremely important projects, knowledge of unix/linux. Workplace
Lisbon. Great career opportunity.
Send applications to Filipe Mendes, email***@***.com
- 6
- Java3D Newbie ! ! "No compatible device" error is a driver, not Java3d problem
Java3d requries an OpenGL or DirectX rendering layer,
------------------------------------
and I think it not a Java3d problem but your system
is set up to render in with OpenGL or DirectX.
I reccomend OpenGL, I try to avoid "Microsft Only" solutions,
and they don't work very well on my Linux system.
Most Linux systems have a simple OpenGl demo: gears
and typing : gears
either runs a simple OpenGL demo or tells you
OpenGL can't run.
Check these links:
http://archives.java.sun.com/cgi-bin/wa?A2=ind0309&L=java3d-interest&P=26329
http://www.mail-archive.com/email***@***.com/msg25938.html
John Smart wrote:
> hi,
>
> I just wanted to start a demo ("HelloUniverse")
> but I get the error:
>
> " No campatible device found,
> please switch to other display mode and try again!"
>
> I switched to all screen resolutions but it still didn't work!
>
> Please help me!
>
> Thanks!
>
>
http://groups.google.com/groups?group=comp.lang.java.3d&selm=3f91437f%240%2415688%249b622d9e%40news.freenet.de
John, please include more relevant information
both in the subject line and body of your posts:
for rendering problems posting information about
your OS and video card helps us solve the problem.
I had to download and install OpenGL from Microsoft's
site when I was running Windows95, I think OpenGL
comes pre-installed on current versions of Windows,
I've upgraded from Windows-XX to Linux
to avoid the Micrsoft viruses, DRM amd expense
and I don't want my programs limited to just
one platform when the growth is elsewhere.
Java & Linux lets you be free, and go to mars ...
Nasa uses Java3d & VRML for the Mars Rover
-------------------------------------------
http://www.frontiernet.net/~imaging/Nasa_3d_animation.html
-- Paul, Java Developer & Web Animator
--------------------------------------
Imaging the Imagined: Modeling with Math & a Keyboard
- 8
- IDE for Java?I downloaded the Sun product, and find it feature rich but slow. Can someone
recommend a more basic (freeware) IDE which will help a newbie without
hiding every bit of code? I can program my way out of a wet paper bag in a
few languages, but want to by-pass some of the learning curve for this
project.
- 10
- javac and java -classpath with regards to antI'm think out loud about ant; I want build.xml to do:
<javac
srcdir ="${sourcedir}"
destdir ="${destdir}"
classpath ="${classpath}"
includes ="${includes}"
/>
inspired by
<http://developers.sun.com/dev/coolstuff/javamake/ant.html>
because that seems to spell out exactly what's sent to
javac. the properties:
property value
-------- -----
sourcedir /java/sources/atreides/jtidy/
destdir /java/classes/
classpath /java/sources/org/w3c/tidy/Tidy.jar
includes /java/sources/org/w3c/tidy/Tidy.jar
Now,
"The class path tells the JDK tools and applications
where to find third-party and user-defined classes --
that is, classes that are not extensions or part of the
Java platform. The class path needs to find any classes
you've compiled with the javac compiler -- its default
is the current directory to conveniently enable those
classes to be found,"
<http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/classpath.html>
so, TidyTest.java is in "sourcedir" and imports
org.w3c.tidy.Tidy using Tidy.jar, so the path to
Tidy.jar would be in the classpath. TidyTest.jar is in
the sourcedir, so doesn't need to be in the classpath.
I'm looking at this snippet, too:
<classpath path="${classpath}"/>
<http://ant.apache.org/manual/using.html#path>
But, don't know what it does, really, but since it
involves classpath it might be useful.
when using "plain" javac from the command line, it's
enough to use the "classfile" switch and give the path to
Tidy.jar like so:
/////////command line///////////////
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
C:\>javac @comp
C:\>java -classpath
.;C:\java\classes\org\w3c\tidy\Tidy.jar;C:\java\classes\
atreides.jtidy.Tid
yTest
C:\>type comp
-d C:\java\classes\
-g
-sourcepath C:\java\sources\
-classpath
.;C:\java\classes\;C:\java\classes\org\w3c\tidy\Tidy.jar
C:\java\sources\atreides\jtidy\TidyTest.java
And that's what I want ant to do, but I don't quite know
how to put it all together. Do I include classpath info
in the manifest for the jar which'll be built so that the
jar is clickable? The Main-Class should read
"atreides.jtidy.TidyTest" indicating where the main class
is, of course.
Since it's necesarry to include the classpath for
package org.w3c.tidy.Tidy to run TidyTest.class it
follows that Tidy.jar and its classpath must also be
included, down the road, in TidyTest.jar.
I hope I'm making at least some sense. For right now
I'll concentrate on getting ant to compile TidyTest.java
so that TidyTest.java can be executed with the java command,
then I'll work on packaging it up. Does that seem a good
way to approach this topic?
Thanks,
Thufir Hawat
- 10
- Applet notinitedOn 27-8-2004 11:42, Karl Juul wrote:
> "zoopy" <email***@***.com> wrote in message
> news:412efd64$0$568$email***@***.com...
>
>>On 27-8-2004 0:04, Andrew Thompson wrote:
>>
>>
>>>On Thu, 26 Aug 2004 22:58:47 +0200, zoopy wrote:
>>>
>>>
>>>>Then a new window pops up (title="DIAL IN WEB APPLICATION", "WELCOM TO
>>>>THE NYS...")
>>>
>>It's not a browser window, but a window launched by the Java applet.
>>
>>Which leads to the following as being "not applicable", IMO.
>>
>>
>>>Which leads me to the next point ..pop-ups.
>
>
> This is consistent with my experience trying to access this site from three
> different points...all three machines are running Google Toolbar with
> popup-blocking enabled. Two of those three machines have no problem loading
> the applet, leading me to conclude that popup blocking is not the problem.
> All three machines are running IE 6.0, probably with different
> configurations, though. One machine runs WIN XP Home (applet OK on that
> machine) while the other two use WIN 2000 Pro.
>
> Since two machines have no trouble loading the applet, I would have to
> conclude that the 83 reported errors are not fatal errors and the expired
> certificate wouldn't seem to be the problem either...
>
> Karl
>
>
Another thought: you're using a https, i.e. secure socket connection. I
don't exactly know how the SSL exactly works, but I think it is also on
the basis of certificates.
Could it be that the "problem" browser doesn't have an up-to-date set of
root certificates (to which another certificate can be traced back).
IIRC the updatesite of microsoft (windowsupdate.microsoft.com) once
offered an update of root certificates for Windows (or IE).
--
Regards,
Z.
- 11
- Linux/X-Windows unable to set focus on a modal form (Consulting $ anyone)It appears whenever a modal window is opened on Linux X-Windows the
focus is stolen from the window and you CANNOT use the keyboard or any
peice of code to return focus to the form - let alone set the focus in
the textbox.
This is not just for my modal forms but for something as fundamental
as JOptionPane or simple code like this:
JFileChooser chooser = new JFileChooser();
if (chooser.showOpenDialog(parentComponent) ==
JFileChooser.APPROVE_OPTION) {
}
From trolling through posts I can see no answers which is really sad
for Linux good for Microsoft I guess. How can we deploy on Linux if
you are forced to get carpal tunnel clicking on every form with the
mouse ?
I would be willing to pay some consulting dollars to get this
resolved.
Greg
- 11
- Javaws.exeI was shocked to notice that Javaws.exe has devolved. It is no longer
an end user tool to manage jawaws apps.
IIRC you used to be able to put a file on the command line. Now you
need a weird URL file://localhost/E:/mindprod/webstarts/esper.jnlp
Anyway you used to be able to launch from the GUI.
--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm
Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
|
| Author |
Message |
Chris

|
Posted: 2004-11-20 22:27:00 |
Top |
java-programmer, Could you write this sound applet?
As a start, consider this simple QBASIC program that generates random
frequencies:
10 frequency = 40 + 400 * RND
20 SOUND frequency, 7
30 GOTO 10
That's fine - except that it plays over the PC speaker - the one that's
just there for the happy beep - and not through the sound card and
proper speakers. You can't control volume, either.
I wonder if anyone would be kind enough to translate the above three
line program into a Java applet. I would like to see whether it looks
simple enough for me to cope with.
If it looks as if I could cope with Java, I would then learn it, and try
to program a way of generating sounds from a mathematical sequence or
formula.
--
Chris
|
| |
|
| |
 |
Chris Smith

|
Posted: 2004-11-21 0:39:00 |
Top |
java-programmer >> Could you write this sound applet?
Chris <nospam@[127.0.0.1]> wrote:
> 10 frequency = 40 + 400 * RND
> 20 SOUND frequency, 7
> 30 GOTO 10
> I wonder if anyone would be kind enough to translate the above three
> line program into a Java applet. I would like to see whether it looks
> simple enough for me to cope with.
You've picked a task that doesn't have a simple Java API. If you wanted
to play a sound file, or something along those lines, it would be much
easier. Here's a shot at your task, though. I've created AU-format
data (a simple file format that was convenient) and just played that.
You should be able to make this work by producing raw sound data as
well, but I didn't think about it initially.
Just know that this kind of low-level task isn't representative of most
Java programming. By the way, I don't know QBASIC's sound functions, so
I've assumed that "7" is the length of the tone. Feel free to correct
my variables below.
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.SourceDataLine;
public class Test
{
public static void main(String[] args) throws Exception
{
double freq = 40 + (400 * Math.random()); // Hz
double volume = 1.0; // range [0, 1]
double length = 7.0; // seconds
int sample = 11025; // samples / second
int nsamples = (int) (sample * length);
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(byteOut);
out.writeInt(0x2e736e64);
out.writeInt(24);
out.writeInt(nsamples);
out.writeInt(2);
out.writeInt(11025);
out.writeInt(1);
/* Sample data is produced by a sin function */
double fmultiplier = freq * 2 * Math.PI / sample;
double vmultiplier = volume * 127;
for (int n = 0; n < nsamples; n++)
{
out.writeByte((int) (
vmultiplier * Math.sin(n * fmultiplier)));
}
out.flush();
AudioInputStream in = AudioSystem.getAudioInputStream(
new ByteArrayInputStream(byteOut.toByteArray()));
SourceDataLine line = AudioSystem.getSourceDataLine(
in.getFormat());
line.open(in.getFormat());
line.start();
byte[] buf = new byte[16384];
int len;
while ((len = in.read(buf)) != -1)
{
line.write(buf, 0, len);
}
line.drain();
line.close();
}
}
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
|
| |
|
| |
 |
Chris Smith

|
Posted: 2004-11-21 0:51:00 |
Top |
java-programmer >> Could you write this sound applet?
Chris Smith <email***@***.com> wrote:
> > I wonder if anyone would be kind enough to translate the above three
> > line program into a Java applet.
And, silly me, I posted an application instead. The code from inside
main can be moved into any appropriate place in an applet to accomplish
the same thing. However, there is a permission needed to play audio
data, and I don't know if applets get it by default. You may need to
sign the applet and request permission from the user.
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
|
| |
|
| |
 |
Chris Smith

|
Posted: 2004-11-21 3:08:00 |
Top |
java-programmer >> Could you write this sound applet?
Chris Smith <email***@***.com> wrote:
> You should be able to make this work by producing raw sound data as
> well, but I didn't think about it initially.
Here's a function to do the same thing without producing a file format
first. This is really far better code than what I posted the first
time, and I'm donating it to the public domain. It can be called from
any context (application or applet), but it needs permission to play
sounds. It's not specified anywhere that applets wouldn't be granted
this permission, but that's really up to the web browser. So, you may
need to sign an applet to get the appropriate AudioPermission ("play").
/*
* Plays a pure tone with a constant frequency.
*
* @param freq Frequency, in Hz
* @param volume Relative volume, on a scale from 0.0 to 1.0
* @param length Length of tone, in seconds
* @param sample Sampling frequency, in Hz. Your sound hardware
* must be capable of playing sounds at this sampling
* frequency. It is recommended that you use a value
* of 8000, 11025, 22050, 44100, 48000, 96000, or
* 192400.
*
* @throws LineUnavailableException
* Your sound hardware is incapable of playing the sound.
* Either the system does not have sound hardware installed,
* or the sampling frequency is not supported.
*/
public static void playTone(
double freq, double volume, double length, float sample)
throws LineUnavailableException
{
int nsamples = (int) (sample * length);
AudioFormat format = new AudioFormat(sample, 8, 1, true, true);
SourceDataLine line = AudioSystem.getSourceDataLine(format);
byte[] buf = new byte[16384];
int bufi = 0;
line.open(format);
line.start();
/* Sample data is produced by a sin function */
double fmultiplier = freq * 2 * Math.PI / sample;
double vmultiplier = volume * 127;
for (int n = 0; n < nsamples; n++)
{
int val = (int) (vmultiplier * Math.sin(n * fmultiplier));
buf[bufi++] = (byte) val;
if (bufi == buf.length)
{
line.write(buf, 0, bufi);
bufi = 0;
}
}
if (bufi > 0) line.write(buf, 0, bufi);
line.drain();
line.close();
}
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
|
| |
|
| |
 |
Chris

|
Posted: 2004-11-22 0:51:00 |
Top |
java-programmer >> Could you write this sound applet?
In article <email***@***.com>, Chris Smith
<email***@***.com> writes
>Chris Smith <email***@***.com> wrote:
>> You should be able to make this work by producing raw sound data as
>> well, but I didn't think about it initially.
>Here's a function to do the same thing without producing a file format
>first. This is really far better code than what I posted the first
>time, and I'm donating it to the public domain. It can be called from
>any context (application or applet), but it needs permission to play
>sounds. It's not specified anywhere that applets wouldn't be granted
>this permission, but that's really up to the web browser. So, you may
>need to sign an applet to get the appropriate AudioPermission ("play").
Chris - first let me apologise for my tardy response. I had to divert
to sort out a hardware problem.
Next - I would like to express my sincere appreciation for the trouble
you have gone to. I am overwhelmed by the amount of work you must have
put into answering my question.
However ... I'm slightly nonplussed, too!
You are so far above my level that I hardly know what to say or ask.
Remember that I'm just a lowly QBASIC programmer.
And the program I wrote was a mere three lines!
I'll try a scatter-gun questioning approach - in case one of my
questions comes close to being relevant. Only answer if you have time -
you have been kind enough to do a lot already.
How can your function be used?
Could you put it in an applet on a website?
Does it mean I could write a program like the following:
Function frequency1, duration1, volume1
Function frequency2, duration2, volume2
Function frequency3, duration3, volume3?
If so - that would be fantastic - because then I could start feeding
values to the function from a formula. For instance, I could see what a
parabola sounds like!
Or feed the digits of pi into the function to generate sounds with
random frequency, duration, and volume.
Is that the sort of thing that could be done with your function?
--
Chris
|
| |
|
| |
 |
Andrew Thompson

|
Posted: 2004-11-22 1:28:00 |
Top |
java-programmer >> Could you write this sound applet?
On Sun, 21 Nov 2004 16:51:04 +0000, Chris wrote:
> How can your function be used?
> Could you put it in an applet on a website?
Since Shris has done most of the hard work already, I'll venture
an answer to this one.
Put the following lines before Chris' playTone method..
<code>
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import javax.sound.sampled.*;
public class ToneApplet extends Applet implements ActionListener {
Button tone;
public void init() {
setLayout(new BorderLayout());
tone = new Button("Play");
add(tone, BorderLayout.CENTER);
tone.addActionListener(this);
}
public void actionPerformed(ActionEvent ae) {
try {
playTone(441.0, 0.5, 2, 48000.0f) ;
} catch(LineUnavailableException lue) {
lue.printStackTrace();
tone.setEnabled(false);
}
}
</code>
..and this one after..
<code>
}
<code>
> Does it mean I could write a program like the following:
> Function frequency1, duration1, volume1
> Function frequency2, duration2, volume2
> Function frequency3, duration3, volume3?
Play with the source, 'Luke'.
Note also that playing a sound is allowed in an unsigned applet
(I suspected as much, but wanted to check it* before commenting).
The only problem with sound comes when trying to *record* the sound
that is going through the sytem's audio lines (eavesdropping).
* IE 6 & Moz. 1.7.2 running Java 1.5.0 beta.
HTH
--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
|
| |
|
| |
 |
Chris Smith

|
Posted: 2004-11-22 1:52:00 |
Top |
java-programmer >> Could you write this sound applet?
Chris <nospam@[127.0.0.1]> wrote:
> Next - I would like to express my sincere appreciation for the trouble
> you have gone to. I am overwhelmed by the amount of work you must have
> put into answering my question.
Not a problem. I was happy for an opportunity to figure out some of the
basics of the sound APIs. I'm sure the knowledge I gained will come in
handy at some point. I'm playing around this morning with modifying
wave forms, and I've got rough approximations of several basic vowel
sounds working. This is fun!
> However ... I'm slightly nonplussed, too!
> You are so far above my level that I hardly know what to say or ask.
> Remember that I'm just a lowly QBASIC programmer.
> And the program I wrote was a mere three lines!
I told you, in my first response, that you've chosen a task that sort of
falls between the cracks of Java APIs. The complexity of this task is a
coincidence; it's not indicative of the Java API in general. The code
is missing from the standard API because modern applications very rarely
produce constant pure tones like that. Playing a sound clip that you've
included with your applet is actually much easier, especially from an
applet.
> How can your function be used?
Just include it in your code, and call it.
> Could you put it in an applet on a website?
Yes. Whether you need to worry about security or not, though, is an
open question. Applets run under very severe security restrictions.
Since there's no official answer to this question, you'd need to write
the applet, and then just test it in various browsers.
> Does it mean I could write a program like the following:
> Function frequency1, duration1, volume1
> Function frequency2, duration2, volume2
> Function frequency3, duration3, volume3?
It would look something like this:
playTone(frequency1, volume1, duration1, 48000);
playTone(frequency2, volume2, duration2, 48000);
playTone(frequency3, volume3, duration3, 48000);
You would then include my function in the same class as the code that
calls it. You could also put the function in a different class (for
example, called SoundUtil), and then write this instead:
SoundUtil.playTone(frequency1, volume1, duration1, 48000);
SoundUtil.playTone(frequency2, volume2, duration2, 48000);
SoundUtil.playTone(frequency3, volume3, duration3, 48000);
The 48000 is a sampling rate; 48000 is generally used for professional
digital audio, and some lesser rate is probably sufficient for your
needs, but there's not a lot of cost to using the higher rate for
generated sound (if you were saving the sound as a file, the higher
sampling rate would result in a larger file).
> If so - that would be fantastic - because then I could start feeding
> values to the function from a formula. For instance, I could see what a
> parabola sounds like!
>
> Or feed the digits of pi into the function to generate sounds with
> random frequency, duration, and volume.
>
> Is that the sort of thing that could be done with your function?
Yes, but it sounds rather annoying! :)
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
|
| |
|
| |
 |
Chris Smith

|
Posted: 2004-11-22 1:56:00 |
Top |
java-programmer >> Could you write this sound applet?
Andrew Thompson <email***@***.com> wrote:
> Note also that playing a sound is allowed in an unsigned applet
> (I suspected as much, but wanted to check it* before commenting).
> The only problem with sound comes when trying to *record* the sound
> that is going through the sytem's audio lines (eavesdropping).
Thanks. I was hoping that was the case, but I didn't want to promise
anything.
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
|
| |
|
| |
 |
Chris

|
Posted: 2004-11-22 14:15:00 |
Top |
java-programmer >> Could you write this sound applet?
In article <email***@***.com>, Chris Smith
<email***@***.com> writes
>Chris <nospam@[127.0.0.1]> wrote:
>> Next - I would like to express my sincere appreciation for the trouble
>> you have gone to. I am overwhelmed by the amount of work you must have
>> put into answering my question.
>Not a problem. I was happy for an opportunity to figure out some of the
>basics of the sound APIs. I'm sure the knowledge I gained will come in
>handy at some point. I'm playing around this morning with modifying
>wave forms, and I've got rough approximations of several basic vowel
>sounds working. This is fun!
Chris - you have now convinced me that it's worth my learning Java.
Well ... that should keep me out of mischief for a few years!
I have got the book "SAMS Teach Yourself Java 1.2 in 21 Days", which is
dated 1998. Is that likely to be OK - or is it too old?
--
Chris
|
| |
|
| |
 |
Andrew Thompson

|
Posted: 2004-11-22 14:47:00 |
Top |
java-programmer >> Could you write this sound applet?
On Mon, 22 Nov 2004 06:15:05 +0000, Chris wrote:
> I have got the book "SAMS Teach Yourself Java 1.2 in 21 Days", which is
> dated 1998. Is that likely to be OK - or is it too old?
I am unfamiliar with that particular tome, but if it is good for
the basic principles of Java, you might flesh it out with lots
of reference to the Java API docs and Sun's tutorials (both of
which are downloadable for local browsing).
--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- Inline bytecode?Is it possible to do iline bytecode in Java? Sort of like inline asm
in c++, but platform independent.
- 2
- "Linked List" AssistanceCan someone please point me to a url that will show me how to create a
linked list.
This needs to be a very simple example as Linked Lists are confusing me.
Thankyou for your assistance.
- 3
- You have received 5 notifications from your fans!Alyssa
<http://www.fanbox.com/socnet/EmailStat.aspx?cmp=&xyz=1&lit=5&me=xAr3pqu
jU0kBSGmCF6dKsg==&fan=F1Qw1zM6IEk=&opg=http://profile.fanbox.com/profile
/NewCustomProfile.aspx?u=alyssawilcox591> sent you a fan request.
Automatically sign in
<http://www.fanbox.com/socnet/EmailStat.aspx?cmp=&xyz=1&lit=5&me=xAr3pqu
jU0kBSGmCF6dKsg==&fan=F1Qw1zM6IEk=&opg=http://profile.fanbox.com/Inbox/M
ain.aspx?messages=3> to view Alyssa's profile and to accept or reject
her fan request.24 hours ago
Alyssa
<http://www.fanbox.com/socnet/EmailStat.aspx?cmp=&xyz=1&lit=5&me=xAr3pqu
jU0kBSGmCF6dKsg==&fan=F1Qw1zM6IEk=&opg=http://profile.fanbox.com/profile
/NewCustomProfile.aspx?u=alyssawilcox591> sent you a fan request.
Automatically sign in
<http://www.fanbox.com/socnet/EmailStat.aspx?cmp=&xyz=1&lit=5&me=xAr3pqu
jU0kBSGmCF6dKsg==&fan=F1Qw1zM6IEk=&opg=http://profile.fanbox.com/Inbox/M
ain.aspx?messages=3> to view Alyssa's profile and to accept or reject
her fan request. 24 hours ago
Alyssa
<http://www.fanbox.com/socnet/EmailStat.aspx?cmp=&xyz=1&lit=5&me=xAr3pqu
jU0kBSGmCF6dKsg==&fan=F1Qw1zM6IEk=&opg=http://profile.fanbox.com/profile
/NewCustomProfile.aspx?u=alyssawilcox591> sent you a fan request.
Automatically sign in
<http://www.fanbox.com/socnet/EmailStat.aspx?cmp=&xyz=1&lit=5&me=xAr3pqu
jU0kBSGmCF6dKsg==&fan=F1Qw1zM6IEk=&opg=http://profile.fanbox.com/Inbox/M
ain.aspx?messages=3> to view Alyssa's profile and to accept or reject
her fan request. 24 hours ago
There are 2 additional fan requests to review
<http://www.fanbox.com/socnet/EmailStat.aspx?cmp=&xyz=1&lit=5&me=xAr3pqu
jU0kBSGmCF6dKsg==&fan=F1Qw1zM6IEk=&opg=http://profile.fanbox.com/Inbox/M
ain.aspx?messages=3> .
Click here to view ALL notifications
<http://www.fanbox.com/socnet/EmailStat.aspx?cmp=&xyz=1&lit=5&me=xAr3pqu
jU0kBSGmCF6dKsg==&fan=F1Qw1zM6IEk=&opg=http://profile.fanbox.com/Inbox/M
ain.aspx?messages=> Change your Email Summary Settings
<http://www.fanbox.com/socnet/EmailStat.aspx?cmp=&xyz=4&lit=5&me=xAr3pqu
jU0kBSGmCF6dKsg==&fan=F1Qw1zM6IEk=&opg=http://profile.fanbox.com/Prefere
nces/Main.aspx?open=emailPref>
You can control
<http://www.fanbox.com/socnet/EmailStat.aspx?cmp=&xyz=4&lit=5&me=xAr3pqu
jU0kBSGmCF6dKsg==&fan=F1Qw1zM6IEk=&opg=http://profile.fanbox.com/Prefere
nces/Main.aspx?open=emailPref> the frequency of these summary emails.
FanBox - 255 G Street #723, San Diego, CA 92101, USA
- 4
- Image from WebHi all, I need to read an image located in http://www.xxx.yyy/eee/test.jpg
...how can I do?
How can I display once readed in a swing interface?
thanks.
mario
- 5
- Problem running the hello world servletI installed j2sdk1.4.2_12, and apache tomcat 4.1.34, on a windows XP
box. I set the following environment variables:
CATALINA_HOME C:\apache-tomcat-4.1.34
CLASSPATH C:/Program
Files/Java/jre1.5.0/lib/xt/QTJava.zip;C:/j2sdkee1.3.1/lib
J2EE_HOME C:/j2sdkee1.3.1
JAVA_HOME C:/j2sdk1.4.2_12
PATH C:\j2sdk1.4.2_12\bin\
I edited the web.xml in C:\apache-tomcat-4.1.34\conf and uncommented
the invoker servlet tag so that I can run servlets.
I can now access jsp and html pages with tomcat, but when I tried to
run HelloWorld Servlet, it gives the following error:
ava.util.MissingResourceException: Can't find bundle for base name
LocalStrings, locale en_US
at
java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:838)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:807)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:578)
at HelloWorldExample.doGet(HelloWorldExample.java:38)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:696)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at
org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:417)
at
org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:131)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:696)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:198)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:595)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:432)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:954)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:138)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:595)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:432)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:954)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2459)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:132)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:595)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:593)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:593)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:432)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:954)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:126)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:595)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:432)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:954)
at
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:534)
What could be the problem?
- 6
- JNI CallStaticVoidMethod fails after N callsI have written an application in Java and C on the Solaris 10 (x86)
platform using the JDK 1.5.0_09. The Java code calls a native method
"startButtonWatcher," which then forks, the parent process returning,
and the child process initiating an event loop that calls a static
method, "sendButtonEvent," on a Java class "ButtonWatcher."
The problem is that on the 65 invocation, the CallStaticVoidMethod will
hang. There is no core file or pid log file produced. (it will also
hang for CallVoidMethod as well if I remove the static declaration in
ButtonWatcher.)
I have also added a main() function to the C code so that it can be
compiled and run as an executable rather than a library file loaded
from Java, and the the same loop will be fine, the Call*Method call
being exected forever (or over a million times at least). The only
difference in the code is the JVM--in the sharable library, it uses the
JVM of the class that calls the native method, and the standalone has
to create its own. What could be the problem? Thanks!
- 7
- how to hide tabs in JTabbedTableHello all
I have a JTabbedTable with many tabs with JPanel in it. I want in a state,
only some tabs are shown and other states, other tabs are shown. I used
setVisible(boolean) but it does not work. could you please help
thank you
S.Hoa
- 8
- pass by referenceAndreas Leitgeb wrote:
> Patricia Shanahan <email***@***.com> wrote:
>> The issue is more critical for people for whom "pass by reference" is
>> familiar language. They will think they know what it means, and have to
>> find out somehow that it means something entirely different, when
>> talking about Java, that it does when talking about other languages.
>
> By the way, this is also true for "reference" itself. They also have
> to learn that what Java calls a reference wouldn't be called that way
> in other languages, for exactly the reasons you wrote (null allowed,
> assignment-semantics).
Indeed, I think the choice of "reference" to mean "pointer or null" was
a bad one. It would have been better to call a pointer a pointer, and
note that it can be null.
For the benefit of people transitioning from C or C++, it may be
necessary to note that it does not have pointer arithmetic or unsafe
conversions.
> Why is it ok, to talk of references in Java, but have an entirely
> different meaning of "reference" in mind in context of the phrase
> "pass by reference"?
"pass by reference" (or more usually "call by reference") is a long
standing term with a meaning independent of the use of "reference" as a
freestanding term. I learned it long before I knew any language in which
one could actually have a reference. I don't see any reason why having
to learn a Java-specific meaning of reference should require people to
learn special meanings of other terms, especially when with have a
perfectly good phrase, "pass reference by value", that is only one word
longer and says *exactly* how Java behaves.
Patricia
- 9
- 10
- Java Object Persistence (JSP & Java)Hi all.
I'm currently working on a simulation with a web frontend. The
simulation is based on 3 components:
- A Webfrontend
- A persister (which is the object of my quetsio :-)
- A WorkHorse
The Workhorse is doing the actual simulation while the web frontend is
used to interact with the Simulation (queueing and dequeueing new
events to the simulation stack).
Now my question is what the best choice for the persister would be.
I found http://www.prevayler.org/wiki.jsp which looks nice but I don't
know if it's the best choice. Is there a library that transparently
saves and loads whole Object dependencies from an SQL Database, or is
an Object Cloud better?
What is your experience with this/other libraries?
- 11
- Creating an object during runtimeI'm trying to generate an object name during run time, and then create an
object with the contents of that variable. You can see that I'm trying to
also make the object name self generating (almost, the 'y' variable isnt
being incremented yet), putting two values ('y' and 'C'). My apologies for
poor coding structure / lack of comments, but I'm am a bit lost on how to
work it out. MANY thanks in advance.Heres what I have so far:
public class testVariable
{
private String name = "";
private String New_name = "";
private int y = 2;
public testVariable()
{}
public void test(String x)
{
name = x;
New_name = name + y ;
System.out.println(New_name);
}
public String getNew_name()
{
return New_name;
}
public static void main(String[] args)
{
int z = 2;
testVariable Darren = new testVariable();
Darren.test("C");
testVariable "c"+ z = new testVariable();
String Old_name = New_name;
}
}
- 12
- "class not found".I'm getting the dreaded "class not found" error. I've Googled this
error and found that it's quite common, but not in exactly the way I
get it. My applets run fine on my machine, both when tested locally
via a local HTML file, and also when going to website, but gives the
"Class not found" error other machines. Anyone have any idea what
might be wrong?
I suspect it may be a codebase error, but I've tried the following in
my HTML file without success:
<APPLET CODE="moonCalendar.class"
name = "moonCalendar" WIDTH=1000 HEIGHT=350>
<APPLET CODE="moonCalendar.class" codebase="."
name = "moonCalendar" WIDTH=1000 HEIGHT=350>
<APPLET CODE="moonCalendar.class"
codebase="http://www.ckolchak.com"
name = "moonCalendar" WIDTH=1000 HEIGHT=350>
You can see if it works on your machine by going to:
http://www.ckolchak.com/astroCalendar.htm
- 13
- Java Timer, swingDear Java experts,
I'm struggling with timers. I've used javax.swing.Timer in my program. But
when one doesn't have the jre installed, my program doesn't work. It then
gives a class not found exception in the browser. It only works on the sun
virtual machines which you have to download from the website like some jre.
I quess the swing library isn't supported by a lot of virtual machines. But
I'm happy about how the timer works in my program because it makes use of
the actionListener.
Is there some easy solution? Using a simple Timer like the swing version and
let it work on any virtual machine/ jre?
best regards,
Piet den Dulk (Netherlands)
- 14
- Intellij 5.1 compile time error..hi,
I am using Intellij 5.1 version. Each time I build the project I get
an error:
error: Compiling Web Module 'web':Invalid file
and the file is in the "deploy" folder
So each time I go into the folder and maually delete the .war file and
then when I build the project it works fine.
>From what I have seen one more person using the same version has this
problem. but the one's using the earlier versions don't have this
problem.
Is there any solution for this?
thanks,
- 15
- ports/69675: Eclipse slow typingSynopsis: Eclipse slow typing
Responsible-Changed-From-To: freebsd-ports-bugs->java
Responsible-Changed-By: ijliao
Responsible-Changed-When: Wed Jul 28 02:09:00 GMT 2004
Responsible-Changed-Why:
over to maintainer
http://www.freebsd.org/cgi/query-pr.cgi?pr=69675
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
|
|
|