Synthetica JProgressBar doesn't fill - java

Recently, I'm using Synthetica as default JLAF, but progress bar doesn't fill, I try the following customize sentences but, nothing changes:
Synthetica.progressBar.x.animation.type with a different value of 0.
Synthetica.progressBar.respectMinimumBarImageSize with the recommended value of false.
Is there a solution?, is it a simple bug? or Is there some customize sentence that I've not seen?
I must clarify that, in other JLAF like nimbus, progress bar fills perfectly.
Thanks in advance!

At the end, the best way to solve the problem was deleting the sentence Synthetica.progressBar.x.animation.type and keeping the other as the following:
UIManager.put("Synthetica.progressBar.respectMinimumBarImageSize",Boolean.FALSE);

Related

JComboBox: arrow-button should be shown at any time

If a JComboBox is not selected, the arrow-button on the right is not shown. This leads to the fact that a combo-box cannot be distinguished from a normal textfield.
The question is now: how is it possible to show the arrow-button permanently? I alrady came across BasicComboBoxUI.createArrowButton() etc., but I did not find out the mechanism of hiding / showing the arrow-button.
Can anyoune give me a hint how to show the arrow-button permanently ?
Can you add below code as first line in your main method.
Toolkit.getDefaultToolkit().setDesktopProperty("win.xpstyle.themeActive",Boolean.FALSE);
and then check your program.
sorry for the inconvenience. Everything is clear now. In have been told that we use a special framework which changes the behaviour. This information would have been useful if given to me earlier... :-(

Differentiate between typing and pasting in JTextField

i've been looking around and haven't been able to find any solution to this problem: i have a JTextField and i want to do some things when the user paste something in there, i've found this: What event to use when pasting something in a JTextField?
which works ok, except that i want only to do things when the user paste something, not when it writes on the text field, i've though of saving the previous value of it and compare it with the new, and if it was empty and now is not, do things, but this won't work since it will enter in that condition when the user types the first letter in the text field.
If anyone knows how to do it whit the documentListener or whit any other listener it would be of grate help.
Update: since various people has asked, the reason i want to do this is because the text will come from a bar code reader or some similar device.
except that i want only to do things when the user paste something
Why should pasted text be treated any different than typed text? Sounds like a design issue. If you specify a better reason/requirement for doiong this we might be able to come up with a better solution.
i want to do some things when the user paste something in there
You might be able to override the paste() method of the JTextField. Just override the method to invoke super.paste() and then add your custom code.
how to do it whit the documentListener
Maybe you would consider a "paste" to mean more than one character is added at a time. In which case you just test the length of the String that is added to the Document.
I was able to fix my problem by configuring my bar code scanner and making it send a "new line" after each reading, and executing my code every time this happens with the actionPerformed of the JTextField. Thanks to everybody who tried to help.

What is the best way to make clickable text in java?

This is for an application so I don't want a hyperlink. I first tried using a Jbutton without all of border/background stuff and then hooking up an actionListener to it but I couldn't get it to the point where I thought it looked nice. I also tried using a JLabel and hooking up a mouse listener to that but I also couldn't get it to look right.
Basically I would like a way using swing to make a button exactly like a url link in an application. What is the standard way of doing this?
but I couldn't get it to the point where I thought it looked nice
You might want to go into greater detail on just what "looked nice" means. I can see you solving this by either a JButton or a JLabel, but the key is perhaps not to look for another solution but to play with the settings of the button or the label til they look nice. If you can't find a nice solution, then post your code (an SSCCE would work best of all) and perhaps we can help you.
that isn't answer to your question but are you tried to add ButtonModel to your JButton example here
It is a rather heavy hammer to use, but SwingX has a JXHyperLink control that is probably exactly what you want. The source is at http://java.net/projects/swingx/sources/svn/content/trunk/swingx-core/src/main/java/org/jdesktop/swingx/JXHyperlink.java?rev=4027 and you can see an article about it at http://www.javalobby.org/java/forums/t18617.html.
It is old, but SwingX continues to do good things.
It's you're trying to make a desktop application which looks like HTML inside a browser, you might try using some of the richer Swing text components in a read-only mode. You could use a mouse-listener to map X/Y clicks to a particular character of text, and then cause an action to occur on that basis.

getFocusOwner with a custom class

I need help working getFocusOwner(). I have a Sudoku game that I made in Java and I want to add arrow key navigation to the program. I did some research and found that using the focus system would be the best way (If it's not, please give me a better way and I can research that).
Okay, so for testing purposes, I'm trying to set focus to SetField, a custom class extending JTextField(Custom because I wanted to disable any inputs that weren't numbers). It has been set to focusable. I called requestFocusInWindow() on the SetField in the middle of the grid, and the focus is set to that component. The problem arises when I try and retrieve the component that has focus.
This is what I'm doing to test the getFocusOwner() method:
sGrid[40].requestFocusInWindow();
try{
System.out.println(this.getFocusOwner().getClass().getSimpleName());
} catch(NullPointerException e){
e.printStackTrace();
}
No matter what component I try this on, I always get the null pointer exception. I tried it with the JButtons, JLabels, and even on JPanels in my program. The focus is set to the component though. I can see the caret blinking in the intended SetField. Is there something I'm doing wrong? Thanks in advance for any help.
Instead of a custom component to only allow numbers, just us a JFormattedTextField.
Do you need to even determine which component has focus, why not add a KeyListener, MouseListener? I am not exactly sure what you doing with the focus but it seems strange.
I want to add arrow key navigation to the program.
You should be using Key Bindings. Create a basic "ChangeFocusAction". You will need 4 instance of this class that you can map to a KeyStroke.
Assuming you have a array of 81 text fields your Action could be created with an integer value that tells the Action how to change focus. For example:
right = -1
left = 1
up = -9
down = 9
The source of the ActionEvent will contain the text field that has focus. Then you search the arry to find the offset of that text field. Then you add the int value from above to the index and request focus on that component.
Just found out the problem. For anyone else that's having a problem with this, try using (Window).getMostRecentFocusOwner(). This worked for me.

Remove some layout elements from JProgressBar

I would like to know if it's possible to remove red areas(on JProgressBar) on the following image.
These are blue lines on the top and left side of the progress bar which I would like to remove. I have managed to remove it with paint() method, painting progress bar manually. But probably there is more correct way of doing it.
Thanks,
Serhiy.
Not tested but i think progressBar.setBorderPainted(false) should do the trick.
Subclassing JProgressBarand overriding paint()is fine and perfectly correct if you want to modify the bar's behaviour. I'm not sure where your blue lines are coming from though; do you have a shadow effect set somewhere?

Categories