对话框 - 我自己设定的挑战

问题描述:

大家好,


我正在努力掌握java,并且为了巩固我的学习目标以及实施新的学习而让我自己成为一个挑战。


我想在集合中输入可能的事情,然后随机生成一个设定值,这是一个建议做什么(Geeky - 知道!)会有我和我的伴侣 - 我的狗 - 我的儿子。一套给我和我的伙伴 - 我的狗 - 没有儿子等 - 基本上我想要的是被问到儿子和狗是否与我们在模态框中然后根据输入导航到相关集。然后生成一个建议。


到目前为止我将添加我的代码 - 它可能与其他人会做的不同,但我正在使用到目前为止我学到的东西。现在,我还没有在java中使用模态/对话框,而是在VB中使用 - 一段时间之后。所以我需要做的第一件事就是学习如何使用它们。我使用什么代码以及我要导入什么?我想在启动方法中添加yes / no框。我已经学会了如何将结果设置为变量,但我正在向开放大学学习,他们向我们展示了自己的类,这些类可能是某种类的子类。任何帮助都将非常感激。这是我的代码:


import java.util。*;

import java.awt。*;

import java。 awt.event。*;

import java.swing。*;


公共类建议

{

Frame theFrame = new Frame();

Button addSuggestion = new Button();

//此订单 - Dan& Bren-Arial-Dylan >
Set< String> YesYesYes = new HashSet< String>();

Set< String> YesYesNo = new HashSet< String>();

Set< String> YesNoYes = new HashSet< String>();

Set< String> YesNoNo = new HashSet< String>();

Set< String> BrenNoNo = new HashSet< String>();

public Boolean arial;

public Boolean dylan;


public void launch( )

{

theFrame.setSize(500,500);

theFrame.setLayout(newFlowLayout());

addSuggestion.addActionListener(new ButtonListener());

theFrame.add(addSuggestion);

theFrame.setVisible(true);


public static void main(String [] args)

{

Suggestion newObject = new Suggestion();

newObject.launch() ;

}

}


感谢您寻找

Hi all,

I''m just getting to grips with java and have set my self a challenge to consolidate my learnings so far as well as implement new learnings.

I want to enter a load of possible things to do into sets and then randomly generate a set value, which is a suggestion of what to do(Geeky - know!) There will be numerous sets, a set for me and my partner - my dog - my son. A set for me and my partner - my dog - no son, etc - basically what i want is to be asked if son and dog are with us in modal boxes and then navigate to a relevent set depending on input. Then generate a suggestion.

I will add my code thus far - it may be ver different to what others would do but i''m using what i ve learnt so far. Now, I haven''t use modal/dialog boxes in java but have in VB - a while back. So first thing i need to do is learn how to use them. What code do i use and what do i import? I want to add a yes/no box in the launch method. I have learnt how to set the result into a variable but I was learning with the open university and they shown us with there own classes which were prob a sub class of some sort.Any help would be greatly appreciated. Here is my code:

import java.util.*;
import java.awt.*;
import java.awt.event.*;
import java.swing.*;

public class Suggestion
{
Frame theFrame = new Frame();
Button addSuggestion = new Button();
//this order - Dan&Bren-Arial-Dylan
Set<String> YesYesYes = new HashSet<String>();
Set<String> YesYesNo = new HashSet<String>();
Set<String> YesNoYes = new HashSet<String>();
Set<String> YesNoNo = new HashSet<String>();
Set<String> BrenNoNo = new HashSet<String>();
public Boolean arial;
public Boolean dylan;

public void launch()
{
theFrame.setSize(500,500);
theFrame.setLayout(newFlowLayout());
addSuggestion.addActionListener(new ButtonListener());
theFrame.add(addSuggestion);
theFrame.setVisible(true);

public static void main(String[] args)
{
Suggestion newObject = new Suggestion();
newObject.launch();
}
}

Thanks for looking

1。)发布代码时请使用代码标签。

2.)不要混合awt和swing。

3.)阅读 JOptionPane class。
1.) Please use code tags when posting code.
2.) Do not mix awt and swing.
3.) Read the specs for the JOptionPane class.


但是我不需要Awt用于这个项目的东西Swing for the dialog box?
But Don''t I need Awt for something with this project and Swing for the dialog boxes?



但是我不需要Awt用于这个项目的东西和Swing的对话框吗?
But Don''t I need Awt for something with this project and Swing for the dialog boxes?



你从awt获得的东西是摆动的。例如,该框架应替换为JFrame。

What you get from awt is available in swing. That Frame for example should be replaced by a JFrame.