jlayeredpane

Create a form with a background Image (JLayeredPane)

牧云@^-^@ 提交于 2019-12-02 18:11:54
问题 I've been struggling to do something I guess pretty simple : I want to create a form (JTextField) with a background image. In order for the form not to cover the background Image, I'm using a JLayeredPane. I've been trying different stuff, nothing seems to work : for some reason, I'm either displaying only the background, or only the JTextField, but never both. My goal would be to have a background image that never changes, and just use my buttons / textfields on top of it. package gestion;

How to create a Piano using JScrollPane and JLayeredPane

佐手、 提交于 2019-11-29 17:10:44
I need to create a virtual piano containing four octaves using JLayeredPane inside a JScrollPane such that one octave is shown initially, and can be scrolled horizontally to see the other octaves. My code displays only one octave and does not show the scrollbar and the other octaves. What is the problem with the following code? class PianoLayout extends JScrollPane { public PianoLayout() { initComponents(); } private void initComponents() { JLayeredPane layer = new JLayeredPane(); //ScrollableLayeredPane layer = new ScrollableLayeredPane(); layer.setSize(1120,150); JButton[] keys = new JButton

JLayeredPane with a JDialog

南笙酒味 提交于 2019-11-28 14:06:55
问题 I am unable to make any components apear on a JLayeredPane when adding it to a JDialog. I have also been unable to find a web resource that shows this may be done in a reasonably sized block of code. Every sight iv looked at "claims" this can be done, and then shows a disgustingly long solution. What i want is to take a JLayered pane add a Button and place a JLabel with an icon in it onto this pane aswell. In english i want a button with an icon stuck in the front of its text. That is the awt

Drawing in JLayeredPane over exising JPanels

雨燕双飞 提交于 2019-11-28 11:26:13
I am working on developing a Chess game. I want to have the board Container utilize a GridLayout to display an 8x8 grid of JPanels. (This will make functions such as highlighting selected squares and valid moves much easier.) I would then like to add the pieces over this layer so that they may be dragged and dropped. I initially had the pieces showing by drawing them in the individual square JPanels, but figured that would be a problem when trying to drag-and-drop them later. I have since been trying to use a JLayeredPane as the main container, but have encountered several issues. One is that

How to create a Piano using JScrollPane and JLayeredPane

蹲街弑〆低调 提交于 2019-11-28 10:26:19
问题 I need to create a virtual piano containing four octaves using JLayeredPane inside a JScrollPane such that one octave is shown initially, and can be scrolled horizontally to see the other octaves. My code displays only one octave and does not show the scrollbar and the other octaves. What is the problem with the following code? class PianoLayout extends JScrollPane { public PianoLayout() { initComponents(); } private void initComponents() { JLayeredPane layer = new JLayeredPane(); /

How to put a component on top of others?

匆匆过客 提交于 2019-11-27 09:47:51
I have a JScrollPanel that includes a big panel which it's self includes 3 inner panels. i want to put a panel (for example) in a special place so that always could be seen, I mean the user can scroll to anywhere wants but that panel always is in top of the other components and doesn't move. I tried to do that via JLayeredPane but I couldn't. how may I do that? trashgod There's a JLayeredPane example here , but OverlayLayout , seen here , may be of interest. It's not included in the conventional gallery . Also consider this example that paints on the scroll pane's JViewport . You could use The

putting marks on ImageIcon in JLabel

僤鯓⒐⒋嵵緔 提交于 2019-11-27 08:18:47
问题 So I'm trying to find a way to modify an image in Java. In other words, if user clicks on the image, a mark will be put at the point where the user just clicked. I have an ImageIcon which I put in a JLabel. So far, the approach I took was to use JLayeredPanel to put another JPanel on top of the JLabel and draw on this JPanel: //... ImageIcon icon = new ImageIcon("foo.jpg"); JLabel lb = new JLabel(icon); JPanel glass = new JPanel(); lb.setBounds(0, 0, 100, 100); glass.setBounds(0, 0, 100, 100)

Drawing in JLayeredPane over exising JPanels

我与影子孤独终老i 提交于 2019-11-27 06:14:00
问题 I am working on developing a Chess game. I want to have the board Container utilize a GridLayout to display an 8x8 grid of JPanels. (This will make functions such as highlighting selected squares and valid moves much easier.) I would then like to add the pieces over this layer so that they may be dragged and dropped. I initially had the pieces showing by drawing them in the individual square JPanels, but figured that would be a problem when trying to drag-and-drop them later. I have since

JLayeredPane and painting

我只是一个虾纸丫 提交于 2019-11-27 05:21:24
I am writing an application which has a JLayeredPane (call it layers) containing two JPanels in different layers. I override the paintComponent method of the JPanel at the bottom (call it grid_panel) so it paints a grid, and the the paintComponent method of the one at the top (call it circuit_panel) so it paints a circuit. Here's a summary of the structure: layers - |-circuit_panel (on top) |-grid_panel (at bottom) I want the grid_panel to stay static, ie, not to do any repaint (except the initial one) since it does not change. The trouble is, whenever I call circuit_panel.repaint(), grid

How to put a component on top of others?

谁都会走 提交于 2019-11-27 04:01:22
问题 I have a JScrollPanel that includes a big panel which it's self includes 3 inner panels. i want to put a panel (for example) in a special place so that always could be seen, I mean the user can scroll to anywhere wants but that panel always is in top of the other components and doesn't move. I tried to do that via JLayeredPane but I couldn't. how may I do that? 回答1: There's a JLayeredPane example here, but OverlayLayout , seen here, may be of interest. It's not included in the conventional