473,398 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

linking frames

9
Hi I need to create two frames in java. One that is a color palette and one that you can load an image into. Then when you click on one of the colors in the color palette frame, you have to be able to draw in that color in the other frame. How can I link these two frames so that the color can be used for drawing???

thanks
Jul 23 '07 #1
3 1415
r035198x
13,262 8TB
Hi I need to create two frames in java. One that is a color palette and one that you can load an image into. Then when you click on one of the colors in the color palette frame, you have to be able to draw in that color in the other frame. How can I link these two frames so that the color can be used for drawing???

thanks
When a color is selected just do a g.setColor and the set the color that was selected.
Jul 24 '07 #2
JosAH
11,448 Expert 8TB
Hi I need to create two frames in java. One that is a color palette and one that you can load an image into. Then when you click on one of the colors in the color palette frame, you have to be able to draw in that color in the other frame. How can I link these two frames so that the color can be used for drawing???

thanks
I normally build a few interfaces for that purpose. Your color palette wants to
set a selected colour; it needs a SelectedColour object for that; here it is:

Expand|Select|Wrap|Line Numbers
  1. public interface SelectedColour {
  2.    public void setSelectedColour(Color colour);
  3.    public Color getSelectedColour();
  4. }
  5.  
Your other frame needs a colour to be selected so it should implement the
interface above; as you wrote it's a JFrame, so here goes:

Expand|Select|Wrap|Line Numbers
  1. public YourFrame extends JFrame implements SelectedColour {
  2.    private Color colour= Color.BLACK; // default value
  3.    ...
  4.    // interface implementation
  5.    public void setSelectedColour(Color colour) { this.colour= colour; }
  6.    public Color getSelectedColour() { return colour; }
  7. }
  8.  
Your palette object couldn't care less that the SelectedColour object is a JFrame,
as long as it can set a selected colour. The above scenario takes care of it.

Just pass YourFrame as a (constructor?) parameter to your palette object.

kind regards,

Jos
Jul 24 '07 #3
r035198x
13,262 8TB
I normally build a few interfaces for that purpose. Your color palette wants to
set a selected colour; it needs a SelectedColour object for that; here it is:

Expand|Select|Wrap|Line Numbers
  1. public interface SelectedColour {
  2.    public void setSelectedColour(Color colour);
  3.    public Color getSelectedColour();
  4. }
  5.  
Your other frame needs a colour to be selected so it should implement the
interface above; as you wrote it's a JFrame, so here goes:

Expand|Select|Wrap|Line Numbers
  1. public YourFrame extends JFrame implements SelectedColour {
  2.    private Color colour= Color.BLACK; // default value
  3.    ...
  4.    // interface implementation
  5.    public void setSelectedColour(Color colour) { this.colour= colour; }
  6.    public Color getSelectedColour() { return colour; }
  7. }
  8.  
Your palette object couldn't care less that the SelectedColour object is a JFrame,
as long as it can set a selected colour. The above scenario takes care of it.

Just pass YourFrame as a (constructor?) parameter to your palette object.

kind regards,

Jos
A neat implementation indeed.
Jul 24 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: David Hayes | last post by:
I tried finding an answer on http://www.quirksmode.org/ without success. I am attempting a complicated Frames structure. I have made it work in IE, but not Netscape. I begin with three...
33
by: randau | last post by:
Linking to a Targeted Browser Window I'd like to open reference links to other web sites in a separate browser window from the browser window hosting my own web site pages. The Link Target...
0
by: Tom | last post by:
Access97 I have an Excel worksheet that contains seven graphs. In my application I have seven subreports in an unbound report. In each subreport I Paste-Linked one of the graphs in the Excel...
3
by: Ken | last post by:
I have a win 2000 database of autographs and scanned photos. They are in the SAME directory. In the table, my "ImagePath" text field shows JUST the image name (i.e. "blank.jpg"). I have an image...
0
by: gasturbtec | last post by:
please help im new at access programming and i just got this project dropped in my lap because the old programmer quit. i've been doing ok so far but now i need to add code to an existing database...
16
by: Thomas Maier-Komor | last post by:
Hi everybody, I have a problem with a certain link pattern that gets resolved wrong in the IE, but works find on Firefox. Maybe somebody has an idea, how to work around it. I have an .html...
2
by: Pepsicola27 | last post by:
Hi folks, I've just recently dived into css and I'm stumped. Coming from the HTML world, I used to create frames with the menu on the left, header on top, content on center/right. My menu...
2
by: saikatkolkata | last post by:
I had been searching ways in net how to connect two frames... my prob is...see i hav a screen with two frames n on the left frame i have a tree view. on selecting a tree node...some relevant info....
4
by: naveenmurthy | last post by:
Hello All, I have created a .mht file in following format. 1. The .mht file contains following htmls. a. MHTLinkingProblem.html b. Left.html c. Right.html d. Start.html
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.