Category: FromSitesTree.com

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

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

TextAreas.java ************** import java.applet.Applet; import java.awt.*; /././././././,/././././ public class TextAreas extends Applet { public void init() { setBackground(Color.lightGray); add(new TextArea(3, 10)); add(new TextArea("SomenInitialnText", 3, 10)); } } Note: Brought from our old site: http://www.salearningschool.com/example_codes/ on Jan 2nd, 2017 From: http://sitestree.com/?p=10342 Categories:Programming Code Examples, Java/J2EE/J2ME, AWT ComponentsTags:Java/J2EE/J2MEAWT Components Post Data:2017-01-02 16:04:35 Shop Online: https://www.ShopForSoul.com/ (Big Data, …

Continue reading

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

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

Uses a FileDialog to choose the file to display #Programming Code Examples #Java/J2EE/J2ME #AWT Components

DisplayFile.java **************** import java.awt.*; import java.awt.event.*; import java.io.*; /** Uses a FileDialog to choose the file to display. *************** public class DisplayFile extends CloseableFrame implements ActionListener { public static void main(String[] args) { new DisplayFile(); } private Button loadButton; private TextArea fileArea; private FileDialog loader; public DisplayFile() { super("Using FileDialog"); loadButton = new Button("Display File"); …

Continue reading

Handling Events #Programming Code Examples #Java/J2EE/J2ME #AWT Components

*********************************** * ActionExample1.java Inherits from CloseableFrame.java and uses SetSizeButton.java. * ActionExample2.java Inherits from CloseableFrame.java. ********************************************************** ActionExample1.java ******************* import java.awt.*; public class ActionExample1 extends CloseableFrame { public static void main(String[] args) { new ActionExample1(); } public ActionExample1() { super("Handling Events in Component"); setLayout(new FlowLayout()); setFont(new Font("Serif", Font.BOLD, 18)); add(new SetSizeButton(300, 200)); add(new SetSizeButton(400, 300)); add(new SetSizeButton(500, …

Continue reading