简体   繁体   English

Java Netbeans:如何将面板彼此叠加?

[英]Java Netbeans: How to layer panels on top of each other?

Please bear with me as I've just started using NetBeans for the first time! 我刚开始使用NetBeans,请多多包涵! Basically what I'm trying to do is create different panels that fit inside one frame, except that only one panel will be visible at a time. 基本上,我想做的是创建适合在一帧内的不同面板,但一次只能看到一个面板。 It'll start with one panel, and depending on what the user inputs, the panel that corresponds to what the user puts in pops up. 它将从一个面板开始,然后根据用户输入的内容,弹出与用户输入内容相对应的面板。

I've tried looking into utilizing LayeredPanes since that's what I've come after hours of researching this only.. I don't understand how to do it! 我已经尝试研究利用LayeredPanes,因为这是经过数小时的研究之后才得出的结论。.我不知道该怎么做! I think using different panels would be much easier than using different frames, so that's why I'm just going to stick with layering panels. 我认为使用不同的面板比使用不同的框架要容易得多,因此这就是我要坚持使用分层面板的原因。

If anyone could explain LayeredPanes, I'd be very grateful! 如果有人可以解释LayeredPanes,我将不胜感激! I'm not sure my coding will help here, but if anyone needs it I'll put it up. 我不确定我的编码在这里是否会有所帮助,但是如果有人需要,我会提出。

This tutorial should point you in the right direction, however, if you want to have items positioned over each other, you might also want to take a look at the CardLayout : 教程应该为您指明正确的方向,但是,如果要使各个项目彼此重叠放置,则可能还需要看一下CardLayout

The CardLayout class manages two or more components (usually JPanel instances) that share the same display space. CardLayout类管理共享相同显示空间的两个或更多组件(通常是JPanel实例)。

Reading your question I dont think that what you need is a LayeredPane , 阅读您的问题,我认为您不需要的是LayeredPane

Basically what I'm trying to do is create different panels that fit inside one frame, except that only one panel will be visible at a time. 基本上,我想做的是创建适合在一帧内的不同面板,但一次只能看到一个面板。

Tell exactly what you want to achieve, I mean on what you are working on. 准确说出您要实现的目标,我的意思是您正在从事的工作。

...and depending on what the user inputs, the panel that corresponds to what the user puts in pops up. ...并根据用户输入的内容,弹出与用户输入内容相对应的面板。

I'd like to suggest a JDialog , show dialogs depending on the user inputs. 我想建议一个JDialog ,根据用户输入显示对话框。 To make sure if this is what you need, you want to provide us with more information. 为了确保这是您所需要的,您想向我们提供更多信息。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM