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
Related
I am curious if it possible to center a JButton in two X grids of a GridBagLayout? I've done some searching through the API but haven't found much. I have also drawn up a small picture to clarify what I am trying to do.
Thank you!
Example Image:
I've done some searching through the API but haven't found much.
Read the section from the Swing tutorial on How to Use GridBagLayout.
You would need to concentrate on the Specifying Constraints section:
the gridwidth constraint will allow the button to span multiple columns
the anchor constraint will allow the button to be centered within the two columns.
the fill constraint will need to be turned off.
The above assumes that you actually have other components on the panel in each of the columns. You can't just randomly say a single component takes up two columns.
So start with the demo code in the tutorial an modify it to have the button on the bottom centered.
I am using a ChartPanel from JFreeChart (1.0.14) to display some plots. The Layout is handled by MigLayout and all works well. However, I have strange behaviour from time to time. The minimal size of the panel changes sometimes when the plots change. I am not setting it in my code but leave everything to MigLayout.
Unfortunately I am unable to reproduce this behaviour in an SSCCE, especially the first S. But in my application it also occurs when I am just changing the renderer to display a thicker line for one of the XYSeries.
So my question:
Is it possible that the layout parameters are changed within the code of JFreeChart depending on the displayed content?
If so, is it possible to turn off this behaviour? Because I don't want anything else than MigLayout to lay hands on the layout parameters...
Ok, I figured out the problem. My ChartPanel is in a TabbedPane with other tabs. One of those other tabs also contains charts. And one of those charts has a logarithmic range axis. Now I put in data that contained negative values, which can not be displayed logarithmically and the reaction of the axis was to just zoom out in both directions as much as possible. This resulted in extremly long axis labels (0.0000000[..]00001 and 10000[..]0000). This resulted in MigLayout giving more space to this panel and recursively also demanding more space from the tabbed pane. So the tabbed pane grew also for my other tabs.
Quiet strange and hard to figure out... ;) Thanks to trashgod for your willingness to help. :)
I'm trying to build a simple interface for an assignment, in which multi-line word-wrapped input boxes can be stacked vertically in a single, fixed-width column. then the whole stack (if tall enough) has to scroll vertically inside of a scroll pane with the same fixed width and a fixed height.
The active box has to change height dynamically to fit the amount of text as it is being typed/deleted. This means the y position of all subsequent inputs in the column should change accordingly. A layout manager's job, right?
I started reading about the swing layouts, and it seemed like only the GridBagLayout could do this. Since this is my app's only interface window, it seemed like a clunky layout to achieve something simple.
So, which swing layout should I use, along with which text input class for word-wrapping and auto height adjustment? Thanks.
A BoxLayout might be what you are after for this use-case.
I have a custom popup window with a custom image background in which I need to place three custom buttons with their own background images. I have only one set of images for all the components, so I want all the parts to scale appropriately. My question now is how do I make sure that the buttons line up with the appropriate parts of the background image of the popup window. I have been experimenting with all sorts of widths and heights and I can not make it look consistent on all my test devices. Can anyone give me some pointers?
EDIT: Just to make it as clear as possible, the image below illustrates the kind of thing I am talking about:
I want the graphical button to line up with the arrows which are a part of the popup window background image.
arrange buttons in an xml layout and set this view to your custom popup and you can set images to buttons from code.
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.