I have a custom window that extends com.vaadin.ui.Window, inside the window I put com.vaadin.ui.TabSheet and into the TabSheet couple of custom components that extend com.vaadin.ui.VerticalLayout.
Everything is correctly placed inside, but the window appears totally minimized. How to extend it to show all contents properly, but without using .setSizeFull() as I dont want to stretch it to whole screen?
I tried .setSizeFull() to TabSheet and its contents, but that didn't helped at all.
Setting custom height and width for the Window works, but this is not what I intend to do...
As it was said in the comments area, a Window must have a size.
I myself would have preferred that the window adapts itself to the screen size or browser size but that is how it works.
Related
I have a JDialog that contains a large number of options and it was all working fine, however I have changed it so that by default some options are non visible until the unless the user clicks on the Show Advanced button.
When they they do this the options are displayed but because the dialog is not tall enough since it was sized based on those options being hidden a vertical scrollbar is added.
I want the dialog to be sized so large enough for when the advanced options are enabled. I have attempted this by creating the dialog with the advanced option displayed, calling pack() to fit based on advanced options being visible
this.pack();
showAdvancedAction.actionPerformed(null);
and then afterwards calling method to make advanced options invisble.
But still when diplayed the dialog is only large enough for when the options are not shown so when click on Show Advanced the dialog adds scroll bar again.
How can I resolve this.
this.pack();
showAdvancedAction.actionPerformed(null);
You have the order reversed. You need to pack the frame AFTER the components have been made visible.
showAdvancedAction.actionPerformed(null);
this.pack();
In java swing you can add buttons or components over the panel. but when you try to resize these then you need to use Grid Layout/ GridLayout class. Try using Grid Layouts and arrange your controls by providing X, Y co-ordinate values. It will definitely work.
On a JPanel I have a few buttons and JScrollPane containing a JTable.
One of the buttons is custom made, I have overridden the paintComponent method to draw an image.
However, if I set the contentAreaFilled or isOpaque properties to false (so that the background is not displayed) whenever I roll over the button the content of the scroll pane is hidden (a grey image appears inside, instead of the table contents). I tried using different layouts for my panel, but got the same result. The only fix I found is setting rolloverEnabled to false for my custom button, but that is not really an option for me, as I want the button image to change at rollover.
The weird thing is, it only happens when I set one of those two properties mentioned above to false. The button acts perfectly if I do not hide it's background. Just out of curiosity, I tried the same on my other two buttons, which are just JButtons with nothing customized, except their size, and it had the same effect on the scroll pane, so I'm pretty sure it doesn't have anything to do with the implementation of the custom button. Has anyone encountered this problem or know anything that may help me with this?
am wondering, if there is a solution for shrinking a charts within browser window, i.a if i resize my browser window my application with highcharts do it well to, it's also resized to the browser window size, but if i shrink my browser window, the app with charts doesn't shrink in size to the browser window size, it only do it when refresh the whole web page, but i need it to be able to do it automatically when you shrink the browser window, the window content also shrinks to the browser sizes, am using java with UiBinder DockLayoutPanel inside RootLayoutPanel. Would be very thankful for any suggestions.
Without specific code examples a specific answer is difficult to give. But to react to browser resize you need to implement the onResize() method. The layout panels you name call this method on children that implement the interface RequireResize. So the panel with the chart should implement the onResize(), and resize the chart. Make sure the parent tree of this widget all implement onResize() or else the method won't be called.
Yes it is possible example (note that I am not using moxie but another wrapper ) : http://data-dragon-766.appspot.com/
You can find the class responsible for rendering the chart.
https://github.com/highcharts4gwt/highcharts/blob/master/src/main/java/com/github/highcharts4gwt/client/view/widget/HighchartsLayoutPanel.java
I am developing a Java Swing-based application with different perspectives. For the "main menu" perspective I do not want the window (JFrame) to be decorated, while in other perspective I do want the window to be decorated. In other words, I need want to change the decoration attribute dynamically.
I have tried to use setUndecorated(false) and setUndecorated(true), but I seems I can only set this once, before actually showing the window.
Is there a way to achieve this?
From the javadoc:
Disables or enables decorations for this frame. This method can only be called while the frame is not displayable.
Therefore, once the JFrame is packed and/or displayed, you can no longer change that value. If you want to change the undecorated state of a JFrame you will need to dispose() it first, then change the state and eventually make it visible again.
After all, I had to take a different approach.
The former solution did work, as I stated in my last comment.
However, it was showing the default LAF window decoration, while I was using a different LAF.
So the result was graphically inconsistent with the rest of the LAF. Finally, I came with the right solution, I used setUndecorate(true) for my frame. Then, when I had to change my perspective to one using decorations I simply had to use the following code
contentPane.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
And when I had to revert to the non decorate perspective, I use
contentPane.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
This approach didn't need to dispose the window and show it again (which actually produced a brief but still visible hide/show of the window)
I have an open-source java swing application like this:
http://i47.tinypic.com/dff4f7.jpg
You can see in the screenshot, there is a JPanel divided into two area, left and right area. The left area has many text links. When I click the SLA Criteria link, it will pop-up the SLA Criteria window. The pop-up window is JFrame object.
Now, I'm trying to put the pop-up window into right area of the JPanel, so that means no pop-up window anymore, i.e. when I click the SLA Criteria link, its contents will be displayed at the right area of the JPanel. The existing content of the right area of JPanel will not be used anymore. The concept is just same like in the java api documentation page: http://docs.oracle.com/javase/6/docs/api. You click the link in the left frame, you'll get the content displayed at the right frame.
The example illustration is like this:
(note: it's made and edited using image editor, this is not a real screenshot of working application)
http://i48.tinypic.com/5vrxaa.jpg
So, I would like to know is there a way to put JFrame into JPanel?
I'm thinking of using JInternalFrame, is it possible? Or is there another way?
UPDATE:
Source code:
http://pastebin.com/tiqRbWP8 (VTreePanel.java, this is the panel with left & right area divisions)
http://pastebin.com/330z3yuT (CPanel.java, this is the superclass of VTreePanel and also subclass from JPanel)
http://pastebin.com/MkNsbtjh (AWindow.java, this is the pop-up window)
http://pastebin.com/2rsppQeE (CFrame.java, this is the superclass of AWindow and also subclass from JFrame)
Instead of trying to embed the frame, you want to embed the frame's content.
There is (at least) one issue I can see with this.
The menu bar is controlled by the frame's RootPane.
Create you're self a new JPanel. Set it's layout to BorderLayout.
Get the menu bar from the frame (using JFrame#getJMenuBar) and added to the north position of you new panel.
Get the frames ContentPane and add it to the center position of the panel.
There is undoubtedly countless other, application specific issues you will run into trying to do this...
No, you don't want to "put a JFrame into a JPanel" and your illustration above doesn't demonstrate this either. Instead it's showing a subordinate window on top of (not inside of) another window. If you absolutely need to display a new subordinate window, I'd recommend that you create and display a JDialog. The tutorials will explain how to do this, or if you get stuck post your code attempt and we'll help you work with this.
Edit 1
You state:
I need to convert from the pop-up window style into the jpanel content style. It's just like the java api documentation page style: docs.oracle.com/javase/6/docs/api When you click the text in left frame, it doesn't show any pop-up, right? The content is displayed at right frame directly. So that's basicly my goal. The source code is quite big. I will try to paste the source code if possible.
What you are looking for is to simply implement a MouseListener in a JList or JTable, and when responding to the click get the content based on the selection made. This has nothing to do with placing a JFrame in a JPanel and all to do with writing the correct program logic. Again, display it in a modal JDialog -- but that's all secondary to your writing the correct non-GUI logic. You're really barking up the wrong tree here. Forget about JFrames, forget about JPanels for the moment and instead concentrate on how you're going to extract the SLA Criteria data when it is clicked on.
Edit 2
I think I see what you're trying to do -- instead of JFrames and JDialogs, use JPanels and swap them using a CardLayout which would allow you to swap views.
I had skimming the source codes, I saw that the AWindow.java has internal panel (APanel.java) to hold the window's content, and it also has a public method to return the content panel object (getAPanel()). With this, I can use it for fetching the window's contents into other container.
Finally, I decided to use JTabbedPane in the right area of VTreePanel for displaying the pop-up window's contents.
You cannot put a Jframe into a JPanel. Instead you should try to create a separate panel that has functionalities like your JFrame and embed that into your JPanel.
Since you can put a JPanel into another JPanel but not a JFrame into another JPanel