JFrame.java


package myProject;

import java.awt.Color;
import java.awt.EventQueue;

import javax.swing.JSeparator;
import javax.swing.JTextArea;
import javax.swing.JLabel;
import javax.swing.JPanel;

import java.awt.Font;

import java.io.IOException;

public class JFrame extends javax.swing.JFrame {

private JPanel contentPane;
private JTextArea textArea;

public static void main(String[] args) throws IOException{

EventQueue.invokeLater(new Runnable() {
public void run() {
try {
JFrame frame = new JFrame();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the frame.
*/
public JFrame() {
setTitle("Group5+");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setBounds(100, 100, 800, 600);// frame size

contentPane = new JPanel();
contentPane.setLayout(null);
this.getContentPane().add(contentPane);//

//show buttons
controlPanel();

//show create test area
TextArea();

//show create map
Map();

//create hr
createLine();


}

public void Map(){
// map label
JLabel map = new JLabel("Map");
map.setFont(new Font("Arial Black", Font.PLAIN, 18));
map.setBounds(400, 80, 200, 20);
contentPane.add(map);
}

public void TextArea(){
//status testarea
JLabel status = new JLabel("Status");
status.setFont(new Font("Arial Black", Font.PLAIN, 18));
status.setBounds(20, 300, 200, 20);
contentPane.add(status);
}

public void createLine(){
JSeparator line1 = new JSeparator();
//position
line1.setBounds(15, 280, 330, 1);
//color
line1.setForeground(Color.black);
//add
contentPane.add(line1);

JSeparator infoLine = new JSeparator();
//position
infoLine.setBounds(15, 60, 700, 1);
//color
infoLine.setForeground(Color.black);
//add
contentPane.add(infoLine);
}

public void controlPanel(){
//control panel
JLabel controlPanel = new JLabel("Control Panel");
controlPanel.setFont(new Font("Arial Black", Font.PLAIN, 18));
controlPanel.setBounds(20, 80, 180, 20);
contentPane.add(controlPanel);

// button_up
Button button_up = new Button("添加",contentPane);
button_up.go();

button_up.setSize(150,120,80,35);
contentPane.add(button_up.getButton());

// button_down
Button button_down = new Button("查询/修改",contentPane);
button_down.go();

button_down.setSize(150,220,80,35);
contentPane.add(button_down.getButton());

// button_left
Button button_left = new Button("¡û",contentPane);
button_left.go();

button_left.setSize(50,173,80,35);
contentPane.add(button_left.getButton());

// button_right
Button button_right = new Button("¡ú",contentPane);
button_right.go();

button_right.setSize(255,173,80,35);
contentPane.add(button_right.getButton());


}

}


Button.java


package myProject;

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

import javax.swing.JButton;

import javax.swing.JPanel;
import javax.swing.JTextField;

public class Button {

private String content;
private JButton button;
JTextField textField;
private JPanel contentPane;

public Button(String content,JPanel contentPane) {
this.content = content;
this.button = new JButton(content);
this.contentPane = contentPane;

initialTextField();

}

public void initialTextField(){
textField = new JTextField();
textField.setBounds(50, 350, 300, 80);
contentPane.add(textField);
textField.setColumns(10);
}
public String getText() {
return content;
}

public JButton getButton() {
return button;
}

public void setSize(int x, int y, int width, int height) {
this.button.setBounds(x, y, width, height);
}

public void go() {
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// onclick function
switch (button.getText()) {
case "↑":
System.out.println("123");
break;
case "↓":
System.out.println("123");
break;

default:
System.out.println("button error");
break;
}
}

});
}

}

Java界面的更多相关文章

  1. Java界面设计 Swing(1)

    Java界面设计的用途 开发者可以通过Java SE开发丰富并且强大的具有图形界面的桌面应用程序.也可以设计一些提高效率的工具软件,帮助自己处理机械性工作. Java 的图形界面工具包,可以用于工具类 ...

  2. Java界面程序实现图片的放大缩小

    Java界面程序实现图片的放大缩小.这个程序简单地实现了图片的打开.保存.放大一倍.缩小一倍和固定缩放尺寸,但是并没有过多的涵盖对图片的细节处理,只是简单地实现了图片大小的放缩. 思维导图如下: 效果 ...

  3. JAVA 界面 - 记事本

    代码: import java.awt.*; import javax.swing.*; import java.awt.event.*; public class Jiemian10 extends ...

  4. Java界面编程-建立一个可以画出图形的简单框架

    引子:总共使用3个.java文件,建立一个简单界面编程的框架. 第1个文件:NotHelloWorldComponent.java //NotHelloWorldComponent.java 1 im ...

  5. Java界面编程—事件监听机制

    组件首先要先注册事件处理器,当用户单击组件.移动鼠标或者敲击键盘时都会产生事件(Event),一旦有时间发生,应用程序就会做出对该事件的响应,这些组件就是事件源(Event source). 接受.解 ...

  6. Java界面设计

    ---------------siwuxie095                             Java SE(Java Standard Edition) 即 Java 标准版, 一般也 ...

  7. Java 界面编程【03】事件监听

    当你把界面都设计好了,总需要添加相应的执行动作给组件,在JAVA中有相应的时间处理机制,叫做“监听器”,给组件添加相应执行动作的过程叫做“注册”,其中的“监听器”是一个接口,里面包含了相应的执行函数, ...

  8. 关于一个查询的JAVA界面,希望对你有启发

    package work2; import java.awt.BorderLayout; import javax.swing.JButton; import javax.swing.JFrame; ...

  9. java界面--WePush-master 项目跑起来 -碰到的问题

    仅能在IntelliJ里面打开GUI Form文件来进行界面的拖拽设计--eclipse中也可以了 当eclipse 打开.form文件时,提示有.对应的编辑工具可以打开它,请到市场去安装 但是:本人 ...

随机推荐

  1. Android 开发基础及环境配置

    2011年买了第一部安卓操作系统的手机,当时势头正盛的HTC不可思议(incredible),当时的想法就是想学习下智能手机开发,但是由于各种原因,客观上是公司的项目太忙了,忙于项目管理.团队建设.客 ...

  2. Qt中使用Windows API

    在Windows平台上进行开发,不可避免与Windows API打交道,Qt中使用的时候要添加对应API的头文件和链接lib文件,另外使用的Windows API的代码部分要使用#ifdef  Q_O ...

  3. mvc api 返回json

    GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear(); }

  4. C# 自动Ping 测试服务器运行状况

    通过小程序自动Ping配置文件中的IP地址,间隔时间.IP地址.手机号码通过配置文件获得. 废话不多说,上代码. using Newtonsoft.Json; using Newtonsoft.Jso ...

  5. 接口测试第十二课(fidller过滤)(转)

    转自: 经常有人问我,如何只抓手机上某个应用的请求包?在使用fiddler抓手机包的过程中,fiddler会话框上瞬间就满屏了,因为它不仅抓到手机上的请求数据包,也抓到了PC端的网络请求包.这时候很难 ...

  6. ImageLoader加载图片

    先导universal-image-loader-1.9.3包 在application配置 android:name=".MyApplication" intent权限 1 pa ...

  7. table 控制单双行颜色以及鼠标hover颜色 table光棒

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  8. 如何使用查尔斯代理抓取https请求

    首先 查尔斯代理是一个很不错的抓包工具 有适合各种系统的版本 最近http的请求几乎铺天盖地的已经变为了https了  其中的好处有很多  更加安全(http://www.cnblogs.com/lo ...

  9. angularJS中directive与controller之间的通信

    当我们在angularJS中自定义了directive之后需要和controller进行通讯的时候,是怎么样进行通讯呢? 这里介绍3种angular自定义directive与controller通信的 ...

  10. EditText光标位置

    1.xml中设置 gravity="top"  加入edittext框的高度不止一行时,该属性可是光标定位在第一行,不设置的话光标是默认在框的中间 2.etEdit.setSele ...