Tag: জাভা

Demonstrates the use of a JColorChooser which presents a dialog with three different tabbed panes to allow the user to select a color preference

Demonstrates the use of a JColorChooser which presents a dialog with three different tabbed panes to allow the user to select a color preference. The dialog returns a Color object based on the user’s selection or null if the user entered Cancel.   import java.awt.*; import java.awt.event.*; import javax.swing.*; /** Simple example illustrating the use …

Continue reading

Creates various buttons. In Swing

import java.awt.*; import javax.swing.*; /** Simple example illustrating the use of JButton, especially  *  the new constructors that permit you to add an image.  *   */ public class JButtons extends JFrame {   public static void main(String[] args) {     new JButtons();   }   public JButtons() {     super(“Using JButton”);     WindowUtilities.setNativeLookAndFeel();     …

Continue reading

Multithreaded Graphics and Double Buffering

ShipSimulation.java  Illustrates the basic approach of multithreaded graphics whereas a thread adjusts parameters affecting the appearance of the graphics and then calls repaint to schedule an update of the display.   import java.applet.Applet; import java.awt.*; public class ShipSimulation extends Applet implements Runnable {   …     public void run() {     Ship s;     …

Continue reading

Driver class that creates three threaded objects (Counter2) that count from 0 to 4.

/** Try out a few instances of the Counter2 class. public class Counter2Test {   public static void main(String[] args) {     Counter2 c1 = new Counter2(5);     Counter2 c2 = new Counter2(5);     Counter2 c3 = new Counter2(5);   } } /** A Runnable that counts up to a specified  *  limit with random …

Continue reading

Template illustrating the second approach for creating a class with thread behavior.

Template illustrating the second approach for creating a class with thread behavior. In this case, the class implements the Runnable interface while providing a run method for thread execution. public class ThreadedClass extends AnyClass implements Runnable {   public void run() {     // Thread behavior here.   }   public void startThread() {     …

Continue reading

Creates and starts three threaded objects

Creates and starts three threaded objects which count from 0 to 4. Uses the following class: CounterTest.java Counter.java /** Try out a few instances of the Counter class. public class CounterTest { public static void main(String[] args) { Counter c1 = new Counter(5); Counter c2 = new Counter(5); Counter c3 = new Counter(5); c1.start(); c2.start(); …

Continue reading

DOM example that represents the basic structure of an XML document as a JTree

//XMLTree.java //Uses the following files Uses the following files:     * XMLFrame.java:Swing application to select an XML document and display in a JTree. ExtensionFileFilter.java Allows you to specify which file extensions will be displayed in a JFileChooser. test.xml Default file loaded if none selected by user. perennials.xml and perennials.dtd Data on daylilies and corresponding DTD. …

Continue reading

Simple example illustrating the use of check boxes

JCheckBoxTest.java Simple example illustrating the use of check boxes. import javax.swing.*; import java.awt.event.*;  */ public class JCheckBoxTest extends JPanel                            implements ItemListener,                                       ActionListener{   JCheckBox checkBox1, checkBox2;       public JCheckBoxTest() {     checkBox1 = new JCheckBox(“Java Servlets”);     checkBox2 = new JCheckBox(“JavaServer Pages”);     checkBox1.setContentAreaFilled(false);     checkBox2.setContentAreaFilled(false);         checkBox1.addItemListener(this);     …

Continue reading

Basic tool bar for holding multiple buttons.

BrowserToolBar.java A basic tool bar for holding multiple buttons. import java.awt.*; import javax.swing.*; /** Part of a small example showing basic use of JToolBar.  *  Creates a small dockable toolbar that is supposed to look  *  vaguely like one that might come with a Web browser.  *  Makes use of ToolBarButton, a small extension of …

Continue reading

Demonstrates the use of a JColorChooser which presents a dialog with three different tabbed panes to allow the user to select a color preference

Demonstrates the use of a JColorChooser which presents a dialog with three different tabbed panes to allow the user to select a color preference. The dialog returns a Color object based on the user’s selection or null if the user entered Cancel. import java.awt.*; import java.awt.event.*; import javax.swing.*; /** Simple example illustrating the use of …

Continue reading