SWING / NOTES</>↗Swing12 Jan 2010
The example below demonstrate how to create a custom JTextPane component that have a background image. package org.kodejava.swing; import javax.imageio.ImageIO; import javax.swing.*; import java.awt.*; import java.awt.image.BufferedImage; import java.io.IOException; import java.util.Objects; public class TextPaneWithBackgroundImage extends JFrame { public TextPaneWithBackgroundImage() { initUI(); } public static void main(String[] args) { SwingUtilities.invokeLater( () -> new...
CORE API / NOTES</>↗Core API10 Jan 2010
In the following example we are going to sort a string containing the following numbers "2, 5, 9, 1, 10, 7, 4, 8" in ascending order, so we will get the result of "1, 2, 4, 5, 7, 8, 9, 10". package org.kodejava.util; import java.util.Arrays; public class SortStringNumber { public static void main(String[] args) { […]
AWT / NOTES</>↗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 […]
AWT / NOTES</>↗AWT02 Jan 2010
The example below show you how to activate the Num Lock button programmatically. Setting the locking state to Boolean.TRUE will turn the Num Lock on. package org.kodejava.awt; import java.awt.Toolkit; import java.awt.event.KeyEvent; public class TurnNumLockOn { public static void main(String[] args) { // Gets the default toolkit. Toolkit toolkit = Toolkit.getDefaultToolkit(); // Update the locking state […]
AWT / NOTES</>↗AWT28 Dec 2009
The code below show you how to activate the Caps Lock button programmatically. Setting the locking state to Boolean.TRUE will turn the Caps Lock on. package org.kodejava.awt; import java.awt.Toolkit; import java.awt.event.KeyEvent; public class TurnCapsLockOn { public static void main(String[] args) throws Exception { // Gets the default toolkit. Toolkit toolkit = Toolkit.getDefaultToolkit(); // Update the […]
AWT / NOTES</>↗AWT26 Dec 2009
This example show you how to detect if the Scroll Lock key is in active mode. If you run the program you will get an output telling you that the Scroll Lock button is active or not active. package org.kodejava.awt; import java.awt.Toolkit; import java.awt.event.KeyEvent; public class ScrollLockState { public static void main(String[] args) { Toolkit […]