jlayeredpane


why is paintComponent() never called by repaint()?

有些话、适合烂在心里 提交于 2020-01-25 05:59:10
问题 I've been working on an program that draws custom JComponents onto a JLayeredPane however all calls to repaint() on the components seem to do nothing yet the paintComponent method is invoked automatically when the window is re-sized. I have been following some of the advice given here: Why is paint()/paintComponent() never called? But none of the solutions seem to fix my problem, update swing components on the EDT, setting component size manually before calling repaint(), calling super

why is paintComponent() never called by repaint()?

北战南征 提交于 2020-01-25 05:57:44
问题 I've been working on an program that draws custom JComponents onto a JLayeredPane however all calls to repaint() on the components seem to do nothing yet the paintComponent method is invoked automatically when the window is re-sized. I have been following some of the advice given here: Why is paint()/paintComponent() never called? But none of the solutions seem to fix my problem, update swing components on the EDT, setting component size manually before calling repaint(), calling super

JSplitPane in JLayeredPane

倖福魔咒の 提交于 2020-01-05 09:01:11
问题 I want the right content of an JSplitPane to fill the entire available space and the left content (panel) to be on top of the other panel. I was thinking about using a JLayeredPane to solve that problem but I couldn't get it to work. My class currently looks like this: public class LayeredPane extends JLayeredPane { private Component topComponent; private Component mainComponent; public LayeredPane() { setLayout(new GridBagLayout()); } public Component setTopComponent(Component c) { this

How to use JLayered Pane to display an image on top of another image?

一笑奈何 提交于 2019-12-25 01:46:37
问题 We are working on a pacman game and we want to add a picture of pacman on top of the background. If someone could provide some example code of implementing the Jlayered Pane that would be great. Here is some of the code we attempted to write. When we try to run it, nothing displays: JLayeredPane pacman = new JLayeredPane(); pacman.setPreferredSize(new Dimension(576, 655)); ImageIcon sprite = new ImageIcon("C:\\\\Users\\\\16ayoubc\\\\Desktop\\\\Pacman-moving.gif"); ImageIcon background = new

Introducing JLayeredPane to an existing JFrame

馋奶兔 提交于 2019-12-24 10:59:02
问题 I've been staring at Oracle's JLayeredPane tutorials but they are laid out in a manner that is confusing to me and doesn't get at what I am trying to do. I have an application that up to now has had no concept of layers. Everything is laid out in a single layer, inside a JFrame. I now want to introduce a component that appears sporadically, as needed, in a certain location, overlaying existing components that stay there normally. Do I have to modify my existing application JFrame so that all

Java Swing JLayeredPane not showing up

旧街凉风 提交于 2019-12-24 05:06:28
问题 I seem to be having some major issues with JLayeredPane . I have a BorderLayout() pane, and I'd like for the West-side element to contain a few JLayeredPane's on top of each other, so I can switch between them to show the right information. The west pane should be 200 pixels wide and should be as long as the total window is. In my sample code I have added two layers to the JLayeredPanel , but they don't show up. They should be in the west pane. Here is my code: import java.awt.BorderLayout;

Making JButtons overlap

六月ゝ 毕业季﹏ 提交于 2019-12-21 05:25:13
问题 I'm creating a virtual piano type program in Java Swing. My area for the piano keys right now is a JPanel with a horizontal BoxLayout containing white JButtons as white keys. I want to add black keys as well, and have them overlap the white keys. There are two different approaches I've tried. One is using the OverlayLayout. Unfortunately there isn't much documentation online for the OverlayLayout manager, and it's not available in the NetBeans GUI builder. I don't have a clue how to make it

JLabel and JLayeredPane - How to display an image over another image?

拜拜、爱过 提交于 2019-12-21 05:16:10
问题 I try to create a little game in java but I'm in trouble. When I draw a map, I'm not able to display the characters without overwrite the titlesets of the squares. My goal is to be able to display many pictures on the same square (like the titleset of the grass, the character and a tree), so I have to deal with the transparency of my pictures (this is not the problem) and the layer (it is the problem). So how can I display an image on another image? How can I explain to java that I need to

JLayeredPane with a LayoutManager

瘦欲@ 提交于 2019-12-20 02:29:11
问题 The situation: drawing a stack of playing cards, like in the Solitaire game. Nicely stacked. To achieve this, I'm using a JLayeredPane in combination with a custom implementation of the LayoutManager interface. The reason for using a custom LayoutManager is that the stack orientation varies, sometimes the playing cards cover each other completely, sometimes partially, and this logic seems to be a good job for a LayoutManager, because this basically boils down to setting the location of the

Line not appearing on JDesktopPane

橙三吉。 提交于 2019-12-19 12:28:39
问题 I want to draw line between two JPanels but line is not appearing on layeredPane. This is what i have done please go through it, compilable.Do try and correct this code. I have tried on drawing lines on Internal frames this way but it is not working for JPanels. package build; import java.awt.BasicStroke; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Point;

工具导航Map