jlayeredpane

Multiple JPanels completely on top of each other

懵懂的女人 提交于 2019-12-12 12:12:01
问题 I am creating an program in which I can draw a map and add different roads etc to it. I have planned to add the map terrain on one jpanel, and the roads etc on another, on top of each other. But I can't get them to work. I don't know how to add multiple jpanels completely on top of each other and making them all able to draw. 回答1: The basic approach to this problem would be to use a JLayeredPane and something like GridBagLayout . The JLayeredPane will give you some better control over the z

Java Swing: combine effects of CardLayout and JLayeredPane

两盒软妹~` 提交于 2019-12-11 10:37:23
问题 I am trying to place some JPanel s one on top of the other, completely overlapping. I use JLayeredPane to have them in different "depth" so I can change the depth and opacity to see a certain panel "under" another. Here is a small test I did which is working properly: public class LayeredCardPanel extends JPanel { private static final String BLUE_PANEL = "blue "; private static final String RED_PANEL = "red "; private static final String GREEN_PANEL = "green"; private String[] panelNames = {

No idea where compiler errors are forming when using JLayeredPane

你。 提交于 2019-12-11 10:26:50
问题 So, in my last question ("Can't figure out how to overlap images in java") I was kindly advised to utilize layout managers and the JLayeredPane. However, after studying the demos, and forming my own code, I have a whopping 34 compiler errors. The compiler errors are consistently "" so there's probably something wrong with importing. However I copied the import list exactly from the LayeredPane Demo. Once again, I am stumped. And also once again, I thank anyone in advance for advice! import

JLayeredPane, background image + “icon” layer

╄→尐↘猪︶ㄣ 提交于 2019-12-11 08:37:17
问题 I need 2 separate JPanels (or any lightweight components) on top of each-other and ultimately embedded within a JPanel, either directly or through something like a JLayeredPane. Thus, no heavy-weight components or glass pane. The lower JPanel (named BackgroundPanel) paints a background image or plays a video while maintaining aspect ratio and using an alpha. The upper panel (called CompassPanel) has icons on it and allows the user to add icons, delete them, and move them around (like a

JLayeredPane and GridBagConstraints

佐手、 提交于 2019-12-11 08:13:40
问题 Inspired by this question JLayeredPane with a LayoutManager I'm trying to get the JLayeredPane to work with the GridBagLayout. Here's the custom LayeredPane-class: class StackConstraints { public final int layer; public final Object layoutConstraints; public StackConstraints(int layer, Object layoutConstraints) { this.layer = layer; this.layoutConstraints = layoutConstraints; } } class LXLayeredPane extends JLayeredPane { private static final long serialVersionUID = 1946283565823567689L;

Automatic content resizing of JLayeredPane

我怕爱的太早我们不能终老 提交于 2019-12-11 01:28:00
问题 I'm trying to create an app with a JLayeredPane that scales automatically with the size of the parent JFrame (this is the easy part using BorderLayout as layout manager on the frame's content pane). The hard part is the fact that I want the content of the JLayeredPane to automatically resize with the JLayeredPane (and thus the JFrame too). In fact the functionality I want to achieve is a lot like the dockable console in Netbeans, that just like comes "on top" of the editor when clicked, and

Resize JFrame to JPanels inside JLayeredPane

与世无争的帅哥 提交于 2019-12-11 00:59:39
问题 I'm working on a Swing GUI using the JLayeredPane . The JFrame has a JLayeredPane which contains two JPanel s. Later I want to display some components in the JPanel s, I cut this part of the code to make it shorter for you. How do I resize the JFrame to the sizes of the JPanel s? frame.pack() does not work and without the line setting the preferred size the GUI will show with minimal size. import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt

Drag and Drop from JTable to JLayeredPane

倾然丶 夕夏残阳落幕 提交于 2019-12-10 18:06:57
问题 How to create Drag and drop between JTable and JLayeredPane . Does anyone have any ideas how to implement this? I need transfer object by Drag and drop between JTable and JLayeredPane . 回答1: You have to do a few things at minimum to get this to work: Call setDragEnabled(true) on your JTable instance Set the JTable s and JLayeredPane s DropTarget Create a draggable Component to add to the JLayeredPane To set a Component s DropTarget , call the setDropTarget(DropTarget d) method and pass an

How to rotate a buffered image without cropping it? Is there any way to rotate a JLayeredPane or JLabel?

风格不统一 提交于 2019-12-08 03:36:56
问题 I had searched about it but I did not get straight forward answer. I want a buffered image to be rotated but not cropped I knew the new dimensions are gonna be some thing like this int w = originalImage.getWidth(); int h = originalImage.getHeight(); double toRad = Math.toRadians(degree); int hPrime = (int) (w * Math.abs(Math.sin(toRad)) + h * Math.abs(Math.cos(toRad))); int wPrime = (int) (h * Math.abs(Math.sin(toRad)) + w * Math.abs(Math.cos(toRad))); Provide me a method for that. BTW is

Java Swing: Clearing custom painting from a JPanel overlayed with other JPanels in a JLayeredPane

被刻印的时光 ゝ 提交于 2019-12-08 00:44:23
问题 I've got a JLayeredPane containing three JPanels, two of which overlap, that I'm painting shapes to. One of the two JPanels that overlap needs to have every shape drawn to it cleared without affecting the shapes drawn to the JPanel under it disappear from the screen. Currently I'm using something like this: Graphics g = pane2.getGraphics(); g.clearRect (0, 0, 1000, 1000); But this not only clears everything painted to pane2 but also pane1, which is under it. So my question is: Is there any