 |
 |
Index ‹ java-programmer
|
- Previous
- 1
- Java 5.0 released
http://news.com.com/New+Java+looks+to+shake+up+desktop/2100-1007_3-5389888.html
- 1
- stdout and stderr don't occur sequentially in Eclipse and NetbeansZelluX wrote:
> But System.err is unbuffered, so I don't think it will have any effect
> to flush after every write.
There is nothing in the Javadocs to indicate that System.err is unbuffered.
Like System.out, System.err is a java.io.PrintStream. The docs for
PrintStream imply that instances are buffered, else the flush() method would
be meaningless. So it is not accurate, or at least not safe to say that
System.err is unbuffered.
That leaves auto-flushing. Nothing in the Javadocs for System.err indicates
that it's created with autoFlush on. Did you check the source for your
particular flavor of Java to see if it is?
In my installation, the source shows:
setErr0(new PrintStream(new BufferedOutputStream(fdErr, 128), true));
Whaddaya know? System.err is buffered in my installation.
Sun Java JDK 1.6.0_10b25, 64 bit, Linux.
Are you quite certain that System.err is unbuffered in your Java installation?
--
Lew
- 1
- Calling own-constructors inside another constructorHi all,
Inspecting some pieces of code from someone I found things like this:
class A {
private String id = "";
public A() {
super();
}
public A(String id) {
this.id = id;
}
}
class B extends A {
public B() {
this(""); <-------------------- HERE!
}
public B(String id) {
super(id);
}
}
Inside constructor B() it's calling a constructor. Could this cause some collateral or strange problems?
I know it's nonsense because id attribute it's being initialized by default to "", but I'd like to know if
also is a problem.
- 2
- 2
- Problem with focus on JListHi!
I got 2 JLists . I doubleclick an item to display it's details.
This works fine so far, but:
When I select an item in JList1 and in JList2 the Mouselistener doesn't
know from which JList he should get the item.
So I had the idea that when you select an item in JList1 JList2 should
loose all selections.
But I just don't get it done.
any ideas?
- 2
- J2EE architecture questionHello.
Iv read a spec from a firm which wants to build a J2EE application,
but the application is not supposed to be web based. The reason for
this is mostly a very complex UI.
From what ive read about the J2EE architecture ,the presentation layer
has always been servlets or jsp.
Is it a posibility / option to build a J2EE application without the
web based presentation layer?
- 3
- Special characters: how to read them into JTable?Hello everybody,
I would like to read String data from a file into a JTable (using Vectors).
These data contain special characters,
mainly Greek symbols. Ideally, I would also like to display subscripts as
well, if possible.
Does anybody knows how this can be done?
Thanks in advance,
Maria
- 3
- Home Made Videos X wife rides as he caresses bum (5.3 Mb) Just few link on some movies...
All just for you...
Download
>>>>> http://download-video.12w.net
>>>>> http://world-sex.urllogs.com
>>>>> http://video-sex.12w.net
CLICK FREE DOWNLOAD VIDEO PORN...
L
I
C
K
T
O
W
A
T
C
H
V
I
D
E
O
P
O
R
N
D
O
W
N
L
O
A
D
F
R
E
E
.
.
.
W
E
L
C
O
M
T
O
M
O
V
I
E
S
P
O
R
N
D
O
W
N
L
O
A
D
.
.
.
- 7
- Multiple thread handle problemhi
I am starting a no.of threads(500) from my application. i want to
start a new thread as soon as one of these threads dies.Any of the
thread could die at any particular time.Currently i am using a loop
to check which of the threads is alive and i can use join() for
others.I don't want to use a loop as that is eating a lot of memory.
Using synchronization method is it possible to block (creation of new
thread) untill one of the current thread dies.
Please help...
Anks
- 12
- File creation in the web applications' rootHello all.
Is it possible to get the path at which my application root is placed
by means of either the ServletContext or the ServletConfig object?
What I am trying to do here is to dynamically create a Javascript file
on the fly and put in the script directory of my web application. But
since the working directory in a web applications case is the
directory which contains the app servers' executable, any new file
created would be created there and I don't want to hard code the path
to my script folder. I want everything to be relative to the
applications' root as far as possible.
Can it be done without any special configuration, the way I can get a
resource present in the application root by the getResource() method?
Any kind of help would be greatly appreciated.
Regards,
sasuke.
- 14
- list box values to be allignedhi,
my list box in the html page contains list box with values. these
values inturn have subvalues and I have to allign the child values to
right so that i can know the parent of the values. how can I do that.
list values should look something like this...
(suppose u have a list box with the state names in usa. the cities of
the states would be the child elements and the state names would be the
parent values)
ALABAMA
Abbeville
Huntsville
Birmingham
Montgomery
......
ALASKA
Anchorage
Tucson
.....
.......
........
........
Urgent can someone help pls. I can use java script or any java
technology
thanks..
- 14
- china whole sale nike air force ones low cut af1 sneakers,ugg bootsDiscount Coach Sandals, Dior Sandals, Prada Sandals, Chanel Sandals,
Versace Sandals, Crocs Sandals, Women's Sandals Men's Slippers From
China
Discount, Prada Sunglasses, Discount, D&G Sunglasses, Discount,
Fendi
Sunglasses,Discount,Burberry Sunglasses Discount, Chanel Sunglasses
Discount, LVSunglasses Discount, Dior Sunglasses Discount, (G U C C
I ) Sunglasses Discount, Armani Sunglasses Discount, Versace
SunglassesDiscount, A&F Sunglasses Discount, LV Sunglasses
For more products pls visit:
http://groups.google.com/group/sci.engr.television.broadcast/browse_thread/thread/6eb9bed7645ab589/8b1c58a3a2cf0d19
- 14
- how to fire JTree child node eventI have a JTree where each node displays a specific view when selected.
I'd like to somehow fire an event to default the app which view to
display when opened.
How do I fire an event for a JTree as if the user clicked on a specific
child node?
- 14
- Great time in FranceHello
I had a fantastic time in France, hope to visit again soon.
I found a holiday cottage from these guys www.looktogo.co.uk
Regards,
Dancer: ).
- 15
- fixing image sizeI realise there have been several posting on this subject already.
However, despite these, I still can't quite work out how to do this.
I need to take the image from a file (.gif .jpg etc), ensure that the
entire image fits on a JPanel of some size, then put this JPanel onto
another Jpanel.
From what I could gather, it looked like I had to extend JPanel and
override paint(). The problem comes when I try to use drawImage().
Here's the code.
//relevent imports
public class Picture extends JPanel
{
private String fileName;
/** Creates a new instance of Picture */
public Picture(String file)
{
fileName=file;
}
public void paint(Graphics g)
{
super.paintComponent(g);
}
}
|
| Author |
Message |
Rv5

|
Posted: 2004-1-24 7:58:00 |
Top |
java-programmer, Where Does the Code Go?
I have a good programming practice question. Just for fun, Ive taken on a
side project that will help a teacher friend of mine work out grades. I
want a GUI interface that will store and retrieve grading info. So Im
hoping someonecan walk me through my class structure. My biggest question
regards whether or not it is good programming practice to have data objects
as members of my GUI class or if it should be done another way? I have my
main class which calls the GUI class. For now in my most basic skeleton, I
have a very simple student class, contains has a grade class. How should
these classes be arranged?
My first thought was have student a member of the GUI class. Say I have a
form with nothing more then two text fields for name and grade, and a
button. When I click the button, I want to store the the textfield data in
the student/grade classes. I can do that fine if student is a member of the
GUI class, but for some reason Im uncomfortable with this design. It seems
the GUI should be design only, no data access code in there. Eventually I
want to add database connection objects to this model for permanent student
data storage and would need to know where those would be called from as
well. So what do you guys think?
Classes:
Main
Gui
Student -> Grade
How to arrange?
Thanks
Rv5
|
| |
|
| |
 |
Missaka Wijekoon

|
Posted: 2004-1-24 8:28:00 |
Top |
java-programmer >> Where Does the Code Go?
my thoughts only,
The GUI is intepretation of data.
The student related classes should be data centric.
In other words data and presentation should be seperated (kind of like
the way xhtml/xml and css are evolving.)
Rv5 wrote:
> I have a good programming practice question. Just for fun, Ive taken on a
> side project that will help a teacher friend of mine work out grades. I
> want a GUI interface that will store and retrieve grading info. So Im
> hoping someonecan walk me through my class structure. My biggest question
> regards whether or not it is good programming practice to have data objects
> as members of my GUI class or if it should be done another way? I have my
> main class which calls the GUI class. For now in my most basic skeleton, I
> have a very simple student class, contains has a grade class. How should
> these classes be arranged?
>
> My first thought was have student a member of the GUI class. Say I have a
> form with nothing more then two text fields for name and grade, and a
> button. When I click the button, I want to store the the textfield data in
> the student/grade classes. I can do that fine if student is a member of the
> GUI class, but for some reason Im uncomfortable with this design. It seems
> the GUI should be design only, no data access code in there. Eventually I
> want to add database connection objects to this model for permanent student
> data storage and would need to know where those would be called from as
> well. So what do you guys think?
>
> Classes:
> Main
> Gui
> Student -> Grade
> How to arrange?
>
>
> Thanks
> Rv5
>
>
--
========================================================================
Missaka Wijekoon (a.k.a. Misk) email***@***.com
Sr. Software Engineer http://www.villageEdocs.com
VillageEdocs
========================================================================
|
| |
|
| |
 |
jhking

|
Posted: 2004-1-24 8:56:00 |
Top |
java-programmer >> Where Does the Code Go?
Like Missaka said, separate your data and presentation. When you build
the web version of this, or need to store the grades in an excel
spreadsheet you'll be glad you did.
Another way to look at things is that class descendants should follow
the 'is-a' rule. Car 'is-a' Vehicle, so a Car class is a descendant of
Vehicle, Porsche 'is-a' Car so Porsche is a descendant of Car. Another
rule is 'has-a' and that implies the object of 'has-a' is a member
variable. Vehicle 'has-a' Motor so Motor and Vehicle are not
ancestor/descendant, the Vehicle class has an attribute of Motor (I'm
ignoring the more complicated cases of bicycle (no motor) and Airbus Jet
(multiple motors) but you get the idea.
As Student 'is-a' Gui doesn't apply and Gui 'is-a' Student doesn't apply
neither should be a descendant of the other.
This also applies to Student and Grade Student 'has-a' Grade, not
Student 'is-a' Grade (or vice versa).
Missaka Wijekoon wrote:
> my thoughts only,
>
> The GUI is intepretation of data.
> The student related classes should be data centric.
> In other words data and presentation should be seperated (kind of like
> the way xhtml/xml and css are evolving.)
>
> Rv5 wrote:
>
>> I have a good programming practice question. Just for fun, Ive taken
>> on a
>> side project that will help a teacher friend of mine work out grades. I
>> want a GUI interface that will store and retrieve grading info. So Im
>> hoping someonecan walk me through my class structure. My biggest
>> question
>> regards whether or not it is good programming practice to have data
>> objects
>> as members of my GUI class or if it should be done another way? I
>> have my
>> main class which calls the GUI class. For now in my most basic
>> skeleton, I
>> have a very simple student class, contains has a grade class. How should
>> these classes be arranged?
>>
>> My first thought was have student a member of the GUI class. Say I
>> have a
>> form with nothing more then two text fields for name and grade, and a
>> button. When I click the button, I want to store the the textfield
>> data in
>> the student/grade classes. I can do that fine if student is a member
>> of the
>> GUI class, but for some reason Im uncomfortable with this design. It
>> seems
>> the GUI should be design only, no data access code in there.
>> Eventually I
>> want to add database connection objects to this model for permanent
>> student
>> data storage and would need to know where those would be called from as
>> well. So what do you guys think?
>>
>> Classes:
>> Main
>> Gui
>> Student -> Grade
>> How to arrange?
>>
>>
>> Thanks
>> Rv5
>>
>>
>
>
|
| |
|
| |
 |
Scott Ellsworth

|
Posted: 2004-1-24 9:00:00 |
Top |
java-programmer >> Where Does the Code Go?
In article <email***@***.com>,
"Rv5" <email***@***.com> wrote:
> I have a good programming practice question. Just for fun, Ive taken on a
> side project that will help a teacher friend of mine work out grades. I
> want a GUI interface that will store and retrieve grading info. So Im
> hoping someonecan walk me through my class structure. My biggest question
> regards whether or not it is good programming practice to have data objects
> as members of my GUI class or if it should be done another way?
I tend to go with Model-view-controller most of the time.
The model is the pure data, such as Student, Grade, Classroom classes,
plus whatever contains them. There are accessors to add students to a
classroom, and grades to a student. There also getters to get the data
back out. For example, the model might have methods like
"createStudent(String name)", "getStudent(String name)", and so forth.
The view might consist of a DisplayStudent window and a DisplayClassroom
window.
The controller knows of them both, and each knows of the controller.
The controller is told by the model when underlying data has changed,
and tells the view windows to update in return. Similarly, when someone
tweedles a field in the view, it is sent to the controller to pass on to
the model.
Your Main class would instantiate a controller, and then it might create
the DisplayStudent window and underlying Model, which is then passed to
the controller. You could also have the controller create both the
views and the models - both designs work.
This is almost certainly overkill for a quickie project like this, but
if you move towards a database, or a more fully featured app with more
than just one text field, then the added flexibility will help.
Scott
|
| |
|
| |
 |
Rv5

|
Posted: 2004-1-24 9:16:00 |
Top |
java-programmer >> Where Does the Code Go?
Ok thats a good example that I understand. Perhaps Ill need to do more
research, but if the GUI is a standalone class, how do I get the data from
the text fields to the student class when the button is clicked if the GUI
doesnt have a student object?
"jhking" <email***@***.com> wrote in message
news:busfq8$email***@***.com...
> Like Missaka said, separate your data and presentation. When you build
> the web version of this, or need to store the grades in an excel
> spreadsheet you'll be glad you did.
> Another way to look at things is that class descendants should follow
> the 'is-a' rule. Car 'is-a' Vehicle, so a Car class is a descendant of
> Vehicle, Porsche 'is-a' Car so Porsche is a descendant of Car. Another
> rule is 'has-a' and that implies the object of 'has-a' is a member
> variable. Vehicle 'has-a' Motor so Motor and Vehicle are not
> ancestor/descendant, the Vehicle class has an attribute of Motor (I'm
> ignoring the more complicated cases of bicycle (no motor) and Airbus Jet
> (multiple motors) but you get the idea.
> As Student 'is-a' Gui doesn't apply and Gui 'is-a' Student doesn't apply
> neither should be a descendant of the other.
> This also applies to Student and Grade Student 'has-a' Grade, not
> Student 'is-a' Grade (or vice versa).
> Missaka Wijekoon wrote:
> > my thoughts only,
> >
> > The GUI is intepretation of data.
> > The student related classes should be data centric.
> > In other words data and presentation should be seperated (kind of like
> > the way xhtml/xml and css are evolving.)
> >
> > Rv5 wrote:
> >
> >> I have a good programming practice question. Just for fun, Ive taken
> >> on a
> >> side project that will help a teacher friend of mine work out grades.
I
> >> want a GUI interface that will store and retrieve grading info. So Im
> >> hoping someonecan walk me through my class structure. My biggest
> >> question
> >> regards whether or not it is good programming practice to have data
> >> objects
> >> as members of my GUI class or if it should be done another way? I
> >> have my
> >> main class which calls the GUI class. For now in my most basic
> >> skeleton, I
> >> have a very simple student class, contains has a grade class. How
should
> >> these classes be arranged?
> >>
> >> My first thought was have student a member of the GUI class. Say I
> >> have a
> >> form with nothing more then two text fields for name and grade, and a
> >> button. When I click the button, I want to store the the textfield
> >> data in
> >> the student/grade classes. I can do that fine if student is a member
> >> of the
> >> GUI class, but for some reason Im uncomfortable with this design. It
> >> seems
> >> the GUI should be design only, no data access code in there.
> >> Eventually I
> >> want to add database connection objects to this model for permanent
> >> student
> >> data storage and would need to know where those would be called from as
> >> well. So what do you guys think?
> >>
> >> Classes:
> >> Main
> >> Gui
> >> Student -> Grade
> >> How to arrange?
> >>
> >>
> >> Thanks
> >> Rv5
> >>
> >>
> >
> >
|
| |
|
| |
 |
Jon A. Cruz

|
Posted: 2004-1-24 10:53:00 |
Top |
java-programmer >> Where Does the Code Go?
Scott Ellsworth wrote:
>
> I tend to go with Model-view-controller most of the time.
I prefer the more Java-style Model-View/Controller approach (where view
and controller are merged to a single entity).
>
> The model is the pure data, such as Student, Grade, Classroom classes,
Yes. I like that also
> For example, the model might have methods like
> "createStudent(String name)", "getStudent(String name)", and so forth.
This is where I'd go a little farther.
'name' being a plain String is probably limited. A name is a complex
thing with different parts. So instead of passing it as a single
monolithic String and parsing it back all over the place, I'd suggest a
'Name' class that does intelligent things with names.
That way you avoid problems with "Cruz, Jon", "Jon Cruz", "Jon A. Cruz",
etc.
> The controller knows of them both, and each knows of the controller.
This, in general, seems a bit off.
Usually a view knows only of a Model. The model class only knows of
object that have chosen to be notified of the model's updated, not of
specific view or controller classes.
Or I think we might be thinking of it the same, but describing it
differently.
To clarify: In the sense of "knowing", the model class only "knows" of
those who implement the model's listener interface and have registered
it. It knows nothing else of those classes. And it does not "know" of
views nor controllers in the sense that the model class does not import
any view or controller classes, nor should it probably even be in the
same package.
> The controller is told by the model when underlying data has changed,
> and tells the view windows to update in return.
Actually, the windows *are* the views (in the general use of the term)
> Similarly, when someone
> tweedles a field in the view, it is sent to the controller to pass on to
> the model.
And this is where I think a lot breaks down. Usually a "view" has no
fields, and a "controller" would be a widget that does the tweedling and
updates the model directly.
Views only reflect what state in the model is, controllers tweak the model.
A controller takes user input then tweaks the model. The model then
notifies listeners that it has changed. The views receive these
notifications from the model, then query the model and update their
appearance.
>
> Your Main class would instantiate a controller, and then it might create
> the DisplayStudent window and underlying Model, which is then passed to
> the controller. You could also have the controller create both the
> views and the models - both designs work.
This, also, is where I would disagree.
I'd think the Main class would instantiate a Model, then create a
View/Controller of that Model. For any non-trivial application, a few
models and a vew view/controllers for each would probably be made.
>
> This is almost certainly overkill for a quickie project like this
Again, I would disagree here. I'd say that a basic Model -
View/Controller separation would help just about any application.
Yes, it might take a bit longer before you saw the first things on the
screen, but usually the time to functional stage would be shorter.
|
| |
|
| |
 |
Jon A. Cruz

|
Posted: 2004-1-24 11:29:00 |
Top |
java-programmer >> Where Does the Code Go?
Rv5 wrote:
> My biggest question
> regards whether or not it is good programming practice to have data objects
> as members of my GUI class or if it should be done another way?
Probably not good practice to mix GUI and Data. At least not like that.
> I have my
> main class which calls the GUI class. For now in my most basic skeleton, I
> have a very simple student class, contains has a grade class. How should
> these classes be arranged?
I'd say maybe the following classes might help
Person
Student
Grade
Teacher
Class
Make those all pure data classes (Models)
Teacher and Student inherit from Person. Person has a name. I had
mentioned name before, and I think Person might be good to centralize
standardizing and looking up names.
Student could have a member that lists the student's classes. It could
also have a member that lists the grades for each class. One way would
be a Vector member to list Classes, and Hashtable for grades that could
use something from Class as a key.
> My first thought was have student a member of the GUI class. Say I have a
> form with nothing more then two text fields for name and grade, and a
> button.
Change your thinking.
:-)
Think of the data Model classes as the bones and muscle of your program.
And the GUI classes are the skin. Start by first thinking about the
abstract data and functionality. Then think of how to show it. Build the
muscle and bone, and then hang the skin on after.
|
| |
|
| |
 |
Jon A. Cruz

|
Posted: 2004-1-24 11:38:00 |
Top |
java-programmer >> Where Does the Code Go?
Rv5 wrote:
> Ok thats a good example that I understand. Perhaps Ill need to do more
> research, but if the GUI is a standalone class, how do I get the data from
> the text fields to the student class when the button is clicked if the GUI
> doesnt have a student object?
No:
public class StudentView extends JPanel
{
Hashtable grades;
String name;
Vector classList;
public StudentView()
{
grades = new Hashtable();
classList = new Vector();
...
Yes:
public class StudentView extends JPanel
{
Student student;
...
public StudentView( Student student )
{
this.student = student;
// Add a listener to student, etc.
...
}
...
Does that give you a hint for starting?
|
| |
|
| |
 |
Rv5

|
Posted: 2004-1-24 11:52:00 |
Top |
java-programmer >> Where Does the Code Go?
Yes, that will get me started. Very good, thank you.
"Jon A. Cruz" <email***@***.com> wrote in message
news:email***@***.com...
> Rv5 wrote:
> > Ok thats a good example that I understand. Perhaps Ill need to do more
> > research, but if the GUI is a standalone class, how do I get the data
from
> > the text fields to the student class when the button is clicked if the
GUI
> > doesnt have a student object?
>
>
> No:
>
> public class StudentView extends JPanel
> {
> Hashtable grades;
> String name;
> Vector classList;
>
> public StudentView()
> {
> grades = new Hashtable();
> classList = new Vector();
> ...
>
>
> Yes:
>
> public class StudentView extends JPanel
> {
> Student student;
> ...
>
> public StudentView( Student student )
> {
> this.student = student;
> // Add a listener to student, etc.
> ...
>
> }
>
> ...
>
> Does that give you a hint for starting?
>
|
| |
|
| |
 |
Patrick B. Haggood

|
Posted: 2004-1-24 18:02:00 |
Top |
java-programmer >> Where Does the Code Go?
Scott Ellsworth wrote:
> I tend to go with Model-view-controller most of the time.
>
> The model is the pure data, such as Student, Grade, Classroom classes,
> plus whatever contains them. There are accessors to add students to a
> classroom, and grades to a student. There also getters to get the data
> back out. For example, the model might have methods like
> "createStudent(String name)", "getStudent(String name)", and so forth.
>
Unless you abscribe to the belief that such accessors are evil:
http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html
( jury for me is still out on this one, but it does give me much to think
about).
|
| |
|
| |
 |
Chris Uppal

|
Posted: 2004-1-24 18:27:00 |
Top |
java-programmer >> Where Does the Code Go?
Rv5 wrote:
> My biggest question
> regards whether or not it is good programming practice to have data
> objects as members of my GUI class or if it should be done another way?
Just to add to what everyone else has said.
One rule of thumb for whether you have achieved a clean separation of concerns
is whether you can test the bits independently of each other.
In this case, I'd hope (if I were writing this) to be able to test my classes
that represent Students, etc, without having to write most of the GUI first.
In a more complicated project I'd also want to be able to the test the GUI
without having to write the final versions of the Student, etc, classes.
-- chris
|
| |
|
| |
 |
Scott Ellsworth

|
Posted: 2004-1-25 17:19:00 |
Top |
java-programmer >> Where Does the Code Go?
In article <email***@***.com>,
"Patrick B. Haggood" <email***@***.com> wrote:
> Scott Ellsworth wrote:
>
> > I tend to go with Model-view-controller most of the time.
> >
> > The model is the pure data, such as Student, Grade, Classroom classes,
> > plus whatever contains them. There are accessors to add students to a
> > classroom, and grades to a student. There also getters to get the data
> > back out. For example, the model might have methods like
> > "createStudent(String name)", "getStudent(String name)", and so forth.
> >
>
>
> Unless you abscribe to the belief that such accessors are evil:
That is a bit more radical an OO position than I usually take. Worth a
read, since there are times you want to break exposing your internal
implementation that way.
That said, if "what it means to be a Shape" is to have a center Point
and a float Area, then accessors for those make sense regardless of how
I architect the guts of it.
Scott
Java, Cocoa, WebObjects and Database consulting
|
| |
|
| |
 |
Scott Ellsworth

|
Posted: 2004-1-25 17:26:00 |
Top |
java-programmer >> Where Does the Code Go?
In article <email***@***.com>,
"Jon A. Cruz" <email***@***.com> wrote:
> Scott Ellsworth wrote:
[...]
> > Similarly, when someone
> > tweedles a field in the view, it is sent to the controller to pass on to
> > the model.
>
> And this is where I think a lot breaks down. Usually a "view" has no
> fields, and a "controller" would be a widget that does the tweedling and
> updates the model directly.
Fields in the TextField sense, not the "String name" sense.
> Views only reflect what state in the model is, controllers tweak the model.
>
> A controller takes user input then tweaks the model. The model then
> notifies listeners that it has changed. The views receive these
> notifications from the model, then query the model and update their
> appearance.
'Zactly, with the combined controller/view approach you favor.
If you have the controller as a seperate beast, then it is notified by
the model that changes have taken place, which it notifies views of,
which then query the controller for needed info, which query the model
in turn. Similarly, when views have a change to push to the model, they
push it to the controller, which forwards as needed.
The extra complexity of having the controller as a broker pays off when
the model and the views begin to drift apart in functionality. The
controller becomes the adapter between the two interfaces. This can
also be accomplished with strategies and the like, and should be if the
controller starts to become a hydra of code.
Scott
Java, Cocoa, WebObjects and Database consulting
|
| |
|
| |
 |
Chris Uppal

|
Posted: 2004-1-25 18:18:00 |
Top |
java-programmer >> Where Does the Code Go?
Scott Ellsworth wrote:
> > Unless you abscribe to the belief that such accessors are evil:
>
> That is a bit more radical an OO position than I usually take. [...]
>
> That said, if "what it means to be a Shape" is to have a center Point
> and a float Area, then accessors for those make sense regardless of how
> I architect the guts of it.
I think the idea is that accessors are conceived of as being a way of
reading/setting the value of an internal value. The example methods you cite
may be *implemented* that way, but there is nothing in the public contract of
the Shape object that means they have to be implemented that way. If the
methods are conceived as ways of passing information to or from an object then
they are not (by normal definitiion) "accessors" -- even if the Shape does
cache its area in an instance variable.
Which means that, oddly enough, you can't tell whether a method is "evil"
(assuming you subscribe to the view -- as I do) just by looking at the code!
It's the mindset of the designer that may be "evil", not the way the method is
implemented....
-- chris
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- remote databaseHello!
I'm quite new to Java. I'm making an MySQL interface. So my problem is:
Can I connect to a remote mysql database without having any additional
software running on that server ?
Is JDBC part of JVM ?
I know these are silly questions, but you would help me a great deal.
Thank you!
Darko
- 2
- what's wrong? my first simplest java program failed..I created a test.java file in D:\j2sdk1.4.2_04\bin>
and the content:
class
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
then I compile it:
D:\j2sdk1.4.2_04\bin>javac test.java
test.java:1: <identifier> expected
class
^
test.java:8: '{' expected
^
2 errors
D:\j2sdk1.4.2_04\bin>
my book tell me it would work well, what's wrong?
--
Your fault as a Government is My failure as a Citizen.
- 3
- Release build in EclipseDoes anyone know how to make a lean release build with Eclipse,
binaries without debugging info ?
- 4
- How to prevent the filechooser resolving symblic linksHello everybody
I am using a filechooser object to select files.
JFileChooser _fileChooser = new JFileChooser();
File[] selectedfiles = _fileChooser.getSelectedFiles();
for (int i =0 ; i < selectedfiles.length; i++) {
//path = selectedfiles[i].getCanonicalPath();
path = selectedfiles[i].getPath();
}
The _fileChooser.getSelectedFiles() returns already absolute path
names. So no matter if I call getPath or getCanocialPath I get the
abosolute path names.
But I want to display symbolic links as relative pathnames.
Is there a way to accomplish this?
Any help I will welcome.
Thanks in advance,
Zoran
- 5
- javap: fully qualified names for "new" statementsHello,
I'm using javap for my project.
Basically, what I'm interested in are the "new", "newarray" and
"anewarray" statements.
However, javap only outputs things like:
new #10; //class StringBuffer
but does not give me the fully qualified name.
Is there any way I could get to know this information?
Cheers,
Sebastien Marion
- 6
- I want to import ProductsHi
=20
1. We can get ready to buy clients for your products. We can bring such =
people, who are searching at google for following
keywords. They are ready to buy clients and they are searching these =
products to make a purchase. If they reach at your
site at this time, chances are very great that your site can make a sale =
to them.=20
keywords:=20
exporter of india
indian exporter
exporter from india
india's exporter
exporter of abc (abc is your product name)
abc exporter
abc manufacturer
indian abc exporter
2. We also offer you a 7 Days free trial. Get your free trial at =
http://www.yesiwillbuy.com/free-trial.htm?chetna
=20
3. For any further information, please let me know. I will be happy to =
help you. You can call at my=20
US marketing phone number at +1-727-565-1339 or you may call me at India =
at +91-93122-88917.
Or you can send me direct email. I usually reply emails within few =
hours. Please send us your contact
phone number and your desired time, and we will call you to help you =
with your first order.=20
regards
Miss Chetna(Certified by GOOGLE as Certified Google Adwords =
Professional)
Suggest Your Friends to Use - FREE Trial - No Obligation 7 Days Google =
Trial -=20
Start Getting Leads within 24 Hours for Your Products/Services
http://www.yesiwillbuy.com/free-trial.htm?Chetna =20
Jan16-08
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 7
- Shootout (startup)
>On Wed, 30 Apr 2008 08:00:38 -0700 (PDT), Isaac Gouy
<email***@***.com> wrote:
>Why don't you go through all...
startup benchmark...
http://shootout.alioth.debian.org/gp4/benchmark.php?test=hello&lang=all
Damn! C & C++ are killing java in this benchmark. Though I discovered
a trick that improves the speed somewhat and saves some face...
With n = 200 (i.e 200 startups in continuous order).
java hello
time: 23.433s
However, just adding the flag -XX:+AggressiveHeap
java -XX:+AggressiveHeap hello
time: 9.914s
that's a huge improvement.
- 8
- help adding items to JComboBox on the flyAnyone happen to see what I might be doing wrong. I'm trying to add
items to my
JComboBox on the fly as nodes are added to the tree. It's like this ...
1. User adds tree nodes to a tree.
2. Then user can select on another node elsewhere in the tree which
renders a JComboBox
and the items just added from step 1 are listed in this box.
I have a few problems ...
- after I select my item in the combobox, the combobox stays there. If
I then select on another node, the item in the combobox doesn't get
selected. It doesn't work where I just select an item and it closes up
and that item is selected.
- sometimes I get a null pointer exception in action performed (because
getSelectedIndex() in getCellEditorValue() returns a -1) which seems to
get called while the program execution is still in the
getTreeCellEditorComponent. This confuses me. Why's it returning -1
when there are items in my combobox?
Any help much appreciated.
(I hope I've got my code snippet here w/o any typos, I had to cut it
down)
----
public class TreeEditor extends AbstractCellEditor implements
TreeCellEditor
{
private JComboBox myComboBox;
public TreeEditor() {
myComboBox = new JComboBox();
myComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
TreePath path = jTree.getSelectionPath();
stopCellEditing();
Integer val = (Integer) getCellEditorValue();
myComboBox.setSelectedItem(val.intValue());
((MyUserObjectInfo)nodeInfo).setName(
myComboBox.getSelectedItem().toString());
node.setUserObject(((MyUserObjectInfo) nodeInfo));
jTree.getModel().valueForPathChanged(path, nodeInfo);
}
});
}
public Object getCellEditorValue() {
return new Integer(myComboBox.getSelectedIndex());
}
public Component getTreeCellEditorComponent(JTree tree,
Object value, boolean isSelected, boolean expanded,
boolean leaf, int row) {
// find the children of this node that were recently added ...
TreeModel tModel = jTree.getModel();
Object root = tModel.getRoot();
DefaultMutableTreeNode carRoot = (DefaultMutableTreeNode)
tModel.getChild(root, 0);
String nodeName = null;
if (myComboBox.getItemCount() > 0) {
myComboBox.removeAllItems();
}
// add children of another node into this combobox.
for (Enumeration e = carRoot.children(); e.hasMoreElements();)
{
DefaultMutableTreeNode carNode =
(DefaultMutableTreeNode)e.nextElement();
Object nodeInfo = carNode.getUserObject();
nodeName = ((MyUserObjectInfo)nodeInfo).getName();
myComboBox.addItem(nodeName);
}
if (myComboBox.getItemCount() > 0) {
myComboBox.setSelectedIndex(0);
}
return myComboBox;
}
}
- 9
- String and Char HelpI have a few questions but first here is my code.
public class CountVowels
{
public static void main(String[] args)
{
int vowel = 0;
int i;
char pos;
String String1 = "Event Handlers is dedicated to making your
event a most memorable one.";
int length = String1.length();
for(i = 0; i < length - 1 ; i++);
{
pos = String1.charAt(i);
if (pos == 'A' || pos == 'a' || pos == 'E' || pos == 'e' ||
pos == 'I' || pos == 'i' || pos == 'O' || pos == 'o' || pos == 'U' ||
pos == 'u') {
vowel += 1;
}
}
System.out.println("There are " + vowel + " vowels in this
String");
}
}
Question one is why does String1.length() return 70 when there are
only 69 chars. Second question is why does this code not count the
vowels in the String.
Thanks in advance
Robert
- 10
- help with java assignmentWas just hoping someone could shed a bit of light on how to approach
this assignment. It would seem we have to determine the value of a in
order to determine how many times the method m() is called, but there
doesn't seem to be enough information to determine a's value. Any tips
would be greatly appreciated...
Many Thanks
For each of the following snippets of code, give the number of times
method m() is called, with a brief explanation. Assume that a and b are
nonnegative integers.
Snippet A
for (int i = a; i < a*a; ++i) {
m();
}
int i = 0; int j = a;
while (i <= j) {
++i;
m();
--j;
}
Snippet B
For this one, first we define a method m1:
public static void m1(int a) {
for (int i = 0; i <= a*a; ++i) {
m();
}
}
Now the snippet:
m1(a*a);
Snippet C
for (int i = a; i != a + b; i += 2) {
for (int j = a/2; j > 0; --j) {
for (int k = 1; k < a; ++k) {
m();
}
}
}
Snippet D
for (int i = 0; i < a; ++i) {
for (int j = 148; j < i; ++j) {
m();
}
}
- 11
- best struts-jsp-servlet development tool?Hello,
We are going to develop a web based application that uses Oracle 9i
database at the beckend. We started with Oracle JDeveloper 10g. It
seems fine but it fails to meet our needs at some points. Can you
recommend another tool for us?
Thanks in advance
- 12
- Class.forname()Hello ,
I have a necessity to delete a jar file which is in the CLASSPATH.
But JVM locks it after a class.forName() call, even though the class
loaded is NOT in the JAR file I want to delete. ( I cannot remove the
JAR file from the CLASSPATH )
First of all is it possible?
Any help is appreciated
thanks in advance
- 13
- How to approachLuc The Perverse wrote:
...
>
> WAIT!
>
> I think I got it (I'm not meaning to imply that you didn't help) - and I
> didn't look at anything.
>
> Let's say there are NxN squares, and there are x number of moves.
>
> I can make the square x, y be represented as an integer 0..N * N - 1
>
> So I create a 2D array [N*N][x] of longs which will represent the sum of the
> number of unique paths to the given point.
...
You got it. There is an optimization that reduces the memory cost,
but you have a dynamic programming solution to the problem. And you have
the really big savings from exponential to linear increase in time and
memory as the number of moves increases.
> Hey thanks everyone. This is more than just a single problem or some points
> on a practice problem that doesn't matter anyway. I'm learning how to do
> this, and becoming a better programmer - and that is important to me.
> Learning new abstract concepts, and having exciting revelations is actually
> (though sadly) a bit of a rarity for me.
I think, more than ever after seeing this, that you would benefit from
reading a book on algorithm design.
Patricia
- 14
- Java will not workI have recently bought a new computer with windows XP and
internet explorer 6. Any page that i try to access that
contains java will not load the java. I have recieved
warnings like ". . .requires a java compatible browser to
run". I have searched the security options and can find
nothing that will help.
Do i have to download anything or change any options
to get java working?
Anon.
- 15
- You don't know anything ...Hello John Bailo , You wrote ,
" I know when someone is bilking his customers
for c++ code whose functionality should be written in
OpenCalc macros "
You comment re-proves :
1 _ You don't know anything about
programming for the desktop .
2_ You don't know anything about my customers ,
even thought I've explained them to you
a million times .
|
|
|