BUG Community

Welcome! Log In

Forums Recent Posts

Subscribe to Recent Posts 12,499 posts found

Apr 5, 2008 2:12pm
johnkzin 9 posts

Topic: BUGbase / Physical Size

Usually tech specs pages list the physical dimensions of the unit … but I didn’t see them on the bugbase product page.

Anyone know them?

Apr 2, 2008 1:39pm
Medium kschultz 107 posts

Topic: Java / Graphics Question

jconnolly


Kschultz,

Your apps are great! With the physical BUG now available, it's important to ensure as much contunity in behavior between the Virtual BUG and physical BUG. Sometimes I wish there was a red "terminate application" square somewhere on the physical BUG. :wink:

I've put up a sample application for how to use Anonymous Inner Classes and WindowAdapter/Listener, MouseAdapter/Listeners on BugNet for reference.


Ha, well at the very end of my time in the office I got the apps going on a real BUG but at the time it was more WOW IT LOADS than worrying about details. I plan to go back and edit all my apps for things like loading from the menu and exiting nicely when I know more about the best way to do it. I guess a "managing application lifecycle/playing nice with other apps" page on the wiki would be a good idea.
Apr 2, 2008 10:28am
Medium jconnolly 285 posts

Topic: Java / Graphics Question

kschultz
Thanks John,

I am far from an authority on AWT, my GUI programming was all Qt/C++ and GTK+/C++ prior to the BUG, but Sun has a lot of good reference material, if only I took the time to read it!


Kschultz,

Your apps are great! With the physical BUG now available, it's important to ensure as much contunity in behavior between the Virtual BUG and physical BUG. Sometimes I wish there was a red "terminate application" square somewhere on the physical BUG. :wink:

I've put up a sample application for how to use Anonymous Inner Classes and WindowAdapter/Listener, MouseAdapter/Listeners on BugNet for reference.
Apr 2, 2008 10:04am
Medium kschultz 107 posts

Topic: Java / Graphics Question

Thanks John,

I am far from an authority on AWT, my GUI programming was all Qt/C+ and GTK/C++ prior to the BUG, but Sun has a lot of good reference material, if only I took the time to read it!

Apr 2, 2008 6:19am
Medium jconnolly 285 posts

Topic: Java / Graphics Question

amormachine
Thanks for the sample code!

I've got it up and running and have been playing around with it for a bit now. FYI: Eclipse didn't like a few lines like involving packaging and importing, so I commented them out.

I have two quick questions for you though ...

1. When I run the code in Eclipse, the frame pops up as it should ... However, when I try to x-it out, it wont go away. I've had to resort to Ctrl-Alt-Delete. Why is that?

2. I can't seem to figure out how the paint method it ExampleCanvas is being called! I've looked everywhere, but I never see it called, not even in the constructors ... I must be missing something simple, what is it??

Thanks again!


Amormachine,

You raise a good point about responsible AWT and OSGi bundle programming. If by closing the Frame you mean to terminate the application, you must express this programmatically. The default behavior of a Frame object when closed is to do nothing. To change this, you must override and flesh out the relevant methods from the WindowAdapter interface. Picking up on Kevin's code, here is what that would look like:


package canvastest.app;

import java.awt.Frame;
import java.awt.event.WindowAdapter;
import canvastest.app.ExampleCanvas;

public class CanvasTestMain {

/**
* @param args
*/
public static void main(String[] args) {
createUI();
}

private static void createUI() {
Frame frame = new Frame("CanvasTest");
frame.setSize(320, 240);
frame.setResizable(false);

ExampleCanvas canvas = new ExampleCanvas(frame);

frame.add(canvas);

frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {

frame.dispose();
//do some happy ungetting of services
//and other tidying up here, before exiting.
}
});


frame.show();
}

}



For more information about WindowListener, WindowEvent, WindowAdapter see some code samples here:

http://www.exampledepot.com/egs/java.awt/pkg.html


The code addition above uses anonymous inner classing, which can be very convenient for GUI programming. Instead of laboriously defining classes that extend the abstract classes and override the relevant methods, or worse, implementing an interface and overriding all the methods for each event handler (MouseListener, MouseMotionListener, etc), you may define it right within the declaration itself. This practice is very common in GUI programming. Most GUI Builders do this in code generation too.

See a nice lecture at Stanford (PDF) for a pretty decent overview of anonymous inner classing in Java:

www.stanford.edu/class/cs108/handouts061/17AnonymousInner.pdf

I should also note that calling System.exit(0) from within any Bundle is bad news! This makes a system call which in turn terminates the entire VM process on the host OS. While this may be ok for the Virtual BUG, this would be very unkind to the other OSGi bundles running concurrently with your own.

Lastly, it may be best not to hard-code the Frame size in your application. Not all LCD resolutions are the same, there is an LCD module in the pipes that would stretch nearly the entire width of the physical BUG!

Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
frame.setSize((int)d.getWidth(). (int)d.getHeight());


I'm working on setting up a Wiki for Java tips and suggestions for BUG coders. I'll be sure to announce when it's up.
Apr 2, 2008 1:13am
User_img_not_found_05_med enicky 24 posts

Topic: Official Updates / BUG+EDU details live on the Web!

Is this also applicapble for international schools ?

I mean , schools located in Europe ? :)

Do you have any more info regarding international shipment ?

Thanks!

Nicky

Apr 1, 2008 11:41pm
jtoeman 57 posts

Topic: Official Updates / BUG+EDU details live on the Web!

From the blog:

I was really searching for a good title for this post. It ranged from "inauguration" to "freshmen orientation" but none fit that well. Then I remembered that it was the end of Spring Break and voila! But now for the important news - we've released all the details of BUG+EDU on the website. Please take a look and give us your thoughts. We'd love to hear your comments on ways you think the program can expand and grow in the future.

First time hearing about BUG+EDU? No problem, I'll take a moment to explain...

In our opinion, children of all ages represent more creative, original thinking that can possibly be harnessed. When I was young I envisioned a future with all moving sidewalks, and remember sketching out how they'd work (intersections are tricky!) and thinking it through to the nth detail. Now, that's not completely true, since the one topic that never really crossed my mind were the economics of the situation.
Which is an unfortunate reality of technology innovation - it tends to be a bit pricey relative to allowances and after-school jobs.

The amazing thing for "kids these days" is the power of computers and the Internet. They both provide vast opportunities to create new software, applications and web sites. But all those opportunities are isolated to the digital realm. Hardware invention/innovation remains frustratingly out of reach for all but the most intrepid youth. We aim to change that.

BUG+EDU (again, details are all here) is a series of programs to not only get discounted BUGs to interested students, but also provide free units to educational institutions, help participate in creating new class curricula, and sponsor on-campus events and demonstrations of the platform in action. We've tried to offer a wide enough range of programs to help virtually any type of school, teacher, or student, but if there's something that somehow has slipped through the cracks, please let us know! In the meantime, good luck on finals!
Apr 1, 2008 10:19pm
Medium kschultz 107 posts

Topic: Java / Graphics Question

Here is a good reference on the paint method and updating in AWT. I’m working on casting a bunch of BUGs around the screen and updating them.

http://java.sun.com/products/jfc/tsc/articles/p…

I have to say that my example is not exactly their perfect use case, but I’m working on it. They say that you should not call the paint class explicitly for a number of reasons (basically, it can fail) and use the repaint() method. That brings up the point of breaking up what you are drawing into objects. It would be tempting to just throw it all in as one Canvas object that needs to get drawn, but then each time it needs to be updated, everything needs to be redrawn. If you make it a number of objects then only the updated objects need to be repainted which hopefully will reduce flicker. Now I’m thinking should each BUG be an object or should I make an object that paints all of them like I did for the gridmarkers? If they are all to be updated every time, then one object is the best route for minimum overhead, but if only some are going to be updated each time than making each one an object would be better. That is kind of up to you.

Apr 1, 2008 10:11pm
Medium kschultz 107 posts

Topic: Java / Graphics Question

The paint method in ExampleCanvas gets called with the frame.show(); line in the main method. Every component that you add to a container gets its paint method called then. Even though Eclipse likes to cross that line out as depreciated, it is not and you need that line.

As for stopping the window, not sure, but if you hit the red square on the console in Eclipse it will close easily.

The packaging depends on how you setup your project. I like to make things broken up into a lot of packages because I like to reuse my code as much as possible, I’d rather write twice as much if I can use it again because no matter how one off a project I think it is, I always seem to use some of it later.

Apr 1, 2008 9:59pm
amormachine 6 posts

Topic: Java / Graphics Question

Thanks for the sample code!

I’ve got it up and running and have been playing around with it for a bit now. FYI: Eclipse didn’t like a few lines like involving packaging and importing, so I commented them out.

I have two quick questions for you though …

1. When I run the code in Eclipse, the frame pops up as it should … However, when I try to x-it out, it wont go away. I’ve had to resort to Ctrl-Alt-Delete. Why is that?

2. I can’t seem to figure out how the paint method it ExampleCanvas is being called! I’ve looked everywhere, but I never see it called, not even in the constructors … I must be missing something simple, what is it??

Thanks again!

Powered by Community Engine

Top
Login