编写一个JAVA应用程序

编写一个java应用程序~

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class BroderLayoutDemo {
private static void showGUI(){
JFrame frame= new JFrame("flowLayoutDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel=new JPanel();
JPanel panelN=new JPanel();
panelN.setBackground(Color.YELLOW);
JPanel panelS=new JPanel();
panelS.setBackground(Color.PINK);
JPanel panelC=new JPanel();
panelC.setBackground(Color.BLUE);
frame.setSize(300, 200);
frame.setLocation(300, 200);
panel.setLayout(new BorderLayout());
JButton button1=new JButton("North1");
JButton button2=new JButton("North2");
JButton button3=new JButton("South1");
JButton button4=new JButton("South2");
JButton button5=new JButton("Center1");
JButton button6=new JButton("Center2");
JButton button7=new JButton("Center3");
panel.add(panelC,"Center");
panel.add(panelN,"North");
panel.add(panelS,"South");
panelN.setLayout(new FlowLayout());
panelN.add(button1);
panelN.add(button2);
panelS.setLayout(new FlowLayout());
panelS.add(button3);
panelS.add(button4);
panelC.setLayout(new GridLayout(2,2));
panelC.add(button5);
panelC.add(button6);
panelC.add(button7);
frame.add(panel);
frame.add(panel);
frame.setVisible(true);
}
public static void main(String args[]){
showGUI();
}
}
颜色有点不太准,可以自己下个工具调一下,写的好辛苦,希望能给分啊

public class Test {
public static void main(String[] args) {
while (true) {
System.out.print("请输入姓名:");
Scanner input = new Scanner(System.in);
String name = input.next();
System.out.println("请输入的姓名是:"+name);
}
}
}

import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;


public class Text_Two_andJButton extends JFrame{
    JTextField one;
    JTextField two;

    public Text_Two_andJButton(){
        setSize(200,150);
        setVisible(true);
        
        one = new JTextField(15);
        two = new JTextField(15);
        JButton button = new JButton("确定");
        JPanel jp = new JPanel();
        Container c = this.getContentPane();
        c.add(jp);
        jp.add(one);
        jp.add(two);
        jp.add(button);
        
        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                String s = one.getText();
                char[] a = s.toCharArray();
                String str = "";
                for (int i = 0; i < a.length; i++) {
                    str = str +(a[i]+0+" ");
                }
                two.setText(str);
            }
        });    
    }
    
    public static void main(String[] args) {
        new Text_Two_andJButton();
    }

}

有图有真相,只能帮到你这里了!



看楼下,,,,,,,

如何用java语言编写一个程序?
答:根据目的判断,需要调取到的函数有randi、mod、mean、find,分别用于产生随机整数、判断是否为偶数、计算平均数、寻找满足条件元素的下标。代码如下:clc;clear;n=randi([10,99],[1,20])%产生随机数,在10到99之间的均匀随机数 a=mean(n)%计算平均数 n(find(n...

如何用Eclipse建立一个Java应用程序
答:2.双击打开,如遇到问题,不能正常打开,请检查jdk是否安装,是否与eclipse使用位数一致!进入后有个欢迎界面,关掉初始的欢迎页面,会是这样的:‍然后点击做上角的加号,进入这个界面:继续:完成后,一个java项目就建立完成了!然后你需要学会建立一个类,可以选中src,右键-->New-->Class,进入...

如何用Eclipse建立一个Java应用程序?
答:(4)系统会进入项目的编辑页面,此时并不能进行程序的编写。(5)“JavaProject”是java项目的一个外框,下面需要进行java内部的项目包新建,选择上方选项栏中的“File——New——Package”新建java的项目包。(6)确定新建“Package”后,系统会弹出新建项目的属性设置,你只需要设置“Package”的名称后...

如何编译运行一个简单的java程序
答:1).使用编辑器(如记事本,小编使用的是notepad++),输入以下6行文本:1 //一个简单的application例子:打印一行文本 2 class Hello { 3 public static void main (String args[]){ 4 System.out.println("Hello Java,This is my first Java Application!");5 } 6 } 输入完成,如下图所...

编写一个Java应用程序
答:import java.util.Comparator;import java.util.HashSet;import java.util.Random;import java.util.Set;import java.util.TreeSet;public class Main { public static void main(String[] args) throws IOException { File f = new File("d:/text.txt");if (!f.exists()) { f.createNewFile()...

在java中编写程序,定义一个学生类
答:import java.util.List;/ 编写一个Java应用程序,该程序包括3个类:定义一个学生类,Student有姓名,学号,选学的课程列表 定义一个课程类:课程名称,课程分数 (1)初始化一个学生,选择了三门课程,并添加到学生的属性中 (2)实现统计学生的总分功能 1.正确编写2个类(5分)2.统计学生的总分功能...

编写java程序
答:import java.util.*;public class Test{ public static void main(String[] args){ Scanner scan=new Scanner(System.in); System.out.println("请输入一个整数"); int x=scan.nextInt(); int y=0; if(x<0) y=-1+2*x; else if(x==0) y=-1; else...

用Java编写一个程序,要求如下:
答:1.内部使用 C 的 longjmp 机制让出一个协程。 因此,如果一个 C 函数 foo 调用了一个 API 函数, 而这个 API 函数让出了(直接或间接调用了让出函数)。 由于 longjmp 会移除 C 栈的栈帧, Lua 就无法返回到 foo 里了。2.为了回避这类问题, 碰到 API 调用中调用让出时,除了那些抛出错误...

如何用Eclipse建立一个Java应用程序
答:1、用Eclipse建立一个Java应用程序首先需要创建一个Java工程,在工程里添加一个类,接着在此类中编写代码即可完成一个Java应用程序的建立了;2、使用的工具是Eclipse;3、步骤如下:(1)、打开Eclipse,点击New菜单,新建一个Java Project,输入工程名;(2)、右键工程里的src目录,点击New菜单,选择...

编写一个Java应用程序,该程序包括3个类:Monkey类、People类和主类 E...
答:public class Program { static void Main(string[] args) { Monkey monkey = new Monkey(); monkey.Speak(); People people = new People(); people.Speak(); people.Think(); } public class Monkey { public Monkey(string s) { } public M...

IT评价网,数码产品家用电器电子设备等点评来自于网友使用感受交流,不对其内容作任何保证

联系反馈
Copyright© IT评价网