Category: FromSitesTree.com

ReverseLabels.java Inherits from CloseableFrame.java and uses ReversibleLabel.java. #Programming Code Examples #Java/J2EE/J2ME #AWT Components

ReverseLabels.java Inherits from CloseableFrame.java and uses ReversibleLabel.java. ********************** ReverseLabels.java ********************** import java.awt.*; ****************** public class ReverseLabels extends CloseableFrame { public static void main(String[] args) { new ReverseLabels(); } public ReverseLabels() { super("Reversible Labels"); setLayout(new FlowLayout()); setBackground(Color.lightGray); setFont(new Font("Serif", Font.BOLD, 18)); ReversibleLabel label1 = new ReversibleLabel("Black on White", Color.white, Color.black); add(label1); ReversibleLabel label2 = new ReversibleLabel("White …

Continue reading

Layout of a complicated GUI interface with GridLayout #Programming Code Examples #Java/J2EE/J2ME #AWT Components

################################## GridBagTest.java Layout of a complicated GUI interface with GridLayout. Uses WindowUtilities.java and ExitListener.java. ################################## import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; import javax.swing.border.*; /** An example demonstrating a GridBagLayout GUI with * input text area and multiple buttons. * ********* public class GridBagTest extends JPanel { private JTextArea textArea; private JButton bSaveAs, bOk, …

Continue reading

Create PopupMenu and add MenuItems #Programming Code Examples #Java/J2EE/J2ME #AWT Components

import java.applet.Applet; import java.awt.*; import java.awt.event.*; ************************ /** Simple demo of pop-up menus. * ******************** public class ColorPopupMenu extends Applet implements ActionListener { private String[] colorNames = { "White", "Light Gray", "Gray", "Dark Gray", "Black" }; private Color[] colors = { Color.white, Color.lightGray, Color.gray, Color.darkGray, Color.black }; private PopupMenu menu; /** Create PopupMenu and add …

Continue reading

Custom AWT Slider #Programming Code Examples #Java/J2EE/J2ME #AWT Components

***************** Custom AWT Slider * LabeledCostSlider.java. A numeric slider class with attached label. * CostSlider.java. A slider class that lets you read numeric values. Used in the LabeledCostSlider class. * Slider.java. A slider class: a combination of Scrollbar and TextField. Used in the CostSlider class. * ScrollbarPanel.java A Panel with adjustable top and bottom insets, …

Continue reading

Lists.java #Programming Code Examples #Java/J2EE/J2ME #AWT Components

Lists.java Inherits from CloseableFrame.java. /./././././././././ import java.awt.*; /*****************/ public class Lists extends CloseableFrame { public static void main(String[] args) { new Lists(); } public Lists() { super("Lists"); setLayout(new FlowLayout()); setBackground(Color.lightGray); setFont(new Font("SansSerif", Font.BOLD, 18)); List list1 = new List(3, false); list1.add("Vanilla"); list1.add("Chocolate"); list1.add("Strawberry"); add(list1); List list2 = new List(3, true); list2.add("Colored Sprinkles"); list2.add("Cashews"); list2.add("Kiwi"); add(list2); …

Continue reading

TextFields #Programming Code Examples #Java/J2EE/J2ME #AWT Components

import java.applet.Applet; import java.awt.*; /** A TextField from each of the four constructors. * ********************* public class TextFields extends Applet { public void init() { add(new TextField()); add(new TextField(30)); add(new TextField("Initial String")); add(new TextField("Initial", 30)); } } Note: Brought from our old site: http://www.salearningschool.com/example_codes/ on Jan 2nd, 2017 From: http://sitestree.com/?p=10341 Categories:Programming Code Examples, Java/J2EE/J2ME, AWT …

Continue reading

ChoiceTest #Programming Code Examples #Java/J2EE/J2ME #AWT Components

import java.applet.Applet; import java.awt.*; /*******/ public class ChoiceTest extends Applet { private Choice choice; public void init() { setFont(new Font("SansSerif", Font.BOLD, 36)); choice = new Choice(); choice.addItem("Choice 1"); choice.addItem("Choice 2"); choice.addItem("Choice 3"); add(choice); } } Note: Brought from our old site: http://www.salearningschool.com/example_codes/ on Jan 2nd, 2017 From: http://sitestree.com/?p=10337 Categories:Programming Code Examples, Java/J2EE/J2ME, AWT ComponentsTags:Java/J2EE/J2MEAWT Components …

Continue reading

ChoiceTest2 #Programming Code Examples #Java/J2EE/J2ME #AWT Components

ChoiceTest2.java /././././././././ import java.applet.Applet; import java.awt.*; import java.awt.event.*; /***********************/ public class ChoiceTest2 extends Applet implements ItemListener { private Choice choice; public void init() { setFont(new Font("SansSerif", Font.BOLD, 36)); choice = new Choice(); choice.addItem("Choice 1"); choice.addItem("Choice 2"); choice.addItem("Choice 3"); choice.addItemListener(this); add(choice); } public void itemStateChanged(ItemEvent event) { Choice choice = (Choice)event.getSource(); String selection = choice.getSelectedItem(); if …

Continue reading

Batton’s java #Programming Code Examples #Java/J2EE/J2ME #AWT Components

import java.applet.Applet; import java.awt.*; /././././././ public class Buttons extends Applet { private Button button1, button2, button3; public void init() { button1 = new Button("Button One"); button2 = new Button("Button Two"); button3 = new Button("Button Three"); add(button1); add(button2); add(button3); } } /././././././././. Note: Brought from our old site: http://www.salearningschool.com/example_codes/ on Jan 2nd, 2017 From: http://sitestree.com/?p=10333 Categories:Programming …

Continue reading

ButtonExample.java Uses the following #Programming Code Examples #Java/J2EE/J2ME #AWT Components

/./././././././././ # ButtonExample.java Uses the following classes: * CloseableFrame.java * FgReporter.java * BgReporter.java * SizeReporter.java ****************** ButtonExample.java ****************** import java.awt.*; import java.awt.event.*; /././././././././././ public class ButtonExample extends CloseableFrame { public static void main(String[] args) { new ButtonExample(); } public ButtonExample() { super("Using ActionListeners"); setLayout(new FlowLayout()); Button b1 = new Button("Button 1"); Button b2 = new …

Continue reading