Vertical layout of the icon and text in a JMenu - icons

I try to find a way to place the icon of a JMenu above its text. I've seen the method setComponentOrientation(..), but it influences only the horizontal order of the icon and the text (icon on the left side, text on the right - or the opposite). Is there any possibility to place these parts of a JMenu vertically (icon on the top, text under the icon)?

I'm not sure if you are fully able to do that. Maybe this page can help you out. http://www.java-forums.org/awt-swing/36112-adding-jpanel-jmenu-focus-issues.html I have never really tried adding an image onto a JMenu vertically. You could always try using a JPanel, and adding the JMenu into it, and then setting the layout of the JPanel as a BoxLayout
JLabel imageForIcon = new JLabel(// image path );
JPanel p = new JPanel(imageForIcon);
JMenu m = new JMenu(p);
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
I am not sure if this would work, but it seems as it could possibly be an option to consider.

Related

Qlabel with image as the background overlaps other Qlabels

I have a Qlabel with image as rich text and some other Qlabels on top of that as in the picture:
although I sent the Qlabel with image to back but when I run they appear as follows:
is there anyway to fix this?
Make the text labels children of the label containing the fade. Also I can not see any layouts. Did you use layouts? You could also put the fade on the widget by implementing its paintEvent(). All other widgets will be displayed on top of that.
Try right clicking the image label and clicking the send-to-back option. That might work. That should send the QLabel behind the other elements even though they appear as though they are already in front.

How to get a Borderlayout to fill its container?

I am a GWT programmer trying to get to grips with using PlayN with Tripleplays gui library.
Having a little bit of trouble working out how to get a border layout filling up all the space of its container. (presumably with the middle space expanding to fill the available size)
BorderLayout border = new BorderLayout(3);
Group mainLayout = new Group(border);
mainLayout.setConstraint(AxisLayout.stretched());
Button Center= new Button("test");
Center.setConstraint(BorderLayout.CENTER);
mainLayout.add(Top);
mainLayout.add(Bottom);
mainLayout.add(Left);
mainLayout.add(Center);
Top Bottom and Left are similarly specified to BorderLayout.Left, top etc.
the whole thing is then added to the root screen with
_root.setConstraint(AxisLayout.stretched());
_root.add(0, mainLayout);
(_root itself just has a AxisLayout.vertical() ...which I am assuming makes it act somewhat like a gwt vertical panel)
At the moment the vertical space seems to be filled, but not the horizontal.
Any ideas where I am going wrong?
I would suggest to set
border.setConstraint(AxisLayout.stretched());
before adding border to mainLayout. This will tell mainLayout to strech this child widget.

GWT DialogBox Has Gaps In Border For Larger Messages

Working with GWT v2.5.1, I'm creating a DialogBox and filling it using HTML by calling dialog.setHTML(...) with this:
<h3>could not start.</h3>
<hr>
<p>These preferences must all be set before I can start</p>
I have no custom CSS. What appears on the screen is this:
You'll notice that there are big gaps in the left and right borders. Looking at the CSS for the dialogTopLeft and dialogTopRight classes, they extract the border from images/corner.png and the shown length of the border exactly matches the size of that image. In other words, the dialog is too big.
I tried removing the "no-repeat" directive on the background CSS attribute (using Chrome Inspector) but that repeats the entire border image, including the rounded corner at the top, and so does not appear contiguous.
I can't be the first person who's tried to put more than a single line into a DialogBox...
What's the trick to making the borders "repeat" and fill in the holes?
Wrap the HTML in HTMLPanel befor passing it to the DialogBox
DialogBox dialog = new DialogBox();
HTMLPanel panel = new HTMLPanel("<h3>could not start.</h3><hr><p>These preferences must all be set before I can start</p>");
dialog.add(panel);
dialog.center();
Thanks to #Moh for placing me on the right path.
The proper way to do this is to set only the dialog title using setHTML() and then create the body as a new panel and add it to the dialog.
DialogBox dialog = new DialogBox();
dialog.setHTML("<b>" + title + "</b>");
dialog.add(new HTMLPanel(message));
Adding buttons is left as an exercise for the reader...
GWT Dialoge box already have pre defined CSS.
you have to override or have to set your own style names using set Methods.
like..
dialogBox.setStyleName("yourcss");
Default css names starts with,
.gwt-DialogBox{}

Flex having a VBox with Vertical Buttons

I am trying to get a left hand like panel bar in my application, one much like the OneNote left hand(notebook) panel.
I have been trying to use a VBox with Buttons and setting the rotation on the buttons to 90. The buttons seem to disappear when I do this.
An example of what I am trying to achieve is here: http://www.rid00z.net/panelBarExample.png
What is the best way to achieve Vertically stacked buttons like this?
try putting all the buttons inside an Hbox and then setting the rotation of the Hbox to 90.
Oh and also make sure you rotate around using a point at the center.
I would create a custom component to do it. I would make each "button" a canvas and display text in it vertically (embedding the font you want to use to do that) - the canvas would have a click event - I would use canvas over a standard Button because it allows more flexibility. In this new component you would have functions to add or delete buttons. I can clarify if it would help.

Flex scrollbar styling issue

I'm trying to style vscrollbar and hscrollbar inside a Vbox.But there's always a white square thing at the right bottom cornor which can not be styled.
My CSS is:
ScrollBar{
downArrowUpSkin: Embed(source="assets/images/scrollbar/arrow_down.png");
downArrowOverSkin: Embed(source="assets/images/scrollbar/arrow_down.png");
downArrowDownSkin: Embed(source="assets/images/scrollbar/arrow_down.png");
upArrowUpSkin: Embed(source="assets/images/scrollbar/arrow_up.png");
upArrowOverSkin: Embed(source="assets/images/scrollbar/arrow_up.png");
upArrowDownSkin: Embed(source="assets/images/scrollbar/arrow_up.png");
thumbDownSkin: Embed(source="assets/images/scrollbar/thumb.png");
thumbUpSkin: Embed(source="assets/images/scrollbar/thumb.png");
thumbOverSkin: Embed(source="assets/images/scrollbar/thumb.png");
trackSkin:Embed(source="assets/images/scrollbar/track.png");
fillAlphas:0,0,0,0;}
Could anyone help me out?Much Thanks!
This is a weird one. The white box at the bottom right is actually a (raw) child of the container.
To get around this you need to subclass whatever container you want to add your styled scrollbars to and remove the child called "whitebox":
var whitebox:DisplayObject = rawChildren.getChildByName('whiteBox');
if (whitebox)
rawChildren.removeChild(whitebox);
IIRC you need to do the above in two places: an override of createChildren and an override of validateDisplayList. In both cases remember to call the super class method first!
That area isn't controlled by the scroll bar(s), it's part of the original container. Does the VBox have it's background colour set to black?

Resources