Ok-I am doing homework out of a book and the instructions are to display an interface with 5 option buttons in a frame. When clicked, each button changes the background color of the frame. It proceeds to tell me to construct CheckboxGroup, use FlowLayaout and add the Checkboxes to the frame along with ItemListener.
It says addWindowListen er()method, write code for itemStateChange d() which uses the getState() method and nested if statements.
--I am so stuck. I hate this book, it does not have any example close to this as to how to do it and I am so so stuck-PLEASE HELP!
This is how far I have gotten. Anything I have tried past this has not compiled. -
import java.awt.*;
-
import java.awt.event.*;
-
-
public class ColorButtons extends Frame implements ItemListener
-
{
-
-
-
public static void main(String[] args)
-
{
-
}//end main arg
-
-
//declare variables
-
boolean answer = false;
-
-
//construct CheckboxGroup
-
CheckboxGroup sizeGroup = new CheckboxGroup();
-
Checkbox BlueBox = new Checkbox("Blue", true, sizeGroup);
-
Checkbox RedBox = new Checkbox("Red", false, sizeGroup);
-
Checkbox YellowBox = new Checkbox("Yellow", false, sizeGroup);
-
Checkbox PinkBox= new Checkbox("Pink", false, sizeGroup);
-
Checkbox GrayBox = new Checkbox("Gray", false, sizeGroup);
-
-
//add components
-
public void init()
-
{
-
add(BlueBox);
-
BlueBox.addItemListener(this);
-
add(RedBox);
-
RedBox.addItemListener(this);
-
add(YellowBox);
-
YellowBox.addItemListener(this);
-
add(PinkBox);
-
PinkBox.addItemListener(this);
-
add(GrayBox);
-
GrayBox.addItemListener(this);
-
-
-
}//end public void init
-
//this method is triggered by the user clicking an option button
-
public void itemStateChanged(ItemEvent choice)
-
{
-
-
}//end itemStateChanged
-
-
//if statements
-
}//end public class
-
1 2442
Im a little confused by what you have writen, try the HelloWorldFrame tatourial! it will help get you started. also, If you are looking for a good book try
Java A Beginners Guide by Hebert schilt! Its informative and has many examples!
Remeber you need to write a runable method in main!
Ok-I am doing homework out of a book and the instructions are to display an interface with 5 option buttons in a frame. When clicked, each button changes the background color of the frame. It proceeds to tell me to construct CheckboxGroup, use FlowLayaout and add the Checkboxes to the frame along with ItemListener.
It says addWindowListen er()method, write code for itemStateChange d() which uses the getState() method and nested if statements.
--I am so stuck. I hate this book, it does not have any example close to this as to how to do it and I am so so stuck-PLEASE HELP!
This is how far I have gotten. Anything I have tried past this has not compiled. -
import java.awt.*;
-
import java.awt.event.*;
-
-
public class ColorButtons extends Frame implements ItemListener
-
{
-
-
-
public static void main(String[] args)
-
{
-
}//end main arg //this should not be here!
-
-
//declare variables
-
boolean answer = false;
-
-
//construct CheckboxGroup
-
CheckboxGroup sizeGroup = new CheckboxGroup();
-
Checkbox BlueBox = new Checkbox("Blue", true, sizeGroup);
-
Checkbox RedBox = new Checkbox("Red", false, sizeGroup);
-
Checkbox YellowBox = new Checkbox("Yellow", false, sizeGroup);
-
Checkbox PinkBox= new Checkbox("Pink", false, sizeGroup);
-
Checkbox GrayBox = new Checkbox("Gray", false, sizeGroup);
-
-
//add components
-
public void init()
-
{
-
add(BlueBox);
-
BlueBox.addItemListener(this);
-
add(RedBox);
-
RedBox.addItemListener(this);
-
add(YellowBox);
-
YellowBox.addItemListener(this);
-
add(PinkBox);
-
PinkBox.addItemListener(this);
-
add(GrayBox);
-
GrayBox.addItemListener(this);
-
-
-
}//end public void init
-
//this method is triggered by the user clicking an option button
-
public void itemStateChanged(ItemEvent choice)
-
{
-
-
}//end itemStateChanged
-
-
//if statements
-
}//end public class
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Jeff Thies |
last post by:
I have this IE specific bit of code for finding the originating node:
var obj=window.event.srcElement;
How do I do that cross browser (Opera, NS, Safari...)? Is there a standard
DOM method?
I seem to recall NS worked something like this:
onmousedown=handleThat;
|
by: Derek Basch |
last post by:
Is it bad form to use the global window variable to reference an event
handlers window?
Like so:
function SortableTable() {
oFilterAdd = this.document.createElement("button");
oFilterAdd.setAttribute("type", "button");
oFilterAddText = this.document.createTextNode("Add");
|
by: Paul Bowman |
last post by:
Hi All
Java has a facility where you can send output to a DOS window using
System.out.println. This is useful while developing as you can see
what it going in your code.
Does .Net provide a similar facility? I notice that when a Windows app
runs there is an output window that contains messages from the
compiler etc. Is it possible to...
|
by: Jaggu |
last post by:
Hi ,
I need to close main window, once the child window succesfully opens
else main window to remain. In my case when I close the main window
immediately after the "window.open()" as mentioned below, both the main
and child disappears(this is due to pop up blocker) disappears
suddenly. I want to make the browser know if pop up blocks the...
|
by: Jonathan |
last post by:
Hi everyone,
I've got a link that launches a little AJAX application in a window.
Like this:
function launchListener()
{
var newWindow = window.open("listener.php", "newWindow",
"width=300,height=150");
}
| |
by: Daz |
last post by:
Hello everyone,
I would like to open a child window from the parent, and add an onload
event listener to the child window which will tell the parent when the
document has loaded. As far as I know, this shouldn't be an issue, but
I just can't get it to work. The script only needs to work with
Firefox/Mozilla, so XP code isn't an issue.
I...
|
by: gg9h0st |
last post by:
i saw a code refactorying onload event listener
window.onloadListeners=new Array();
window.addOnLoadListener=function(listener) {
window.onloadListeners=listener;
}
why declare the onloadListeners, addOnLoadListener below window?
|
by: =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= |
last post by:
I'm doing a web app in VB/Dot Net 2.0. I'm probably a bit rusty and I have
no experience using the repeater control.
I have a user control I've created with multiple properties. I've created a
test page and I've managed to bind the usercontrol to a repeater and display
some data in the following fashion:
<asp:Repeater ID="Repeater1"...
|
by: matheussousuke |
last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails.
The goal is: Make it send the email with the URL http://mghospedagem.com/images/controlpanel.jpg
instead of
http://mghospedagem.comhttp://mghospedagem.com/images/controlpanel.jpg
As u see, there's the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| | |