什么是构建我的程序的最佳方法? [英] What would be the best way to construct my program?
问题描述
这是我第一次自己尝试建立一个完整的程序,到目前为止,我只是做个别的方法和单一的课程,所以我想听听你的想法和建议,将是什么创建我的GUI /程序的最佳方式。
It's the very first time I am going to try and build a complete program on my own ,up till now I have only been making individual methods and singular classes so I would like to hear your thoughts and suggestions on what would be the most optimal way of creating my GUI/program.
这个想法是我有一个 JFrame
c $ c> JTabbedPane 作为contentpane。
The idea is that I have a JFrame
with a JTabbedPane
as contentpane. The JTabbedPane
in turn exists of several other panels.
我正在想一个正常的类文件,我从哪里将获取我需要的一切。
我将为框架单独创建一个类,另外另一个类为 JTabbedPane
而不是一个新的类,我将添加到 JTabbedPane
。
I was thinking of having one regular class file from where I would fetch everything I need.
I would make a separate class for the Frame ,another separate class for the JTabbedPane
and than one new class for each new Panel that I am going to add to the JTabbedPane
.
沿着
public class Fetcher {
public Fetcher(){
JFrame frame = new theFrameClass(); // theFrameClass extends from JFrame
JTabbedPane tabbedpane = new theTabbedPaneClass();// theTabbedPaneClass extends from JTabbedPane
JPanel tab1 = new firstTabClass(); // firstTabClass extends from JPanel
JPanel tab2 = new secondTabClass(); // etc...
tabbedpane.add(tab1);
tabbedpane.add(tab2);
frame.add(tabbedpane);
}
}
其次,我如何能够最佳地使用Netbeans的设计功能?使用我之前提到的betaprogram,我在从不同的类添加到JContentPane的选项卡时遇到困难。这些其他类的标签只会在我的程序运行时出现,但不能在设计模式下出现。
Secondly ,how would I be able to optimally use the design function in Netbeans? With a betaprogram I made earlier I had difficulties with adding in tabs from different classes to the JContentPane. The tabs from these other classes would only appear when I ran my program but not during the design mode.
感谢您的时间,如果我未能解释某些内容更清楚。
Thank you for your time and my apologies if I failed to explain something more clearly.
推荐答案
其次,我如何才能最佳地使用设计功能Netbeans?有一个betaprogram我早些时候,我有困难添加从不同的类到JContentPane的选项卡。这些其他类的选项卡只会出现在我的程序,而不是在设计模式。
"Secondly ,how would I be able to optimally use the design function in Netbeans? With a betaprogram I made earlier I had difficulties with adding in tabs from different classes to the JContentPane. The tabs from these other classes would only appear when I ran my program but not during the design mode."
您可以将 JPanel
表单拖放到当前设计视图窗体中。另外,我看不到在另一个类中创建 JTabbedPane
的一点。只需拖动到主框架类
You can just drag and drop your JPanel
forms to the current design view form. Also, I don't see the point of creating the JTabbedPane
in a different class though. Just drag it to the main frame class
这篇关于什么是构建我的程序的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!