Hi i was wondering if any has heard of a Java component that provides a range slider. A slider, that is, with two knobs that define a range in the min max values rather than just one.
I found on the web a JRangeSlider in the perfuse library but i have two issues with it.
First (and not that important) is that it has it's own visual style and does not change and blend in with the used look and feel.
Second (and REALLY important for my app) is that when you setEnable(false) on it nothing happens!! You can still use the slider. The reason i want to disable it is that i have a new thread running at some point in my program that alters a value that the range slider also affects. I want to simply disable the slider while my thread is running and enable it after that.
Any thoughts?
I believe you are using an older version of RangeSlider. If you still need it, please make sure you check out the latest release. Here is a screenshot of it under different look and feel. Regarding the look is not so good, we are now using the same look and the JSlider of the L&F you are using. The screenshot below are from under Windows 7, Mac OS X Aqua, Windows XP and Metal respectively.
Screenshot of RangeSlider from JIDE Common Layer
JIDE has an open-source RangeSlider in its Common Layer. You can try it out by downloading JIDE's webstart demo.
I'm not sure what the look and feel of your app is...but you could always give BiSlider a shot:
bislider: BiSlider Home Page
Am not aware of any other than whats been mentioned, but a suggestion for your second problem would be to change the model to a static model (with suitable values) at the same time you disable it. That way it will be guaranteed not get updated.
When you enable it, remember to switch it back to the original model.
Related
I was reading through the java docs and found that it is easy to make a shaped windows, making them translucent and coloured as long as the platform is supporting such feature, but I couldn't find anything about making them glossy.
Is it possible in either awt or just swing to give frame or a panel a metallic look?
I know this might be a horrible idea from cross platform point of view, but I wanted to know if it's possible somehow without resorting to some third party libraries?
I have found a button gloss example here:
http://www.andygibson.net/blog/tutorial/glass-button-tutorial-in-java/
But it is not exactly a metallic look and if I replicate the method to use rectangles instead of circles it may scale poorly.
I've been looking at JavaFX but it seems to be a massive multipurpose package - an overkill if I just want one eyecandy.
note - if you give a minus, be so kind to explain why - else its just being a jerk. I see nothing wrong with this post and I did indicate what I looked at. From what I see I've fulfilled all formal requirements and this is not a subjective type of question.
What your requesting can only be handled by calling the Windows native API. You'd have to cooperate with the Windows DWM (Desktop Windows Manager) facility. Typically it's handled by calling the DwmExtendFrameIntoClientArea function.
Long time ago, I tried to mimic the glass (AKA Aero/Frost) effect using Swing. It was partially possible. One can easily write drawing code which handles this (and surprisingly even quite performant), providing that the drawing happens on the Java side.
That was possible with Swing (see Glass effect for internal panes) and should be even simpler with JavaFX.
However, to handle your precise request - the windows borders - one has to use the native WinApi. From my little research, I only found that SWT does this in limited way (but doesn't expose as publically accessible methods).
I tried to call the Windows Shell API through the JNA project. I successfully managed to change the glass area, but the effect was unpleasant: the Swing wasn't really well prepared (~JDK 7u5) to handle partially transparent JFrames. I remember, that the JFrame code, during a repaint, was clearing the Window using some color. I had to forcefully change it to other one (which matched the one I specified by calling the Windows API), but ended up in a visual mess.
I tried to debug it and I found that certain versions of Java have different code to clear the JFrame's content. So, even if I managed to correctly set the wanted color, it could easily break with the JDK update.
I wanted to have a discussion on Java GUIs, right now, I'm still in school and I've done light gui development for class.(We briefly covered it.)
Plain and simple, I couldn't do anything I want, I wanted to build a nice clean layout but everything looked off and worse when you maximize it. JButton were huge when put inside a GridLayout, or they spanned the whole row, when I clearly specified the size of the button and etc. It's been one headache after another with Java gui development.
With Microsoft WPF/XAML UI development is more straightforward, it felt like HTML/CSS. Setting the width, height, margin, and padding is great, knowing where my components are going to be puts the mind at ease. And you can even design a custom Look and Feel.
I wanted to know if do you guys have any tips and resources for someone starting Java GUI development. And the one thing I don't get is launch new items with a JFrame, i.e a game.
At Launch your directed to a panel with 4 buttons.
Play Game - Takes you to a new panel to play the game.
Lobby - Takes you to a chat like interface
and etc
Should these be panels? Or more JFrames, like when a user click a button I launch the Play Game JFrame then close the menu JFrame. I really have no ideas with Java guis.
Make sure you understand and are using the appropriate layout managers. This Swing tutorial is very useful for learning how each works: http://download.oracle.com/javase/tutorial/uiswing/layout/visual.html
Also realize that you can layer layouts by putting on panel inside another. This is sometimes necessary to achieve a desired effect while keeping things simple.
For your last question, buttons can just be added to a panel that can bee adding to additional panels before a frame.
First off take a look at Mig Layout. This is a real full featured layout manager and currently is the best one available. If for some reason you can't use external dependencies then you will want to look at GridBagLayout. GridBagLayout will be powerful enough to do everything you need, but it is not as easy to use as something like Mig Layout.
In 99% of the applications you will build you will have a single JFrame and just transition the JPanels to show the different screens.
First off, one of my rules of thumb when building UI panels is to never set directly any location or size.
Then, a second rule is to never set any preferred, minimum or maximum size directly in pixels (thus will bite you when you change from one monitor to another one, with higher or lower DPI resolution). Take a look at this post on my blog, quite old but still useful today.
Thirdly, I try to avoid embedding panels into panels because it leads to components alignment problems and inconsistent component sizes.
Finally, I try to use DesignGridLayout for most of my forms, and sometimes revert to GridBagLayout if the UI layout is too complex (but a complex UI layout may also be a sign of poor UI design).
As a general comment about how to build UI applications (with any UI toolkit in general, but with Swing in particular), there are several recommendations that exist out there, but it is hard to find concrete implementations, you have to read a lot about these, and then try to find the way that works best for you.
Yes, welcome. Compared to HTML /Javascript/CSS you can get nothing like the sophistication and polish for the equivalent level of time spent learning.
(I haven't sourced all the files for you for anything here - google and start looking up).
Swing, in my experience definitely feels like I read 10 million documents, played with some demos, and spend three or four months nightly for 2-3 hours, and you have some idea of how some of the api's work, and then have no idea why some don't. Its great. You want something to work and then implement that, and proceed to f*ck up the rest of your gui.
Java swing, in my opinion, is desperately crying for an open source JQuery type plugin library that will animate your JComponents and render them in a way that you like. Its a definite second class citizen on the desktop, and especially now that CSS / HTML browser rendering sophistication has improved over the last few years.
The nimbus look and feel style is an improvement definitely in the right direction.
You could also move over to JavaFx. Good luck. Apparently its quite nice. I haven't yet had the time or patience.
If you are allowed to use thirdparty library : try JAXX as an option. The idea was to create a css type implementation, where styling elements are separated into a file that can be quickly configured and tested.
Read here for good introduction: today.java.net/pub/a/today/2006/03/30/introducing-jaxx.html
JavaCSS is found in the JAXX project. JAXX is a xml format style implementation of the swing gui interface. You write an xml document, and a css style document, and are able to bind the inputs and outputs of the GUI to your java implementation engine. The css style document allows for rapid sophisticated gui development. Using the jaxx jar engine, the xml code is converted into java code that runs as rapidly as if deployed in a .java class file.
The project has been continued by a French group of programmers and is now to be found here: http://www.nuiton.org/projects/jaxx/files
The demo is at least pretty and most things seem to work.
The latest release is JAXX 2.4.2. The latest update was May or June 2011. Whilst in French, the documentation is still comprehensible in English. Just translate.
The original ethan nicholas files of jaxx were last updated on 17-07-2009
http://sourceforge.net/projects/jaxx/
Please note: www.jaxxframework.org/wiki/Main_Page is a dead link, the site is discontinued. instead a mirror has been made and can be found at: buix.labs.libre-entreprise.org/original-jaxx/www.jaxxframework.org/wiki/Main_Page.html
This documentation is essential to understand the meaning and purpose of jaxx and its use.
If you are patient, have lots of time, and are interested, also look at the timing framework by Chet Haase, to animate your components, it is possible to create sophisticated effects. It requires learning curve and time.
Or pay to get your gui components handled by a professional third party library? (Um, the obvious answer, no-one who has spent the time and effort to learn to create a pretty gui is just gonna hand that over).
So spend three years learning and then ask for moola from others?
Another idea - I am very into exploring but it looks like it might be a nightmare to implement, despite everyone saying its so easy, get an open source webbrowser html / csss renderer embedded, and design your gui on that, using CSS / JQuery / HTML.
But it looks like you have to first compile the web browser (mozilla) from source, and then wrap that in another program (e.g. JRex) and then put the whole thing in a mini- client server like Jetty, just to have a front end implementation that you halfway like.
And that is only if the browser is actually is as compliant with the CSS2 standard and HTML4. Forget about HTML5. That is for the future.
Okay, I am grumpy today, but I don't think the gripes are completely unjustified.
I've seen other answers and hacks around to this question, but none seem to do exactly what I'm after.
Essentially, I'm after a JWindow whose background is translucent but the content of the window itself (buttons, text and so on) are opaque. The methods I've seen so far fall into one of two categories:
Taking screenshots from behind the window and using them (http://onjava.com/pub/a/onjava/excerpt/swinghks_hack41/index.html) - this isn't much good in this scenario since it's too slow, I want to be able to put things like video behind the window and have it show through
Making the whole window translucent (including the components on it which I need to remain opaque.)
Is what I'm asking for possible, and if so how would it be done? If not, will Java 7 provide any methods that would make this easier / possible? I know it's got more support built in for shaped windows so I wonder whether something there could take care of this also. I've been searching around for a while now but with no luck.
Can only be done if you are using JDK 6 update 10 and above. Must also support hardware acceleration. See
http://download.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html
Hopefully no one has asked this question - didn't see it, but I apologize if it's a duplicate.
Anyway, I'm building some plug-ins with Eclipse RCP and am using SWT for my UI. I have a Composite that contains some panels and other items - anyway, I've noticed a bit of a difference in the appearance of the UI depending on how my OS is set up.
I'm running windows XP but am using the "classic" look/feel which is that of Windows 98. When it's like this - the UI looks fine; however, when I switch to the newer XP look/feel with that tacky blue bar and what not - labels and borders in my composite are different.
Is there a way I can force SWT to use the classic look/feel?
You need a javaw.exe.manifest bound to your application.
Here is an article that describes the problem:
http://www.javalobby.org/forums/thread.jspa?threadID=15414&tstart=0
I think it is a design decision of SWT to make it inherit the platform look and feel. I imagine this is partly to address the usual "java apps look rubbish/out of place/different" comments and partly to make it easier to load the relevant fragments at startup.
I don't know of any way to override the standard values.
Does them being different somehow interfere with the operation of the application? SWT is designed to inherit your user's preference for UI presentation. This is basic HCI - let your user decide what is tacky.
I am creating an application that is essentially a financial alerts site. I am a basic level Java programmer, and I have created some of the logic for alerts in Java.
I want to be able to have pop-ups appear on the desktop whenever something "interesting" happens (interesting depends on %change, liquidity and a few other simple factors).
What is the best combo of technology to implement something like this?
I would use the java.awt.SystemTray in Java SE 6. It's cross-platform and pretty easy to use.
Although some people hate the balloon notifications in Windows, they're the least obtrusive popups, since they can be ignored by the user or easily dismissed. Most importantly, they can't be missed by the user who has been away from the computer, because balloons (at least in Windows XP/Vista) use system idle timers to determine when's the right time to disappear.
Some prefer more traditional toast notifications, similar to those shown by Outlook - they show up and slowly fade out, giving the user some time to interact with them if needed.
I had the same problem and finally solved it using an undecorated, alwaysOnTop window.
And thanks to this blog entry I found the TimingFramework, and now it even is translucent, fades in and out, goes 100% opaque on mouse over etc. In conjunction with the SystemTray and TrayIcon the behavior is nearly as that of Outlook.
Oh, I have to note, that other than the second link, I do the fading out with
AWTUtilities.setWindowOpacity(window, op);
You could write a java program that resides in the system tray, but I am not sure if there are cross platform compatible ways to do this. maybe you have to use a platform specific library for Win, Mac, Linux, ...
I'd just create a message window and animate it. Then add SystemTray support and voila, you're done.
In Delphi you can do that pretty quickly, but you can't easily reuse your java logic
You can just run you program in "silent" mode, without creating any windows by default, maybe just a little icon in the taskbar which when double-clicked will open a settings window. The program will be running in the background and creating windows with the set focus whenever an event happens.
But in my opinion, a slide window or at least a balloon tooltip is a better idea.