jlayeredpane

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;

Component layering Java Swing, Layers showing on hover

[亡魂溺海] 提交于 2019-12-14 02:07:32
问题 I have two JPanels layered on top of each other in the same container. I am using container.add(jpanel,0); and container.add(otherjpanel, 1). It works fine however in order for the top layer to show I have to hover over the components with the mouse. Here is some executable code showing my problem. Just hover mouse on upper part of screen. import java.awt.*; import java.awt.event.*; import java.awt.image.BufferedImage; import javax.swing.event.*; import javax.swing.*; import javax.swing.text.

JLayeredPane not drawing

僤鯓⒐⒋嵵緔 提交于 2019-12-13 18:14:41
问题 Good day, Hopefully this is a quick kill question. I am writing an application that uses JPanels and JLayeredPane inside a JFrame. On the initial start of my application, one of the panels does not show up until my mouse moves over the area where the panel should be. I even call the validate and repaint methods, but I am still able to display both panels together. Any suggestions? Thank you. Here is my JFrame class (which has the main method) import java.awt.Dimension; import javax.swing

JLayeredPane with gridlayout?

我是研究僧i 提交于 2019-12-13 09:50:08
问题 Is there a way for me to add buttons to the right side of my JLayeredPane? The layered pane contains a JPanel which represents a chess board and on top of this board I have JLabels representing chess pieces. I want basically another panel attached to the right side of the board which contains player information and buttons allowing for rematches/etc. What would be the best way to go about adding this panel? Here is a snippet of my code. The part which sets up the board panel inside the

Top layer in JLayeredPane not displaying

◇◆丶佛笑我妖孽 提交于 2019-12-13 04:20:34
问题 I'm trying to create a panel that uses a JLayeredPane to have a panel centered above another, larger panel. I can't seem to get the smaller panel to display though. Any ideas as to what I'm doing wrong? import java.awt.Dimension; import javax.swing.BoxLayout; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLayeredPane; import javax.swing.JPanel; public class MainPanel extends JPanel { private JLayeredPane pane; private AllPlayersPanel players; //Larger panel,

How do I make a JSlider background transparent? or How do I properly overlay JComponents in JLayeredPane?

旧巷老猫 提交于 2019-12-13 02:26:22
问题 I am trying to overlay a JSlider on top of a JProgressBar. I am using a JLayeredPane to hold the two components. I am adding the JProgressBar to the JLayeredPane and then adding the JSlider. So far, I have attempted to make the JSlider transparent by setting opaque to false and overriding the paintComponent method. What I end up with is that the slider handle is the only part that becomes transparent while the background stays opaque. It is possible that I am not using the JLayeredPane