使用 Netbeans 的 Java 桌面应用程序

发布于 2024-11-17 10:21:55 字数 266 浏览 3 评论 0原文

我正在开发教程软件,帮助解决金融书籍的问题。所以它类似于包含组合框和格式化文本框的工作表之类的东西。除了一件事之外,一切都按我想要的方式进行。有没有办法可以随时保存我所做的工作。

让我具体一点。共有十二章,每章包含 15-20 个问题。每个问题都是通过文本框和组合框以及一些 jtabbed 面板等的组合来设计的。如果我解决了一半的工作表并想要保存以便以后可以打开它,我会打开我的软件。有什么办法可以做到这一点吗?问题是每个工作表都有不同的组合框和文本框数量,因此变量也不同。

提前致谢

I am working on tutorial software which help to solve problems of a Financial Book. So it is something like an worksheet kind of thing containing combo-boxes and formatted text boxes. Everything is working as i want except one thing. Is there a way i could save my work done by me any point of time.

Lemme be specific. There are twelve chapters and each chapter contains some 15-20 problems. Each problem is design with combination of text boxes and combo-boxes and some jtabbed panel etc. If i solved half my worksheet and want to save so that i could open it later i open my software. Is there any way to do that. The problem is every sheet have different no of combo-box and text boxes so the variable are also different.

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心安伴我暖 2024-11-24 10:21:55

您需要一个工作表模型。该模型是一种数据结构,与使用 GUI 小部件来表示它的事实无关(本身)。

您可以在保存时将模型的状态(从简单的序列化开始)保存到磁盘。启动时加载。

按照这些思路,可以对工作表进行统一处理。

public interface PersistentModel {
    boolean save (OutputStream out) throws IOException;
    boolean load (InputStream out) throws IOException;
}
public interface SpreadSheet extends PersistentModel {
    Worksheet[] getWorksheets();
    Worksheet getWorksheet(int i); // and other related, etc.
}

public interface Worksheet extends PersistentModel {
   int id();
   Element get(String name):
   Element[] getElements();

   public interface Element<T> extends PersistentModel { 
        String getName();
        T getValue();
        boolean setValue(T v);
   }
}

Swing 使用 MVC,并且您有挂钩模型的标准机制(保存工作表状态的数据结构),并且 GUI(可能是 Swing)表示相同的内容。我认为这不是问题。

You need a model for your worksheet. This model is a data-structure and has nothing (per se) to do with the fact that GUI widgets are used to represent it.

You save the state of the model -- start with simple Serialization -- to disk on save. Load on startup.

Something along these lines allow for uniform treatment of your worksheets.

public interface PersistentModel {
    boolean save (OutputStream out) throws IOException;
    boolean load (InputStream out) throws IOException;
}
public interface SpreadSheet extends PersistentModel {
    Worksheet[] getWorksheets();
    Worksheet getWorksheet(int i); // and other related, etc.
}

public interface Worksheet extends PersistentModel {
   int id();
   Element get(String name):
   Element[] getElements();

   public interface Element<T> extends PersistentModel { 
        String getName();
        T getValue();
        boolean setValue(T v);
   }
}

Swing uses MVC and you have standard mechanisms of hooking your model (the data structure holding state of the worksheets), and, the GUI (swing likely) that is the presentation of the same. I assume that is not an issue.

萌逼全场 2024-11-24 10:21:55

那么,您必须有一个持久存储才能保存此桌面应用程序的状态。考虑数据库或文件存储。
您还可以序列化“应用程序的状态”。在一个对象中并将其保存在磁盘上,当您再次启动应用程序时,您会重新加载它。

Well you must have then a persistent store in order to save the state of this desktop application.Think on a database or file store.
You can also serialize "the state of the app." in an object and save it on disk and when you start the app again you reload it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文