包含面板的Java GUI问题 [英] Java GUI problem that contains panels

查看:64
本文介绍了包含面板的Java GUI问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

布局:面板内图形组件的组织

可交付成果

app.java(初始申请)
MainFrame.java (外部JFrame)
ControlPanel,一个面板的Java类,它将包含两个其他面板,使用布局。
TopPanel,Panel的Java类,将显示组的名称和组的平均GPA
CenterPanel,Panel的Java类,将显示组中4名学生的名称和学期GPA。
group.java和student.java(以前实验室的工作版本,可能需要更新,请参阅下面重要的#2)。

学生应在所有提交中应用一致的缩进。这可以通过NetBeans源菜单完成。

目录

您可以从这个NetBeans项目开始。
您将创建3个面板和一个组对象。一个面板包含另外两个面板。
在顶部面板上,您将显示该组的名称和平均GPA。
中心面板将包含4个按钮,显示第4组学生姓名和GPA。





重要 - #1  - 单个组对象

您将在此分配中仅创建一个组对象g1。

只有一个语句组g1 = new group(...);在整个申请中。

由于需要使用两个面板,因此需要在某处创建g1,然后将对象g1作为参数传递给其他类。

重要 - #2 - GPA计算

您之前的团体/学生解决方案可能正在以此方式工作;否则,您需要更新它。

因为GPA是在学生中随机计算的,根据您的计算方式,平均组GPA可能与每个学生的GPA的显示总和不匹配。

为了解决这个问题,你需要:

in group:

semesterGPA是使用学生的GPA属性计算的,而不是学期的GPA学生中的()方法

学生:

它需要GPA作为属性

属性GPA是在构造函数中计算的,当学生时创建时,调用semesterGPA()随机方法

semesterGPA()方法,无论何时调用,都会更新属性GPA的值。





我尝试了什么:



i没有任何java GUI经验,所以我不知道怎么做解决这个问题.java

解决方案

对不起,这里没有人会为你写你的作业。请参阅跟踪:使用JFC / Swing创建GUI(The Java™Tutorials) [ ^ ]。


< blockquote>

引用:

我对java GUI没有任何经验所以我不知道如何解决这个问题.java



你希望我们为你做这件事,这样你就永远不会学到,也永远不会有经验。试用和错误是你将如何学习。



家庭工作问题是你在现实生活中必须解决的问题的简化版本,他们的目的正在学习并且练习

我们不做你的HomeWork。

HomeWork不会测试你乞求别人做你的工作的技能,它会让你思考和帮助您的老师会检查您对所学课程的理解以及您应用这些课程时遇到的问题。

你的任何失败都会帮助你的老师发现你的弱点并设定补救措施。

你的任何失败都会帮助你了解什么有效,什么无效,被称为'试错'学习。

所以,试一试,重读课程并开始工作。如果您遇到特定问题,请显示您的代码并解释这个问题,我们可能会提供帮助。



作为程序员,您的工作是创建算法解决特定问题,你不能依赖别人永远为你做,所以有一段时间你必须学会​​如何。而且越快越好。

当你要求解决方案时,就像试图通过培训其他人来学习开车一样。

创建算法基本上是找到数学并做出必要的调整以适应你的实际问题。


Layouts: the organization of graphical components inside a panel

Deliverables

app.java (initial application)
MainFrame.java (external JFrame)
ControlPanel, a Java class for the panel that will contain two other panels, using a layout.
TopPanel, a Java class for the Panel that will display the group’s name and group's average GPA
CenterPanel, a Java class for the Panel that will display names and semester GPAs of the 4 students in a group.
group.java and student.java (a working version from previous labs, might need updates, see important #2 below).

Students should apply consistent indenting in all submissions. This can be done via the NetBeans Source menu.

Contents

You can start with this NetBeans project.
You will create 3 panels and one group object. One panel contains two other panels.
On a top panel you will display the group's name and average GPA.
The center panel will contain 4 buttons displaying the group 4 students name and GPA.



Important - #1 - The single group object

You will create only one group object g1 in this assignment.

There will be only one statement group g1 = new group(...); in the whole application.

Since two panels need to be used, g1 will need to be created somewhere and then pass the object g1 as a parameter to other classes.

Important - #2 - GPA Calculation

Your previous group/student solution might be working this way; otherwise, you will need to updated it.

Because GPA is calculated randomly in student, depending how you calculate it there is a chance that the average group GPA will not match with the displayed sum of each student's GPA.

In order to fix this, you need to:

in group:

semesterGPA is calculated using the GPA attribute in student, not the semesterGPA() method in student

in student:

it needs GPA as an attribute

the attribute GPA is calculated in the constructor, when the student is created, calling the semesterGPA() random method

the semesterGPA() method, whenever it is called, updates the value of the attribute GPA.



What I have tried:

i dont have any experience with java GUI so i dont know how to solve this problem.java

解决方案

Sorry, no one here is going to write your assignment for you. See Trail: Creating a GUI With JFC/Swing (The Java™ Tutorials)[^].


Quote:

i dont have any experience with java GUI so i dont know how to solve this problem.java


And you want us to do it for you so that you will never learn and never get experience. Trial and error is how you will learn.

HomeWork problems are simplified versions of the kind of problems you will have to solve in real life, their purpose is learning and practicing.
We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.

As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.


这篇关于包含面板的Java GUI问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆