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 addWindowListener()method, write code for itemStateChanged() 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 2434
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 addWindowListener()method, write code for itemStateChanged() 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?
...
|
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");...
|
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...
|
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...
|
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",...
| |
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
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...
| | |