Client-Side Development Section Index | Page 5
How do I play a MIDI file using the Mobile Media API (MMAPI)?
Player player = Manager.createPlayer("http://example.com/example.midi");
player.start();
Using the Mobile Media API, how can I loop the playback of my song?
Use the setLoopCount() method of Player to playback media with looping. A value of -1 means forever. A value of 1 is the default. 0 is invalid.more
Using the Mobile Media API, how do you play a video?
This is similar to playing an audio file but requires you to get the control to display the video on. You need to see the results, not just hear them.
InputStream is = getClass().getResourceAsStr...more
What is jrunscript?
In JDK 6.0, jrunscript is a command-line scripting shell program. Supposedly, it is experimental and may not survive past JDK 6.0.
How can I write over a splash screen?
With Java 6, prior to the main window of the application showing, you can get the splash screen via SplashScreen splash = SplashScreen.getSplashScreen();, get its graphics context, and draw to it ...more
How do I show a splash screen for my jarred up program?
You need to specify the splash image in the manifest file for the jar:
Manifest-Version: 1.0
Main-Class: HelloSplash
SplashScreen-Image: MyImage.png
Then run the JAR without specifying t...more
How do I show a splash screen from the command-line for my program?
With JDK 6.0, there is a -splash option for java, as in java -splash:Hello.png HelloWorld.
What serves as the base class for all Swing components?
The JComponent class of the javax.swing package serves as the base class.
How can I use a component as a tab text/icon on a JTabbedPane?
Prior to Java 6, you couldn't. With Java 6, there is a new setTabComponentAt() method of JTabbedPane.
How do I find out the list of image formats I can read or write?
To discover the installed set of readers and writers, you simply ask the ImageIO class through its getReaderFormatNames() and getWriterFormatNames() methods. You can also get the set of mime types...more
How do I print the contents of a JTextComponent, with headers, footers, and across multiple pages?
Added to JDK 6, you call the print() method of JTextComponent to do this. Prior versions required you to paginate things yourself.
Should I use the invokeLater() and invokeAndWait() method of EventQueue or SwingUtilities?
Short answer: EventQueue.
Longer answer... Utility methods were added to the SwingUtilities class because the first version of the Swing classes had to work with JDK 1.1, even though Swing was re...more
When writing a JPEG image, how do I control the compression level/quality?
You can get the default writing parameters for a specific ImageWriter through its getDefaultWriteParam() method. The method returns an ImageWriteParam object. For JPEGs, this happens to be an inst...more
Im looking for the simpliest TTT source code, 3x3 matrix...Human vs Human. If anyone have it, please show me the script.
Here is a TicTacToe applet/application hybrid.
It runs as an applet in a browser and as an application when launched from the command prompt.
import java.awt.*;
import java.awt.event.*;
import j...more
I want the user to be able to input tabs in my application, but the tab character moves the input focus to the next component in the app and my application's keylistener gets nothing. Is there any way to change this behaviour ?
The tab is a focus traversal key by default and you have to change this to catch the tab entries in your keylistener. You do this by overriding the Component method : getFocusTraversalKeys(int id)...more