jlayeredpane

Is repaint executing too slow?

拜拜、爱过 提交于 2021-02-10 19:48:15
问题 I have the following: import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JLayeredPane; import javax.swing.JFrame; import javax.swing.BorderFactory; import java.awt.event.MouseListener; import java.awt.event.MouseEvent; import javax.swing.ImageIcon; import java.awt.GridLayout; import java.awt.Dimension; import java.awt.Color; import java.util.Random; class Cell extends JLayeredPane { private JLabel image1; private JLabel image2; private JLabel image3; private Random rand;

Is repaint executing too slow?

筅森魡賤 提交于 2021-02-10 19:47:58
问题 I have the following: import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JLayeredPane; import javax.swing.JFrame; import javax.swing.BorderFactory; import java.awt.event.MouseListener; import java.awt.event.MouseEvent; import javax.swing.ImageIcon; import java.awt.GridLayout; import java.awt.Dimension; import java.awt.Color; import java.util.Random; class Cell extends JLayeredPane { private JLabel image1; private JLabel image2; private JLabel image3; private Random rand;

Why does a JButton under a JPanel still react?

让人想犯罪 __ 提交于 2021-02-10 03:27:48
问题 I looked around for my problem, and i couldn't find an answer, so here I go: I have a JLayeredPane, and in there there are 2 JPanels. The deepest one ( furthest down ) has JButtons on there. The second one ( The one on top ) has a partially transparent background color ( although i don't think this should influence it ). Now when I hover over my JButtons ( which are behind the other JPanel ), they still fire events to the MouseListener I added to them. I don't know why... Why is this the case

Why does a JButton under a JPanel still react?

£可爱£侵袭症+ 提交于 2021-02-10 03:24:15
问题 I looked around for my problem, and i couldn't find an answer, so here I go: I have a JLayeredPane, and in there there are 2 JPanels. The deepest one ( furthest down ) has JButtons on there. The second one ( The one on top ) has a partially transparent background color ( although i don't think this should influence it ). Now when I hover over my JButtons ( which are behind the other JPanel ), they still fire events to the MouseListener I added to them. I don't know why... Why is this the case

Java LayeredPane LayoutManager add() Method Conflict

我的梦境 提交于 2021-01-27 11:54:55
问题 Suppose I have a JLayeredPane called mainPanel that is using a BorderLayout . I also have a JLabel called backgroundLabel that contains an image. How would I go about adding the backgroundLabel to the bottom layer of mainPanel ? mainPanel.add(backgroundLabel, new Integer(-1), new Integer(0)); The above line seems like the obvious answer, and would work if the mainPanel was using a null layout. The BorderLayout in mainPanel is not liking the command and gives the following stack trace.

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