how to setup this gui - java

Im having quite a difficult time setting up this GUI
As you can see in the picture i need to have several clickable items and i dont know how to do it. So i thought i could make one different VerticalFieldManager representing the white background. But it looks impossible to have more than two VerticalFieldManager over the main manager. So i thought i could use a LabelField and change the background color to white (it didnt work either) and on top of it put clickable labels and clickable textField but i dont get the background VerticalFieldManager to repeat it self and put itself under the previous one with a slight margin between them. Anyways, can you guys give me ideas on how to accomplish this GUI, what to use as background.
Thanks in advance and have a nice one.

I would suggest the following layout
Screen delegate should be VerticalFieldManager
Each item should be VerticalFieldManager as well
The body of the item itself should be RichTextField
The rest of the clickable elements you mentioned should be clickable Labels.
You will have to use HorizontalFieldManagers as well. One for the top panel and one for the bottom panel. Check the JustifiedHorizontalFieldManager from the advanced UI libarary.
As for clickable label - it is easy to implement one. Search SO for "[blackberry] clickable label". You can also check the BaseButtonField and BitmapButtonField provided in BlackBerry advanced UI library and available here.

Related

Change size of JFrame according to user selected image

I'm about to write a program using Java and i want it to have the next behavior:
Start with a small screen, just one button (i'm going for the JMenuBar) for the user to select a image file (a country or state map)
Once selected the image file, i'll need to resize the frame to the size of the selected image, and put the image as background.
when the user clicks somewhere inside the frame (click on a state or city) the program will have to create a visual object there, a circle, square or any form in that coordinates.
will need also a listener in those objects to know when they are clicked.
Summary: User has to select an image and trace a graph on it.
I am not asking for the code to do this. I would like to have some ideas about which components use to achieve this since i have been reading and there are plenty of ways to set the background image and stuff. But, considering the requirements, can you recommend me which components to use? I am a bit short of time since i've been given only about a week to code this, otherwise i would try all the alternatives by myself.
Some answer like:
"use a label to set the background and then resize the frame by this way: (some stuff) and then you can create a class extending from JLabel to create the circles with the listeners...." that would be enough help
I hope I was clear, any idea is welcome
Many thanks!
If you're going to stick with Swing I would use a JFileChooser to select the image. Once you got the image you can easily resize the JFrame by using the frame.setSize(image.getWidth(), image.getHeight());
To listen for mouse clicks inside your JFrame you need to use a MouseListener, make sure to add it to the frame, I always forget doing that.
Not sure whether you've succeeded drawing images/shapes at all. If not, you need to use a JPanel, check this topic if you need extra help.
If you are going to use a "JFrame " then you should definitely use Swing JFrames JPanels, and JLabels (as well as any other JComponents you need.) to accomplish this. Use only one JFrame. Use JPanel as the content pane/background for your JFrame and add everything else to it. But I would also suggest learning and using JavaFX because its the newest and I think it would be the easiest to use to do something like this. But if you only have a week and you know some swing use what you know. If you need more information post some code. Or ask a more direct question.

Adding a 'Minimize' button to JTabbedPane Tab Bar

I've searched extensively to solutions for this but haven't found anything that really achieves what I'm trying to do, the closest thing I could find was the solution posted at the bottom of this thread: http://www.java-forums.org/awt-swing/12267-how-add-jbutton-tabbed-pane-headder.html .
However because the JTabbedPane I'm using is inside a JSplitPane, it's size can increase/decrease, so using that solution doesn't work as the button stays static.
Below is an image of where I would like the place the component, similar to how eclipse has a minimize button on it's pop out views.
Is this possible without creating a custom JTabbedPane component?
Do you really need this button to hide?
Why don't you set splitpane.setOneTouchExpandable(true);?
With this line you can hide the bottom with an arrow of the splitpane.

How to create buttons like Android Google Plus App

I am new to Android development, and I am wondering if there are any samples available to create a panel similar to the photo/checkin/mood/write panel at the bottom of the google+ app on android.
1) Are they 4 buttons? How do I style the buttons to look like that?
2) I want to auto hide the panel on scroll down, but show on scroll up.
Appreciate if anyone could guide me in the right direction.
Cheers
To show\hide panel - use animation.
This panel can be linearLayout with 4 buttons.
Do detect what've been scrolled look at: Synchronise ScrollView scroll positions - android
you can use linearlayout and in that take for imageview..when scrolling you can show/hide linearlayout..and for view you can use linearlayout color as black and this imageview images..
OK, so I implemented exactly what you trying to do only without the buttons.
After lot of hours spending googling around I found this one - https://gist.github.com/imminent/4576886 by Dandre' Allison, which is a specific implantation of quick return bar for a list view which is little more trickier from other view components. For more implementations of quick return bar and other scrolling tricks you can use Roman Nurik's Scrolling Tricks library here https://plus.google.com/u/0/+RomanNurik/posts/1Sb549FvpJt and here http://www.androidviews.net/2012/11/scrolling-tricks/. I just saw that there is another quick return bar for list view implenation by Lars Werkman in https://github.com/LarsWerkman/QuickReturnListView which I never tested. I used the Dandre' Allison snippet which works great.
Answering your first question.
all the buttons are either in ImageButton, or in ImageView that make it clickable. it's either you can lay it out in LinearLayout or RelativeLayout, well it's depends on how you want to make it.
Try Using split action bar this will basically do the task for you.

How do I refresh a GUI in Java?

I have a general question that is Java related.
I am writing an application that has a GUI menu. I am trying to change one part of the GUI menu based on the selection of a Radio button.
Do I need to:
Redraw the whole window or just update that part with:
setVisible(true)?
If I just use the statement from #1 above .. the GUI is fine -- until I move the mouse over it and then I see the previous button choice. What am I doing wrong?
Swing components have a repaint(), revalidate(), and doLayout() method. One of those should probably be able to redraw whichever pieces you want. However, doLayout is not something that you should be taking responsibility for, that's the layout engines responsibility.
You may also want to check out this post, the first response has a pretty good explanation, and links to an article with more detail.
In terms of the second part of your question, I'm not sure, but we may need to see some code to get an idea. Is the 'replaced area' actually being removed from the view?
..in my application the user select which device platform type they want top test (that choice is a set of two radio buttons on the left). When the user selects either Android or iOS, the center grouping of check boxes changes to reflect a group of android devices they can test or a group of iOS devices that they can test.
Put a panel in the 'center grouping'.
Use a CardLayout for the panel.
Add both iOS & Android controls to the panel with the card layout.
Flip between them as needed.
Call revalidate() on the top level component.

Blackberry - How to implement ListField Smooth Scrolling?

Overview
I'm using a listfield class to display a set of information vertically. Each row of that listfield takes up 2/5th's of the screen height.
As such, when scrolling to the next item (especially when displaying an item partially obscured by the constraints of the screen height), the whole scroll/focus action is very jumpy.
I would like to fix this jumpiness by implementing smooth scrolling between scroll/focus actions. Is this possible with the ListField class?
Example
Below is a screenshot displaying the issue at hand.
(source: perkmobile.com)
Once the user scrolls down to ListFieldTHREE row, this row is "scrolled" into view in a very jumpy manner, no smooth scrolling. I know making the row height smaller will mitigate this issue, but I don't wan to go that way.
Main Question
How do I do smooth scrolling in a ListField?
There isn't an official API way of doing this, as far as I know, but it can probably be fudged through a clever use of NullField(Field.FOCUSABLE), which is how many custom BlackBerry UIs implement forced focus behavior.
One approach would be to derive each "list item" from a class that interlaces focusable NullFields with the visible contents of the list item itself -- this would essentially force the scrolling system to "jump" at smaller intervals rather than the large intervals dictated by the natural divisions between the list items, and would have the side benefit of not modifying the visible positioning of the contents of the list item.
Assuming you want the behavior that the user scrolls down 1 'click' of the trackball, and the next item is then highlighted but instead of an immediate scroll jump you get a smooth scroll to make the new item visible (like in Google's Gmail app for BlackBerry), you'll have to roll your own component.
The basic idea is to subclass VerticalFieldManager, then on a scroll (key off the moveFocus method) you have a separate Thread update a vertical position variable, and invalidate the manager multiple times.
The thread is necessary because if you think about it you're driving an animation off of a user event - the smooth scroll is really an animation on the BlackBerry, as it lasts longer than the event that triggered it.
I've been a bit vague on details, and this isn't a really easy thing to do, so hopefully this helps a bit.
unless you want to override the how the listfield paints or create your own wrapper, you will always have this issue, this is because each line is always visible when scrolling. Try using labelfield instead.

Categories

Resources