I have a transparent undecorated JFrame that I set using AWTUtilities.setWindowOpaque(this, false). On the JFrame, I have a scrollpane; it works perfectly on Windows. On the Mac, the whole JFrame is draggable; so when I try to scroll through the scrollpane by clicking and holding the mouse on the scrollbar, the entire frame moves instead of the scrollbar thumb. I also tried to use setBackground(new Color(0,0,0,0)) instead of setWindowOpaque(), but it has the same problem. Any ideas on how to fix this?
As suggested in this similar thread, try:
getRootPane().putClientProperty("apple.awt.draggableWindowBackground", Boolean.FALSE);
If you choose to use this, the scrollbar will be usable and the window won't drag. However, you may be stuck with an immovable window, unless you add a MouseMotionListener and move the window around in the mouseDragged() method using a call like frame.setLocation().
Instead, you might be able to force the user to click on the scrollbar's arrow buttons, rather than drag the scrollbar itself... But that's not the most user-friendly idea I've ever seen.
Related
I have a JPanel v. Function below creates a full-screen Jframe, called window, which will feature this JPanel. I have:
protected final void fullScreenMulti(final JPanel v) {
final JFrame window= new JFrame();
window.setUndecorated(true);
window.add(v);
//window.setVisible(true);
.
.
.
window.validate();
window.repaint();
GraphicsDevice gdev = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
gdev.setFullScreenWindow(window);
DisplayMode mode = gdev.getDisplayMode();
window.setSize(mode.getWidth(), mode.getHeight());
}
This works for the default render that is written for the code. However, selecting the GL renderer which uses JOGL, makes the fullscreen frame blank and I get a white screen. You will have to switch-tab in and out, or press Start for the Panel to be painted. I tried changing the background of window using:
Container c = window.getContentPane();
c.setBackground(Color.yellow);
that doesn't do anything though and I still get a white screen. (Although when i debug, I can see that the background property is successfully applied.)
Also clicking on the blank area of a second screen(The window is hosted on the first screen), or even clicking the Start button, SOMETIMES makes the frame go Black and my mouse adaptor fails to work afterwards. (what exactly could be happenning here, how can I investigate it?) Other times, it has the same effect of Alt-tab.
Haven't done much Swing stuff in Java and a I'm bit lost. Seeing that it seems to be working fine on one renderer and not on the other, suggests that it has something to do with the GL renderer, but the renderer works fine when rendering JPanels in my non-full screen mode; Also my understanding is that the role of the renderers is merely to buffer the video that is featured on my JPanel.(I mean that's what renderers do, right?) so it is probably a case of some setting not being specified above, but the original renderer takes care of it. Any suggestions what that might be?
edit: needless to say, taking out window.add(v) will make the frame render fine and the result of changing frame background etc. that was previously not working, will now be visible on the frame.
This is a known problem. -Dsun.java2d.noddraw=true solves it.
I'm making a microwave simulation program and having an annoying problem. I want the microwaves viewing window to change color on a button press, to visualize that the microwave is on. However, because I also have a jlabel with an icon (food image) in the background, I need the background to be semi transparent. I've accomplished this adding an alpha value to the jPanel (cookingWindow).
It starts like this
So what I've basically done is set an actionEvent to the start button with the following code.
cookingWindow.setBackground(new Color (250,234,1, 150));
cookingWindow.repaint();
This works, except this happens
When I minimise and maximise the window, everything goes back to place. But obviously, it would be preferable if you didn't have to minimise the window. Any ideas on how to stop this visual bug?
See Backgrounds With Transparency for an explanation of the problem and a couple of solutions.
Basically the problem is how the Swing opaque property handles transparent backgrounds (it doesn't).
Revalidating and repainting the jFrame seems to do fix everything up. I was previously only repainting the jPanel.
How to disable iconified button in JFrame Window ?
something like setResizable, but for minimize button
At First, you can use the method setUndecorated(boolean). It may disable the title bar and the border.
In the end, you will create the icon label and close button at your frame top or the others position.
But this way will lose the border look and feel for the frame. If you choose this way, you must create a lot of code.
In fact, If you could not use JNI, this way may be the only.
You could use a JDialog, which natively does not have a minimize button.
In fact, the minimize, close and maximize/un-maximize buttons are drawn by the Operating System itself. This means you can't really disable them within Java.
That's why my suggestion is to use a JDialog.
I have a JScrollPane and a JPanel inside. I see the scrollbars when needed, but the mouse wheeling works only when the mouse is over the scrollbars. Is there a property or something to make mouse wheeling work when the mouse pointer is over the whole panel, not just the scrollbars? You know like in browsers - you can scroll the page even if the mouse pointer is not over the scrollbars.
Thanks in advance!
It works for me (Java 6, Windows, JScrollPane containing a JPanel, mouse wheeling over JPanel). JPanel with rounded 100 pixel borders, min size 1000x1000, preferred size (4000x4000).
So I guess, that your existing code interferes. Try a separate example, and then rework your app.
Make sure main window(possibly a JFrame) implements Scrollable.
I am implementing ToolTip in Java as to make users having an easier time to use the product. Though tooltip that are at the borders of the JFrame and ends up outside the JFrame starts to "flicker". I've tried lots of things (like moving the tooltip so it should be inside the Jframe, controlling the painting so it ends up within the JFrame and so on) though it doesn't work.
Anyone got any expertise within the field that know how to avoid this problem?
Cheers,
Skarion
When a tooltip is displayed in a JFrame, Swing does not create a floating window, it simply paints the tooltip in the graphic context of the JFrame. This does not generate any flickering.
On the other hand, when a tooltip is outside the boundaries of the JFrame, it becomes heavyweight: a window is created to host the tooltip component. Flickering occurs when the tooltip window appears.
Maybe setting "-Dsun.awt.noerasebackground=true" would help because it prevents one step of background repainting of the hosting window.