GWT ScrollPanel, bottom scrollbar is not scrollable - gwt

If I create a ScrollPanel like this:
public class BoardPanel extends ScrollPanel {
public BoardPanel(Game game) {
AbsolutePanel abs = new AbsolutePanel();
setHeight("100px");
setWidth("100px");
setAlwaysShowScrollBars(true);
abs.add(new Image(game.getMap().getImageUrl()));
add(abs);
}
}
I got my picture with a scrollbar on the right, which is scrollable.
The bottom one is only shown, if I use setAlwaysShowScrollBars(true);
My question is, how can I get the bottom one scrollable? It is just grey.

If the bottom one is shown only if you use the setAlwaysShowScrollBars(true) then it most probably means the image is being fully displayed and there is nothing left to scroll

public class BoardPanel extends ScrollPanel {
AbsolutePanel abs = new AbsolutePanel();
private GameCtrl gameCtrl;
public BoardPanel(Game game) {
setSize("100px", "100px");
abs.add(new Image(game.getMap().getImageUrl()));
abs.setPixelSize(768,576);
add(abs);
for (Player player : game.getPlayerList()) {
drawRobot(player);
}
}
I have fixed it, your hint was right, because he thinks that the whole image is displayed.
If I set the size of the AbsolutePanel, the bottom scrollbar appears and it looks like it should.

Related

Unity, scalling the width of a dynamically created Gameobject in a a scroll view content box

I am trying to add 100 dynamically created buttons to a scroll view in Unity, but I have a problem letting the scroll view automatically adjust the width of the buttons to match the width of my screen.
When I tried to add the buttons manually it worked fine , but when I do this by code I get another results.
The code I am using :
public GameObject button;
public GameObject scrollviewcontents;
void Start()
{
for (int i =0; i<=100;i++) {
GameObject dbutton = Instantiate(button);
dbutton.name = i.ToString();
dbutton.transform.parent = scrollviewcontents.transform;
}
}
and The results I get :
Results
Results with comments
I just want the buttons to look like as they are added manually, any help ???
By default when instantiating an object the object keeps the same world space position, rotation and scale as before. try this instead:
dbutton.transform.SetParent(scrollviewcontents.transform, false);

GWT overlapping images

i have one window panel and i want to set image in it.so i do,
Window window = new Window();
Panel panel = new Panel();
AbsolutePanel absolutePanel = new AbsolutePanel();
Image image = new Image("img/heat_map.jpg");
absolutePanel.add(image);
Image ap1Image = new Image("img/end.PNG");
ap1Image.getElement().getStyle().setMargin(1, Unit.PX);
absolutePanel.add(ap1Image);
panel.add(absolutePanel);
window.add(panel);
but i stuck in code as i can't overlap another small icon image on main image(heat_map).
i want onclick event on that icon image.but i can't overlap images in window panel.please help me out.
It seems that you using something like GXT not pure GWT. But anyway - AbsolutePanel should implement something like add(Widget, int left, int top) method so you need use it instead of simple add(widget)
First thing is in your code is you can not instantiate GWT Window Class since the constructor Window() is not visible.
Second thing is there is no add method in window class.
And finally to overlap your images one on another you need to apply Some CSS
(Z-index..positions )
CSS Divs overlapping, how do I force one above the other?
And finally
you can simply add a click handler to image.
imageIcon.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// Do something....
}
});
Good luck.

Dynamically positioning a GWT widget

My Goal is to have a Button with a background image and ontop of these a Label.
I want to position the label in the centre of the button and vertically allign it's text. I want the button to expand in propotion to the number of characters in the label. What is the best type of panel to use to build this type of composite widget as I am running into problems with using an AbsolutePanel as it doesn't dynamically grow with it's child elements.
private PushButton button;
private Label label = new Label();
private AbsolutePanel panel = new AbsolutePanel();
private Image image = new Image("images/rectangle_blue.png");
public ExpandingRectangularButton(String text)
{
label.setText(text);
String width = "120px";
String height = "160px";
image.setWidth(width);
image.setHeight(height);
button = new PushButton(image);
panel.add(button, 0, 0);
panel.setWidth(width);
panel.setHeight(height);
initWidget( panel );
}
What is the best type of panel to use in this case? I have tried flow, horizontal and flextables but I can't get these to stack widgets on top of each other correctly
FlowPanel??.
A FlowPanel arranges components in a directional flow, much like lines of text in a paragraph.

get in the center of the composite? eclipse

My purpose is to draw in the CENTER of the composite. Actually, I have an rcp view and I'm drawing some shapes inside it. this is the code that I use :
display = parent.getDisplay();
white= display.getSystemColor(SWT.COLOR_WHITE);
parent.setLayout(new FillLayout(SWT.VERTICAL));
// Create the ScrolledComposite to scroll horizontally and vertically
final ScrolledComposite sc =new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
sc.setMinHeight(100);
sc.setMinWidth(100);
sc.setSize(100,100);
Composite child = new Composite(sc,SWT.NONE);
child.setLayout(new FillLayout());
child.layout(true);
parent.addListener (SWT.Resize, new Listener () {
public void handleEvent (Event e) {
x = child.getBounds().width/2;
y = child.getBounds().height/2;
child.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent event) {
dessin(gc); // to raw the circle
}
});
sc.getDisplay().update();
}
});
I defined the view with a ratio (so when the view is empty I get the wanted size)...I don't know the exact size of the view since it can be resized by the user at anymoment, or when an editor is opened... So, my problem is how to draw just in the center of the view and keep the drawings in the center even if the view is resized...
PS: Using (Point.x and point.y), I get (0,0) when the view appears first, then I get other values...
Pleaaaaaaaaaaaaaase help
You can use getOrigin() method on ScrolledComposite, which will return Point instance with the point in the content that currently appears in the top left corner of the scrolled composite. See docs getOrigin method on ScrolledComposite.
With that information and size of the component which you'll get from getBounds() method you can easily calculate the 'real' center.

Child height in SplitLayoutPanel

I've got a SplitLayoutPanel. In the North cell, I've got a ScrollPanel
with a tree on it.
I want this ScrollPanel height to be the same of the north cell, so
when the tree expand, a scroll appears. The size of this ScrollPanel
must changed when the north cell is resized.
I've tried with RequireResizes but parent does not send size
information... An ideal approach should be that ProvidesSize widgets call onResize method with available size for the RequiresSize widget children
I'm very confused. How to configure SplitLayoutPanel to have cell
children resized ?
Thanks
Create a class that extends Composite and implement RequiresResize; like so:
public class MyScrollPanel extends Composite implements RequiresResize {
private ScrollPanel scrollPanel;
public MyScrollPanel() {
scrollPanel = new ScrollPanel();
initWidget(scrollPanel);
}
public void onResize() {
// do something to your scrollpanel
}
}
Then add MyScrollPanel to the north cell in your SplitLayoutPanel.
EDIT
However. It turns out ScrollPanel already has the desired behavior by default. A ScrollPanel added to a SplitLayoutPanel cell will automatically fill the size of the cell, even on resize. And any ScrollPanel child widget larger than available space will cause a scrollbar to appear.
But make sure you're adding the SplitLayoutPanel to the RootLayoutPanel by doing
RootLayoutPanel.get().add(splitLayoutPanel);