I'm having an issue where I have 4 form fields in a fieldset. If certain conditions are met, I use setVisible(true/false) to hide or show the fieldset.
I'm running into a problem where I originally hide a fieldset, but when I make it appear, it doesn't display the labels and textfield boxes.
If I do it in reverse, where I show the fieldset, then hide it later, I have no problem switching between the views and having it show up properly.
I use an HBoxLayout for the fieldset. I'm wondering if it's the layout that could potentially be causing the problem or maybe it's the rendering order?
Does anyone have a workaround or solution?
Thanks.
The workaround I found was removing and adding the fields again. It's still not identical, the fields seem to be pushed over a bit from the left side, but it at least shows up again.
Related
I'm doing a program in JavaFX with ComboBoxes, and loading a FXML for the layout.
When I click for the first time in a ComboBox with few items (only two, for example), the scrollbar is shown at the right side. After I open it again, the scrollbar doesn't appear anymore.
I tried some solutions. One that worked is to apply a CSS directly in the FXML, which sets the cell size to a fixed value. But a solution inside the code (for example, in the initialize function in the controller) would be better for my case.
Thanks for any help.
This problem seems to be fixed in recent JDK versions, see https://bugs.openjdk.java.net/browse/JDK-8095019
If the options would stay fixed I would suggest using ChoiceBox instead of ComboBox. It is basically the same, but without the scrollable option. If you insist using ComboBox you can try combobox.setVisibleRowCount()
I am working a billing software development and I have faced some problems during hiding the grid lines I hid my table's grid lines using tablename.setShowGrid(false) method.
I have also set background for some specified rows. After hiding grid lines it shows as white lines within the background set rows.
I am pretty sure that you set everything visible at the end of the source code. This happend to me too. My advice: Set everything manually visible or not visible. Yeah, that is way more code as usual, but you can see what should be visible and what shouldn't.
I hope I can help you. And I am sorry for my bad English.
i have the following problem:
i want a JButton with a line break. i am using the html method to get it done.
<hmlt>Bla<br>Bla</html>
the problem appears if i disable the button. it works fine except on the "html-styled" button. the color from the button stays the same.
on an other button i am just using ←+;(without the "+") and it works fine, the arrow gets grayed out if i disable him.
so i searched some time for the unicode or html number for the line break, but it didn´t work(for example 
+;)
so can anybody give me an advice? i know it could be done in java, but i prefer the html way, cause it is faster to implement :)
See How to Use HTML in Swing Components: ButtonHtmlDemo:
..Note also that when a button is disabled, its HTML text unfortunately remains black, instead of becoming gray. (Refer to bug #4783068 to see if this situation changes.)
I don't think components with HTML text will be affected by the modified text style that disabling them usually causes.
You could override the button's getText() method to return a different HTML including styling for the text depending on whether the button is disabled or not, but if you want to get it just right it would probably be easier to extend the UI to allow multiple lines without relying on HTML.
I'm just figuring out my way around SWT. I have a little problem that i cant seem to solve. I have a check-box in my window. When the check-box is checked, i would like add a multi-line, read-only, text box below it, lets say 200x200. I want the height of the window to increase to accommodate this text-box. When the check-box is unchecked I'd like the opposite to happen.
Could you help me with this? I can't find an example but maybe I'm not using the right keywords. Cheers.
--EDIT
the.duckman'ss answer was very helpful. I've managed to get it working to some extent. I'm adding a multi-line textbox 480px high. How do I automatically resize the window to accommodate the text box? When the user checks the checkbox, the textbox shows up but the height of the window doesn't increase to accommodate the textbox. My code is a little long so I've put it in PasteBin — http://pastebin.com/01RxKeEr
Thanks.
I recommend looking at the SWT Snippets to every beginner - that's probably the best place to go to with SWT questions.
This snippet does exactly what you want.
Edit
Ooops, I ignored the second half of your question, sorry. Simply add this line to your listener:
shell.setSize(shell.computeSize(SWT.DEFAULT, SWT.DEFAULT));
Is it possible to overlay multiple JSliders so I can see the "thumbs" on both (I've tried disabling the painting of the track and setting opacity to false but one still hides the other)? Basically I'd like to create a component that allows the user to define a range (and I didn't really want to write a custom one since it has most of the attributes of a slider). If there is another way I could do that with a slider, that would work too.
thanks,
Jeff
Ah, I found it (i must not have been seraching on the right terms). Swing labs as a JXMultiThumbSlider that I think will do the trick.
http://swinglabs.org/hudson/job/SwingX%20Weekly%20Build/javadoc/org/jdesktop/swingx/JXMultiThumbSlider.html
I recently had the same problem, I wanted a slider with two thumbs. I didn't get into it too much, and what I ended up doing to get the range is simply putting two sliders and in the "onSliderChange" event listener prevented one beeing smaller than the other and the other bigger than the one. I don't beleive Swing has a two-thumb-Slider, although it might be a cool new feature to add, so I think this is your best bet.
JIDE has a RangeSlider with 2 thumbs (and a nice extra one on top to move both thumbs at once (e.g. drag the range around) in their open source common layer: http://www.jidesoft.com/products/oss.htm