|
-
October 27th, 2009, 09:10 AM
#1
Mobile Development
I have a mobile device running WM 5, and have successfully ported over a java application (.jar) which ran. To my dismay, I am not seeing the full application due to the physical size and lack of scrollbars. Where are the scrollbars? Shouldn't they be automatic since everything isn't shown within the display screen size?
Another thing, since I'm working with a mobile, is there anyway to adjust the size of each component? That way I can make things more compact and won't have to rely on the scrollbar so much??
...thanks for any help gurus. (I'm trying to make it work)
-= the best is yet to come =-
-
October 27th, 2009, 11:21 AM
#2
Re: Mobile Development
I'm going to give you a general answer since I don't do much development at all with Swing or AWT.
http://java.sun.com/javase/6/docs/ap...t/Toolkit.html
Code:
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
From there, you know what you have to work with, so I would think that the root frame is always created / adjusted to fit the maximum size of the window, and all subcomponents that you add from there-on-in are percentage based to handle the resize.
I'm not sure if you would need a listener for when a screen size is modified (windows mobile may add it's own frames around the screen like with IE when you press the 'menu' button), but you may want to handle that somehow as well.
Not sure about your scrollbars, but if I remember correctly, there is a property on a component to display scrollbars always, never, or if required. You might want to look into that.
------
If you are satisfied with the responses, add to the user's rep!
-
October 27th, 2009, 03:18 PM
#3
Re: Mobile Development
Have you tried using a scroll pane to give you scroll bars ?
Good teaching is more a giving of the right questions than a giving of the right answers...
J. Albers
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
October 28th, 2009, 02:47 PM
#4
Re: Mobile Development
@Deliverance
yea man, I came across getScreenSize() already. What gets me, when I run the app on my local computer, it seems to grow just as big as my widescreen monitor, no problem. But when I import the file to my mobile device, I only see part of what I think should be there. I fear my components are just too big to be display correctly and thus stretching out my view passed the screen size.
@Dlorde
Actually, I did just discover JScrollPane and ScrollPaneLayout late last night. I'm playing with a small example now, but I haven't wired it up to my own code just yet. The problem I'm having is that JScrollPane uses a BorderLayout and what I created uses GridBagLayout. Since I'm just beginning with Java, I have to redo my GUI on a BorderLayout and/or get everything on a ScrollPaneLayout (I don't know if thats one of the same or not).
-= the best is yet to come =-
-
October 28th, 2009, 03:34 PM
#5
Re: Mobile Development
Make sure there isn't a minimum size set on these components that you have to override.
------
If you are satisfied with the responses, add to the user's rep!
-
October 28th, 2009, 04:20 PM
#6
Re: Mobile Development
 Originally Posted by capitolc
The problem I'm having is that JScrollPane uses a BorderLayout and what I created uses GridBagLayout. Since I'm just beginning with Java, I have to redo my GUI on a BorderLayout and/or get everything on a ScrollPaneLayout (I don't know if thats one of the same or not).
Try putting your GridBagLayout stuff into a JPanel, and then putting that into the scroll pane (it should default to the center area which is sizeable in all directions). The GridBagLayout panel should size itself to its contents, and the scroll pane should display scroll bars if the panel is too large.
Computer Science is a science of abstraction -creating the right model for a problem and devising the appropriate mechanizable techniques to solve it...
A. Aho and J. Ullman
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
November 6th, 2009, 10:08 AM
#7
Re: Mobile Development
... thanks Dlorde, got it where my srcollbar shows up just as you suggested.
For another question/concern. For anybody with java development on a mobile device, I've included an JPG to a JLabel for display. I run my app on my laptop and it came up no problem. When I moved everything of my mobile device, the image doesn't appear. Any thoughts? (I have yet to try a GIF/BMP/PNG image yet - thats next)
Speaking of things not showing up, most of the time when I launch my app, non of my componets show up at first. I have to resize my window for everything to appear. What gives? It happens more times than not, but I need to counter-act this. Is there like a paint.refresh() in java?
-= the best is yet to come =-
-
November 6th, 2009, 11:29 AM
#8
Re: Mobile Development
 Originally Posted by capitolc
Speaking of things not showing up, most of the time when I launch my app, non of my componets show up at first. I have to resize my window for everything to appear. What gives? It happens more times than not, but I need to counter-act this. Is there like a paint.refresh() in java?
All the components should show up every time if you've coded it right. Do you call pack() on the top-level frame before you call setVisible(true) ?
There are methods to repaint the components - validate() will recursively layout and repaint all that need painting, and repaint() will paint an individual component, but you should only need them if you change something (add or remove a component, or custom paint a component) while the GUI is displayed.
The outcome of any serious research can only be to make two questions grow where only one grew before...
T. Veblen
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
November 12th, 2009, 11:33 AM
#9
Re: Mobile Development
I wonder if running my jar executable through a 3rd party is causing my errors on my mobile device. The application is called Mysaifu JVM. Can you recommend another JRE I can use for Windows Mobile 5.0?
my problem is still, the image file that I have is not showing up. I tried bmp/jpg/gif/png formats, but nothing. The image shows up fine when I run it from my computer, but never on my mobile device. I also tried shrinking down the image to a 100x85 - no luck. I placed the image on another JPanel, then attach that one to my main -no luck.
This is starting to get frustrating, but do yu have any ideas?
-= the best is yet to come =-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|