我尝试使用Swing创建一个MVC应用程序。我对实施以及应该如何处理感到困惑。我的意思是:swing Mvc模型
我有桂这是所有逻辑发送到类名为控制器的观点,我有一个模型,在那里我有模特属性(我已阅读MVC就是这样)
。我创建了一些随机代码,并输入了我想要的代码数,并将其与
ActionListener
一起传输给一个Class Named Controller。随机代码通过方法中的控制器类上的按钮生成。 生成随机代码,然后我想将它们保存在数据库中。 我很困惑如何将生成的代码保存在数据库中。 我应该在类命名控制器中创建一个方法,以便我可以从那里保存它们?或另一个不同的类与保存更新找到..........方法?如果是,那么为什么我使用Model属性创建Model类?我怎样才能使用Model类。 如果我必须使用它,或者如果我只需要让这个类在那里,那么我们还需要了解如何使用Model类。 Model类的用途是什么?如果它只是与属性在一起,并且保存在其他地方? 通常使用什么方法,以便我可以使用MVC模式?我困惑吗?任何帮助 我忘记告诉我使用Hibernate。感谢 ps。我也读过这http://java.sun.com/products/jfc/tsc/articles/architecture/,但我不明白。public class code(){// this is the Model private int i; public void setter(int i){ this.i=i; } public int getter(){ return i; } public String generateStringInt() { return new BigInteger(190, random).toString(32); } // what ever i want to create with the int i variable i will do it on this class? ///then i will pass it on the controller to sent it on the view //OR save if i want to save it.?Is this way of thinking right? //Or is there any other way to do it ? /// if i have a Button and press it from the View it will generate this method?or // i have to do it else? public String generateStringInt() { return new BigInteger(190, random).toString(32); } } //then if i want to save i can just do it like //session.save(object) or is there any other way?
是不是好些了吗? 感谢
a [sscce](http://sscce.org/)将有所帮助。 – gontard
完整的教程超出了本网站的范围。请编辑您的问题以包含[sscce](http://sscce.org/),其中显示您尝试过的内容以及遇到问题的位置。 – trashgod