Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2008

Tip: Looking for answers? Try searching our database.

How best to keep code and gui separated but harmonious

Thread view: 
RichT - 29 Feb 2008 18:50 GMT
Hello,

I am wishing to create an image model class and will need some way to
display images.

I know that JFrame, JPanel and Canvas support displaying images and are
ideal candidates.

Rather than put all the code for image related functionality in one of
these components, I want to be able to create an image model class
separately taking one of these components or even a subclass of these
components but only this range of components and perform operations on
it I guess like an MVC but only two classes not three.

So as an example I have JFrame but do not want to display the image
directly on it but instead want to use a JPanel or a Canvas inside a
scroll pane and have my image model class perform the operations on the
JPanel or Canvas or subclass of.

So I know that the image model class would take a reference to the
JPanel, Canvas or a subclass of these but nothing else and the JFrame
would have a reference to the image model class.

Selecting menu or button items from the JFrame would invoke a command,
passed to the image model class which would execute the command and
apply changes to the JPanel, Canvas or subclass of one of these.

How would I even start I have read information on Generics and
Interfaces and can see either of these could be used but not sure where
to start.

I am not trying to create a photoshop clone :) but want basics like zoom
in out and area, rotate and flip. In time I will probably add new image
related functionality, but don't want to be tied to a JPanel or a Canvas
or anything, especially if a new component appears in the future which
maybe better suited?

I hope someone can understand what I am trying to achieve here I sort of
do but it is still a bit hazy and vague and not sure where to start or
how to start.

Thanks
Rich
Stefan Ram - 29 Feb 2008 19:25 GMT
>So as an example I have JFrame but do not want to display the
>image directly on it but instead want to use a JPanel or a
>Canvas inside a scroll pane and have my image model class
>perform the operations on the JPanel or Canvas or subclass of.

 In MVC, the model does not act on the view, because
 of the separation via the observer pattern.

 The model only sends a message to notify the componente of the
 changes. It does not tell the component what to do.

>How would I even start I have read information on Generics and
>Interfaces and can see either of these could be used but not
>sure where to start.

 Interfaces (and to some extend, type arguments) are
 fundamentals of Java one always needs.

>I hope someone can understand what I am trying to achieve here I sort of
>do but it is still a bit hazy and vague and not sure where to start or
>how to start.

 You can read about the Swing architecture.

http://java.sun.com/products/jfc/tsc/articles/architecture/
DBloke - 01 Mar 2008 13:39 GMT
> http://java.sun.com/products/jfc/tsc/articles/architecture/

Thanks, I always believed swing was MVC too and referring back through
my lecture notes so did the tutors, or I misunderstood at the time :)
Jeff Higgins - 29 Feb 2008 20:29 GMT
> Hello,
>
[quoted text clipped - 4 lines]
> do but it is still a bit hazy and vague and not sure where to start or how
> to start.

You might have a look at:
G - 2D Graphics Library and Rendering Engine for Java
Its author has graciously provided a free of charge
LPGL licenced easy to use and understand, with source.
<http://geosoft.no/graphics/>
DBloke - 01 Mar 2008 13:36 GMT
> You might have a look at:
> G - 2D Graphics Library and Rendering Engine for Java
> Its author has graciously provided a free of charge
> LPGL licenced easy to use and understand, with source.
> <http://geosoft.no/graphics/>

Thanks


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.