I understand that this is done in CSS (well SCSS) but I'm struggling with how to style it so that the MenuBar looks like text. I'm ok with the MenuItems as they are, I just want the MenuBar itself to look like links. A good example is the Help link at the top of StackOverflow, just to the left of the search box at the top of the screen..
By default in Vaadin it looks like buttons, and when I click on them the button is highlighted and has this extra border color as shown below:
I want to remove all that and just make it look like a link that you click on. The MenuItem styling is great, but I just want to make it look like text. I like the down carrot, as well as the styling for the MenuItems, it's just the MenuBar that I'd like to change. Below is an example:
I've been messing around with the css for a bit now and I just can't get the right style. Any help would be greatly appreciated. Again I'm just looking to remove the styling of the MenuBar and nothing else. So far I have:
.myMenuBar
{
border: none;
background-image: none;
background-color: myBackgroundColor;
box-shadow: none;
}
The problem is that there are still a number of style elements I'm struggling with:
For example I still have a blue highlighted button when I click. Also the popup menu is backgrounded to my custom color. I also have a separator line in black between the two elements. And although it's harder to see there is a fine white and grey line above and below the MenuBar to show some depth.
UPDATE: Added some css improvements but I'm still a ways away.
Even with the links in the comments just below the question I still struggled to find a solution. Eventually I ran into the Class ValoTheme and found I could do exactly what I wanted with one line of code. In fact it was better than what I was planning so kudos to the theme designers!
menuBar.setStyleName(ValoTheme.MENUBAR_BORDERLESS);
Related
How can I style a ComboBox "body" part not the dropdown?
As you can see on the screenshot I want to style just that part where you click and opens the dropdown and the dropdown should remain as it is.
If I try for example:
.combo-box-base .list-cell{
-fx-background-color: red;
}
everything goes red not just what I want.
I had a look at this question: Javafx combobox styling
but it didnt really helped me, it styles everything but not that specific part I need.
I have also looked with ScenicView, and I could locate it and add as style: -fx-background-color: red and it worked, but from code I could't manage it.
In ScenicView I saw the ComboBox has three components:
a StackPane a ListView and a ListCell. I want to style just the ListCell part.
Here is how it looks like if I add those line in my.css:
As you can see I don't want the dropdown to be styled.
How can I solve it.
Note: the arrow should remain as it is, just that part where the text is shown, as the second screenshot shows.
This question is very similar to previously asked, but unfortunately, previous articles do not help much to solve a problem described below.
I would like to create a layout with three text areas that holds source code, code lines and some help information. And only one text area has a scroll bar. It's required to sync text areas in terms of text lines (wrapped text should not affect code lines) and scroll functionality (scroll bar in test area with source code will scroll all three areas).
Please look at layout example:
I already seen a number of topics that shown how to use row header in scroll pane, like in Text Component Line Number. In this aproach, I have no idea how to add third text area. I am looking for advice, how to create such kind of interface easily. Thank you!
I have no idea how to add third text area
Use a BorderLayout and add the components to left, center and right
[...] and only one text area has a scroll bar. It's required to sync text areas in terms of text lines (wrapped text should not affect code lines) and scroll functionality
Please have a look at following answers:
How to scroll two JTextPane's?
synchronize scrolling of N number of jtables in java swing
I've been working on a Button extending class that when left-clicked on displays a stay-open popup menu (ContextMenu object) on a configurable side/corner of the button. The constructor takes an enumerated value like NORTH_LEFT that indicates the side of the button where it gets shown and which edges on both the button and popup are aligned. In other words the 2 should always show in an L shape combo, not a T shape.
So when I want to do something like EAST_BOTTOM where the bottom edges of both button and popup should align, I figured something like this would work:
PopupMenu.show(this, Side.RIGHT, 0, this.getHeight() - PopupMenu.getHeight());
But what I get is a Popup that appears much higher up then it should. That's because the PopupMenu.getHeight() call is returning a larger value then expected. I suspect because it is including the large shadow border in its dimensions. I've noticed that this semi-visible border also extends over my button a bit and prevents mouse clicks from registering on the edge of the button near the menu. So I have multiple reasons to want a border of 0 width.
I assume there is a way to do it via CSS. I've tried setting -fx-background-insets and -fx-padding to 0 but neither seems to make a difference. Any other suggestions?
The solution is to add -fx-effect: null; to your CSS for the ContextMenu. This removes the dropshadow effect that is the modena.css default for ContextMenus. Once I did that I was able to correctly place my menu wherever I needed it to go.
Credit for this working answer goes to José Pereda - we worked it out in the comments above.
I am stuck trying to make the following kind of slide menu in Swing.
I have searched entire web but I didn't find any tutorial or maybe I missed that. Can you please suggest a solution or a tutorial? I don't need code but just the components to use.
This is very simple in Swing.
What you are looking for is a JSplitPane. You can start with it closed and it has arrows (or other symbols depending on your look and feel) that can be clicked on.
http://docs.oracle.com/javase/tutorial/uiswing/components/splitpane.html
Note: A slider is a very different component. (http://docs.oracle.com/javase/tutorial/uiswing/components/slider.html)
Edit: Based on your comment it sounds like actually are looking for an animated opening of the slider (which is hard to tell from a static image).
In that case this question is a duplicate, look here: Animation for divider movement in JSplitPane
So, I have a Calendar solution for my employers where I am using a custom look and feel (Synthetica) and each cell in the table holds a JPanel with a list of buttons and a PAGE_AXIS BoxLayout. I am trying to reduce the gaps between each button so that they abut each other, and I've tried setting the borders to null except that destroys the button appearance. I have used the following (as recommended by Oracle to view the actual size of the components) code;
setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createLineBorder(Color.red),
getBorder()));
And this is what I get;
Setting the margin does not work with whatever border version the buttons are using. So, is there any way to find the current border that it's using? So that I can set that border's insets manually, or something like that. Basically, I need the buttons to abut each other. Any ideas?
Clarification: I want the button's themselves to stay the same size, but I want the white space around them (highlighted inside of the red borders) to be gone,
Several possibilities should be considered:
Manipulate the button's bound properties: setBorderPainted(false), et al., as suggested here.
See if a suitable sizeVariant is available, as shown here.
Use a custom UI delegate based on BasicButtonUI, as shown here and here.
I tried to get the Synthetica L&F to have a look but seems as though you have to create an account which I did not want to do. Anyways, a quick look around the website and I found a page which indicates how you can see and configure some of the values set in the L&F. Might be worth having a look there.
http://www.jyloo.com/synthetica/customize/