Programmingbydoing
http://www.programmingbydoing.com/
1. Modulus Animation
public static void modulusAnimation() throws InterruptedException {
int repeats = 5;
int steps_per_seconds = 10;
for(int i=0; i<repeats*11; i++){
if(i%11==0){
System.out.println(",oOo.....");
} else if (i%11==1){
System.out.println("..oOo....");
}else if (i%11==2){
System.out.println("...oOo...");
}else if (i%11==3){
System.out.println("....oOo..");
}else if (i%11==4){
System.out.println(".....oOo.");
}else if (i%11==5){
System.out.println("......oOo");
}else if (i%11==6){
System.out.println(".........oO");
}else if (i%11==7){
System.out.println("o.......o");
}else if (i%11==8){
System.out.println("Oo.......");
}else if (i%11==9){
System.out.println("oOo......");
}else if (i%11==10){
System.out.println(".oOo.....");
}else if (i%11==11){
System.out.println("..oOo....");
} Thread.sleep(1000/steps_per_seconds);
}
}
2.Using swing for input
public static void inputBox(){
String name = JOptionPane.showInputDialog("What's your name?");
String input = JOptionPane.showInputDialog("How old are you");
int age = Integer.parseInt(input); System.out.println("Hello, " + name);
System.out.println("Next year, you will be " + (age+1));
System.exit(0);
}
3. A frame with a Panel with writing on it
import javax.swing.*;
import java.awt.*; public class Prog613 {
public static void main(String[] args) {
Frame613 f = new Frame613();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
} class Frame613 extends JFrame {
public Frame613(){
setTitle("613 rocks");
setSize(300,200);
setLocation(100,200); Panel613 panel = new Panel613();
Container cp = getContentPane();
cp.add(panel);
}
} class Panel613 extends JPanel{
public void paintComponent(Graphics g){
super.paintComponent(g);
g.drawString("Hi, ",75, 100);
} }
4. Graphics Demo1
import javax.swing.*;
import java.awt.*; public class GraphicsDemo1 extends Canvas {
public static void main(String[] args) {
JFrame win = new JFrame("GraphicsDemo1");
win.setSize(600,800);
win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GraphicsDemo1 canvas = new GraphicsDemo1();
win.add(canvas);
win.setVisible(true);
} public void paint(Graphics g){
g.setColor(Color.green);
g.drawRect(50,20,100,200);
g.fillOval(160,20,100,200);
g.setColor(Color.blue);
g.fillRect(200,400,200,20);
g.drawOval(200,430,200,100); g.setColor(Color.black);
g.drawString("Graphics are pretty neat. ",500,100);
int x = getWidth()/2;
int y = getHeight()/2;
g.drawString("The first letter of this string is at (" + x + ","+y+")",x,y); } }
Programmingbydoing的更多相关文章
- 【译】快速高效学习Java编程在线资源Top 20
想要加强你的编程能力吗?想要提升你的 Java 编程技巧和效率吗? 不用担心.本文将会提供快速高效学习 Java 编程的 50 多个网站资源: 开始探索吧: 1.MKyong:许多开发者在这里可以找到 ...
- 快速高效学习Java编程在线资源Top 20(转载)
想要加强你的编程能力吗?想要提升你的 Java 编程技巧和效率吗? 不用担心.本文将会提供快速高效学习 Java 编程的 50 多个网站资源: 开始探索吧: 1.MKyong:许多开发者在这里可以找到 ...
随机推荐
- php 调用微信上传临时素材接口 {“errcode”:41005,”errmsg”:”media data missing hint”}
原因:由于PHP5.6以前与之后的版本curl_setopt有差异.PHP5.6以后不再支持”@文件路径”的方式. $picPath= "public\public\upload\xxx.p ...
- MySql通过数据库文件恢复数据库
以表”Table”为例: 如类型是MyISAM, 数据文件则以”Table.frm””Table.MYD””Table.MYI””三个文件存储于”/data/$databasename/”目录中. 如 ...
- postgresql 中文排序
select c_wsxx from fjfl.t_case_anyou order by convert_to(c_wsxx,'GBK') asc;
- openresty开发系列30--openresty中使用全局缓存
openresty开发系列30--openresty中使用全局缓存 Nginx全局内存---本地缓存 使用过如Java的朋友可能知道如Ehcache等这种进程内本地缓存.Nginx是一个Master进 ...
- UBI mkfs.ubifs 参数记录
NAND 硬件结构如下: 脚本如下 sudo mkfs.ubifs -q -r rootfs_iproute -m 4096 -e 248KiB -c 3840 -o ubifs.img -F ech ...
- 安装tensorflow2.0
pip install tensorflow==2.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple import tensorflow as tfpri ...
- memcached概述与基本操作
memcached 什么是memcached memcached之前是danga的一个项目,最早是为LiveJournal服务的,当初设计师为了加速LiveJournal访问速度而开发的,后来被很多大 ...
- Spring boot后台搭建二为Shiro权限控制添加缓存
在添加权限控制后,添加方法 查看 当用户访问”获取用户信息”.”新增用户”和”删除用户”的时,后台输出打印如下信息 , Druid数据源SQL监控 为了避免频繁访问数据库获取权限信息,在Shiro中加 ...
- WinForm SetWindowPos窗口置顶使用说明
就是有时候窗口不能够成功置顶,这时需要重新切换下标签,就可以置顶了,本文介绍C# SetWindowPos实现窗口置顶的方法: [DllImport("user32.dll", C ...
- layui的select监听
首先,select一定要放在<form class="layui-form" ></form>里面 然后,加监听<select id="id ...