I've searched through google, but there doesn't seem to be anything on this. In almost every user interface, you can resize parts of it in order to make it more custom (from the users perspective). For instants, in eclipse, one can resize the consul relative to the area with the code by clicking on the spot in-between the two panels/parts and dragging. One can also click and drag the area in between the Package Explorer and the rest of the parts in order to resize that. How would I do this? By "this", I mean allow users to resize the amount of space given to each part of the layout? How do I get the little division-sign-like curser to show up? What layout should I use?
You seem to be describing a JSplitPane.
Take a look at How to use Split Panes for tones of examples
Related
I'm not very experienced with Java Swing Layouts. I'd like to make a layout looking like the one in the picture. Is there any easy way to understand and create layouts?
There are tutorials on the oracle website and there are wysiwyg layout-building tools that show you interactively what you are building. One of them I have personally used in the past is the Window Builder you can get as an eclipse plugin but it is by no means the only one.
In the end though what it comes down to is experience. Fool around with them, try them out, get to know them. If you dont code with them yourself it is difficult to understand them properly.
Is there any easy way to understand and create layouts?
I cannot judge what others would find easy, but my approach to laying out containers is to look for sub-sections of the GUI that would be easily done with a particular layout, then working outwards from that.
For example, it seems a single row GridLayout might be well suited to displaying the top two text panes. Then the rest of the GUI can be created by placing the panel with the two text panes into the PAGE_START constraint of a BorderLayout, with the third text pane in the CENTER and the text field in the PAGE_END.
Done.
i have difficulties in resizing elements in CN1, f.e. i want to resize a Button and put an image on it to use in a MenuBar, the Buttons are too big so that it exceeds the space of a Samsung S5 Display. Im working with the Designer and tried a lot with the Themes/Styles but dont seem to find a solution for this.
The MenuBar as in the screen has too large buttons, the left one is the Logo of the Company, the Buttons are three in total but only two can be seen..
For the yellow status icon, same problem same hassle :\
Do i really have to manage this in source code or is there a more convenient way with the UIDesigner.
Regards
EDIT : i now found out that using "icon" in the Designer is rubbish. Instead use this following Trick.
Put in a Text, define a Style in the ThemeEditor, set Font-Size in millimeters. Also set the Background Image and its behaviour to ScaleToFit, it should Resize now. Only Downside i have using this technique is that i have to use Whitespaces instead of a Text, is this really the best practice or does someone have a better approach?
Also another downside is that for every Image you have to Design a single Style
In order to support multi DPI's the icon needs to adjust it's size to the many screen sizes available.
Use multi-image https://www.codenameone.com/how-do-i---fetch-an-image-from-the-resource-file---add-a-multiimage.html
I'm currently trying to learn JavaFX and FXML (and Java) and decided to write a textbased RPG. The basis for this was already written quite some time ago, but now I wanted to do the whole thing better. Including the visuals, that is, the GUI.
First of all: I'd like to do this using FXML. That does not mean however that I'm not interested in seeing a way using basic Java.
What I want to build is a fully dynamic GUI. No Matter how it is resized, the components (and ideally the text as well) would be at the same location, relative to the other components / window border.
The window would have some kind of top line with several buttons for saving, the menu, overview and whatnot. Below that, on the left side, would be Character information: Health, Experience, Money etc. On the right side would be the text output (using a Scrollpane) plus a text field, for user input. Below the text input/output I'd place the buttons used for actions and decisions. Bottom left corner does not contain anything, though it should be a separate area.
At first I tried using Splitpanes, not knowing that they can be resized anytime and have visible Dividers. Now I'm not sure what to do.
A Gridpane would give some of the functionality I need (separate the areas), but also does not give the flexibility I want (unless I just don't know how to do it). I couldn't get it to work. So I tried using simple Panels. But with them I couldn't figure out how to keep the panels keep their relative position and size, and how to make the Buttons stick to the borders.
So what would be the best way to go about this? GridPane? Panel? Something else I'm missing? Since I don't really know how to achieve this, any help in any direction would be highly appreciated.
Have you read the layout tutorial?
From your description, it sounds like a BorderPane might be best for the overall layout (i.e. the root of your scene graph): I'm not quite sure if you could easily make this give you the empty bottom left corner you want. Alternatively you could use a GridPane as you suggested, with appropriate ColumnConstraints and RowConstraints applied to size the cells in the pane.
I'm trying to provide a progress report for a slow operation, in the form of text scrolling up from the bottom of the screen with details on what's going on - it's an effect you may have seen a few times in video games when they're loading maps, making network connections and suchlike.
Glass pane seems to be the way to get the text overlay, that much I have working. My problem is exactly what component to use for the actual text display.
JTextArea can display text, but as far as I can see, it can only do it from the top of the screen down - is there a way to make it scroll text up from the bottom of the screen?
JLabel by contrast can align the first line of text to the bottom of the screen, and even take appended text on that line, but when I add more lines separated by newline characters, it just seems to swallow them up even after calling repaint and validate. Is there a way to make it scroll up with the new text?
Or is there another component I should be using instead?
I really like JXLayer for effects layered over Swing components. JXLayer was at one point scheduled to be included in Java 7. Unfortunately the moving around that has been going on Java.net lost all the good content that the author had. There are still some other great resources around (Java 7 required for this one) on the web. I use JXLayer to provide panels with a busy state having a web-like spinner and greyed out appearance.
Another alternative (not as capable as JXLayer IMHO) is MigLayout has absolute positioning, which is maybe easier than the GlassPane.
JLabel would be the easiest. Otherwise you will have to override paintComponent to do anything fancy like animating the text movement.
I am working on an app which when used for loading a file and drawing the contained components, may result into painting of overlapping components. For example, consider a big rectangle box containing text line inside it.
Now because these components are overlapping, it is difficult for the user to select the inner text box in this case as it has been overlapped by the rectangle box.
We were thinking of solving this with allowing the users to actually move any component to a layer below the current one. But this has its own limitations on the usability side, as then for every such case the user will have to move the bigger or the most recently painted component to a layer below and then do the other processing on the inner components like dragging etc. There can be more than 2 components at the same 2d (x & y position) in this app.
I am sure that there should be a better solution for this and could someone please provide some pointers on the implemention part of it.
I am not sure, whether i understand your question. Do you have problems, with the action listeners or because of drawing the components?
This How to Use Root Panes may be helps.
You can create a Glasspane in Java
Here's a simple example of an object drawing program that supports click and drag for multiple selections. More advanced programs often implement z-order functionality (Move Forward, Move Backward, Move to Front, Move to Back) by simply re-ordering the node list.
As an alternative to the layered pane approach, also consider JInternalFrame. This example shows How to Use Actions to manage a menu from which hidden windows may be brought to the fore.