*SOLVED:I made a Jframe with a specific background that I need. I found on Youtube that if I want to have a picture for background,you have to choose Null Layout.I did it,and when I run my program then the window remains small(not at normal size) at left corner on my screen. I need Null Layout because I use other labels up to Label,which I use as background.I have almost done with my project,and I have only this problem.Any idea?
Thank you!
**I found the solution. You can choose Absolute Layout and it has no problem !!!
Related
I am trying my hand in swing applications and would like to know if there is a way to increase the height of the title bar of a JFrame/JDialog?
And also Can I get rid of the Swing icon and replace it with an icon of my own choice?
Sorry if this is a repeated question/too silly , I just haven't found a suitable answer anywhere yet :( Thanks !
.. if there is a way to increase the height of the title bar of a JFrame/JDialog?
Given that wold make that one app. inconsistent with all the other apps. that open on this machine, I'd sure hope not. (And as far as I know, 'no it is not possible'.)
Can I get rid of the Swing icon and replace it with an icon of my own choice?
See JFrame.setIconImage(Image).
can someone tell me how i can fix this padding/shadow like effect around my MenuItems?
I dont know the Name of it so a research was hard without an exact name of it:
http://imagizer.imageshack.us/v2/150x100q90/901/GyPRgA.png
This gradient isn't part of my stage background its a background which opens with the Menu like a Container holding the Menu.
Sorry guys its hard to explain hopefully you can help me.
The screenshot i cant post fully since i got only 1 reputation so i add a link to it
Thanks in advance.
Since i was playing around trying to figure my problem while waiting i felt onto the solution for it.
For those which have the same Problem:
Solution:
Since the new Modena style is used by default, the context menu's are styled with a drop shadow / Gaussian blur effect, which made when opening the Menu it gave some kind of strange effect when using an other background on the stage.
To solve this its only needed to overwrite(resetting) the style..
in my case it was the follow one which i needed to overwrite in a new css file.
-fx-effect: dropshadow( gaussian , rgba(0,0,0,0.2) , 12, 0.0 , 0 , 8 );
I have a graphical editor written with GEF. In this editor it's possible to drag and drop elements around and create connection by dragging and dropping on specific anchor points.
Everything works fine, except that the diagram does not automatically scroll when the user drags stuff around.
I would expect the diagram to scroll automatically when the user reaches the side of it while dragging something.
Is such a feature supported by GEF? Which class/setter should be called to enable it?
If it's not directly supported, how to proceed to achieve it?
It's been a while since I last fiddled with GEF.
Does drag and drop not work at all or just in the direction of negative coordinates?
What Layout are you using?
IIRC, there were different layouts with one of them (FreeForm?) supporting negative coordinates, so if you just have trouble with negative coords, you could try to change the Layout.
Here is an example of a Scrolling Graphical editor (the author says ;)) which might give you a good hint.
And there is a class named org.eclipse.gef.ui.parts.ScrollingGraphicalViewer that might help, too.
Only hints, though, since I don't know your code.
First step is to make your canvas scrollable. This is explained in this book, pages 96 - 101.
Assuming you are already drawing your figures on a FigureCanvas and you're using FreeformFigures and FreeformLayer, you can do the following:
Add a MouseMoveListener on your Figure in its EditPart. Each time a drag is detected, in the mouseDragEvent method, reveal your figure with getViewer().reveal(EditPart.this).
This will cause your Figure to always be constantly revealed when it's being dragged.
I use XMonad+gnome as window Manager. I have the problem that, when I run a Java Web Start applicacion, It olways show an empty window, like the screen:
Is there something I can do to fix it?
UPDATE:
I tried simple programs from JWS Examples and it works, right. So it should be a problem of the application.
The failed aaplication is Blast2Go.
Change the name of the window manager to a known one like LG3D:
startupHook = setWMName "LG3D"
I had the exact same problem with my own Java code and using the other suggested solutions (setWMName, MToolkit, etc.) did not solve the problem with Xmonad. I must note that in other window managers (e.g. fluxbox), the app works as expected. In my case, however, I figured out the problem. If you have access to the source of the Java app, I suggest you consider the following:
If you have any JFrame or JPanel or other containers, you should explicitly define their layouts. If you set the layout to null, then the dimensions of the container must be set explicitly. Otherwise, the container won't be rendered at all. For instance, I have a JPanel that contains all my widgets. I'd rather have full control over the layout, so I set the layout to null, and then explicitly set the dimensions for the JPanel:
jContentPane.setLayout(null);
jContentPane.setPreferredSize(new Dimension(appletWidth,appletHeight+100));
Hope this helps.
I try to build a gui (Swing) for a simple java application. The application should have a start window like a menu. From there I would like to navigate to several other windows.
My question is what is the best-practice to achieve such a navigation? Should I build several JFrames and switch the visibility of them on/off when navigating OR should I better have one JFrame and add/remove JPanels in this single frame to navigate between the windows?
Thanks.
I recommend
Do not do a MDI application with sub-frames like those found in the old Windows days. They suck as they make the matter confusing.
Do design a tabbed interface. The welcome page/menu will be displayed on a first tab that is always created on the start.
All cool kids do that nowadays:
Visual Studio
Eclipse
Firefox
If each of your windows correspond to different task (possibly nested), you could present your application as a SDI, with on the left a task panel like:
Each of the task would display one JFrame with the associated window.
Other solution: a table of content like this picture on the left side
(note: it actually also displays a task panel in this example on the bottom right)
Multiple JFrames sounds like a better idea to me. Much more OO.
You must find a balance between these goals:
Not too many things in one "window"
The user must quickly be able to find the correct window to do the next step of work
All relevant information must be visible at any time
Eclipse solves this by creating many small editors where each editor shows some specific information and allows to modify it. Editors are then arranged within one OS window in tabs and "views". A view is always completely visible and they can be arranged. Think of a view as a way to cut an existing editor in half (horizontal or vertical) and then being able to replace one of the halves with another editor. Between each half, you have a splitter so you can adjust the sizes.
Arrangements of views are then saved in "perspectives".
This allows every user to create a perspective which contains all the necessary editors at the same time, arrange them as they need it and work effectively.