AWT / CATATAN</>↗AWT19 Apr 2010
The example code below shows you how to print a file using the default registered application’s print command for the corresponding file type. As an example, on Windows notepad.exe is the default application for printing a .txt file. To print a file using the default registered application we call the java.awt.Desktop.print(File) method. The print() method […]
AWT / CATATAN</>↗AWT19 Apr 2010
For editing a file using the default registered or associated application we can do a call to the java.awt.Desktop.edit(File) method. In the code snippet below we will edit a PNG file. Using the edit() method of the Desktop class will open the default registered application for PNG files. For example on Windows there could be […]
AWT / CATATAN</>↗AWT16 Apr 2010
If you want to open a file using the default registered or associated application for those files you can use the Desktop.open(File file) method call. In the example below we’ll ask the Desktop class to open a text file. package org.kodejava.awt; import java.awt.*; import java.io.File; import java.io.IOException; public class RunningDefaultAppOpen { public static void main(String[] […]
AWT / CATATAN</>↗AWT15 Apr 2010
Here is an example using the java.awt.Desktop class to open user’s default mail client application. There are two methods provided, the mail() and the mail(URI uri) methods. When specifying the URI to the application will be opened with the message field filled with the mailto information. You can refer to the following document for the […]
AWT / CATATAN</>↗AWT14 Apr 2010
The code below show you how to browse a website using the user’s default web browser. To get the default web browser you can use the Desktop class browse(URI uri) method call. package org.kodejava.awt; import java.awt.Desktop; import java.io.IOException; import java.net.URI; public class RunningDefaultBrowser { public static void main(String[] args) { URI uri = URI.create("https://kodejava.org"); try […]
AWT / CATATAN</>↗AWT05 Jan 2010
The program below show you how to turn on the Scroll Lock button programmatically. Setting the locking state to Boolean.TRUE activate the Scroll Lock. package org.kodejava.awt; import java.awt.*; import java.awt.event.KeyEvent; public class TurnScrollLockOn { public static void main(String[] args) { // Gets the default toolkit. Toolkit toolkit = Toolkit.getDefaultToolkit(); // Update the locking state for […]