I am trying to make controls for a media player. I have a slider and volume control which i wish to sit above another row of controls such as play mute etc at the bottom of the window.
I thought a good way to achieve this was creating a HBox that sits above another HBox, both aligned to the bottom in a javafx application.
I tried to use insets and margins to offset one from the other but i was not able to get them both to show.
Another attempt was to add the two HBox nodes to a VBox to get them vertically placed, but that was not successful either (i don't think it can be done this way).
Does anyone know how to implement this? or is there a better way to achieve the desired effect?
A GridPane might be what your looking for.
It acts similar to HBox and VBox, such as you can get creative and add other grids and boxes inside the main grid.
Related
I am making a small game with LibGDX, and for this game I need a small container, which is a scene2D Stack, and inside that container is a label.
My problem is, that this label may only be on one line, and if the label text is longer than the container width, then it has to slowly move/scroll from right to the left, so the player can see the entire notification text. and when all the text has been shown, then the sliding should start over.
The best example I can come up with, for the behavior, is a digital text sign like in the image below
Hope anyone has some guides or can show me some code, to get me going :)
If it was me, I'd create a table (label container) and a label(text) and change the position of the label accordingly and then reset it. Respecting all of the label.getwidth and so on
I want a panel around two text fields that can be collapsed, similar to a TitledPane with no text. However the TitledPane uses too much vertical space so that it saves almost no space, as it reserves the space normally used for the title. Does JavaFX offer a really space-saving panel, lets say a rectangle with a triangle for collapsing?
There is no such ui control in JavaFx apparently. You must implement your own "collapsible pane" . It is possible to use TreeView but I think it can only hold text values as child elements.
The album view in iTunes has a slick effect where the album title and cover art stay in view at all times. If you slide down the screen they stay pinned to the top of the screen until they bump into the next album, then they slide away.
Notice how the top album is still fully visible even though the user has scrolled down a ways.
What is this control or effect called? I'm coming up with blanks trying to Google for it.
How can I do this in JavaFX? I want to mimic this in my Java-based GUI. Can TableView do this, or maybe some third-party control?
The easiest way to do this is with a ScrollPane. Inside your ScrollPane you define your rows and their layouts (probably each row is an HBox containing an ImageView and a TableView which is set to the height of the ImageView). Then, the TableViews inside your ScrollPane need to let the ScrollPane override their scrolling - that is, their onScroll bubbles up to the ScrollPane.
Then you override the onScroll behavior for your ScrollPane. The algorithm for the scrolling could go like this:
There are two modes.
1) Scrolling IN an album scrolls the TableView in that row. If the scrolling goes beyond the boundaries of the TableView's scrollHeight (the range between 0 and scrollHeight), then the mode switches to scrolling TO an album.
2) Scrolling TO an album scrolls the ScrollPane an amount up to the height of the current row. Scrolling an amount greater than the current row's height moves to the next album and switches the mode back to Scrolling IN that album.
3) Edge Cases: Scrolling within the ScrollPane beyond the boundaries of the ScrollPane's scrollHeight (the range between 0 and scrollHeight) immediately moves to the next album and switches the mode back to Scrolling IN that album.
I'd give a code example, but I've never actually seen anybody try to do this. I just know you CAN do it.
I would recommend you to take a look to the SpreadsheetView in ControlsFX
The SpreadsheetView allow you to fix at the top of the screen any number of line. So you would have the first part of your behavior.
Regarding the fact of bumping into another, it would be more difficult but not impossible with the SpreadsheetView.
Anyway, if you want to implement that behavior in the TableView, you will find very useful tricks in the SpreadsheetView code.
This is how a section title acts as default in a UITableView.
https://developer.apple.com/Library/ios/documentation/UIKit/Reference/UITableView_Class/index.html
This should help you on how to create and use UITableView
For a project I have an almost working code, but I do not have the GUI. I want to make a screen that consists of clickable labels and has the following design:
I was thinking about first making the middle GridBagLayout with with a dimension of 6 by 2. Then 'wrapping' that up and adding the two buttons to the side, and then 'wrapping' that and adding the two buttons below.
I am inexperienced with Swing, and I have no idea how to start. I hope someone can give me some hints in the right direction.
Several approaches to a very similar layout using GridBagLayout and/or nesting are shown here. Consider using JButton for each clickable area, rather than JLabel. If you go with a nested layout,
Use BorderLayout for the enclosing panel.
Add buttons to EAST and WEST for the leftmost and rightmost areas.
Add a GridLayout(1, 2) of buttons to SOUTH for the bottom row.
Add a GridLayout(2, 6) of buttons to CENTER for the central twelve areas.
Addendum: A critical issue will be what you want the resize behavior to be.
as said in the comments above you could (should ?) use the WYSIWYG Window Builder plugin available for Eclipse; it's simple to use.
However, that doesn't answer your question, so to do so, here is how I would structure the UI if I were to make one like that :
http://www.hostingpics.net/viewer.php?id=902716gZHkK26.jpg
I basically use BoxLayout because that's the one I'm most familiar with. Every Rectangle is a JPanel. I think the image is pretty self eplanatory.
Im making a Java application which views a set of images within a timeline. My Idea was to use a JScrollPane with the set of all images set out in a grid-layout, but rather than scrolling the pane using the traditional scroll bars, I wanted to use something like a JSlider.
The purpose of this is to give the user more control and idea of the time at which the subset of images is shown and to give greater effect of a timeline. I have produced a simple visual example of my idea below:
I wondered whether this was even possible as I have not seen any similar examples after extensive research. Any help with any possible solutions is greatly appreciated.
Many thanks.
Some ideas: Put the images into a JPanel and this JPanel into a JScrollPane without scroll bars at all. Then sync the slider (ChangeListener) with the JViewPort.
Or (simpler) use the horizontal scroll bar as the slider and custom a JScrollBar with the labels.