2024年9月getmonth(java中的getMonth()函数和Calendar.get(Calendar.MONTH)函数)

 更新时间:2024-09-21 09:52:22

  ⑴getmonth(java中的getMonth()函数和Calendar.get(Calendar.MONTH)函数

  ⑵并将最大值输出?*/??import?java.util.Scanner;??public?class?JavaDay_?{??public?static?void?main(String?args)?{??System.out.println(“请输入个数:“);??Scanner?scanner?=?new?Scanner(System.in);??int?nNumA?=?scanner.nextInt();??int?nNumB?=?scanner.nextInt();??int?nNumC?=?scanner.nextInt();??int?nMax?=?;??if?(nNumA?》=?nNumB?&&?nNumA?》=?nNumC)??{??nMax?=?nNumA;??}??else?if?(nNumB?》=?nNumC?&&?nNumB?》=?nNumA)??{??nMax?=?nNumB;??}??else?if?(nNumC?》=?nNumA?&&?nNumC?》=?nNumB)??{??nMax?=?nNumC;??}??else??{??System.out.println(“无法比较!“);??}??System.out.println(“Max?=?“?+?nMax);??}??}??/**?*?Created?by?yn?on?//.?*?.编写万年历小程序?*?输出结果:?*?请输入年:?*?请输入月:?*?年非润年?*?年月份的天数是?*/??import?.sun.webkit.BackForwardList;??import?java.util.Scanner;??public?class?JavaDay_?{??public?static?void?main(String?args)?{??System.out.println(“请输入年:“);??Scanner?scanner?=?new?Scanner(System.in);??int?nYear?=?scanner.nextInt();??System.out.println(“请输入月:“);??int?nMounth?=?scanner.nextInt();??int?nflag?=?;??if?(nYear?%??==?)??{??if?(nYear?%??==?)??{??if?(nYear?%??==?)??{??nflag?=?;??System.out.println(nYear?+?“年是润年“);??}??else??{??System.out.println(nYear?+?“年不是润年“);??}??}??else??{??nflag?=?;??System.out.println(nYear?+?“年不是润年“);??}??}??else??{??System.out.println(nYear?+?“年不是润年“);??}??//判断年月份的天数??if?(nMounth?==???||?nMounth?==???||?nMounth?==???||?nMounth?==???||?nMounth?==???||?nMounth?==???||?nMounth?==??)??{??System.out.println(nYear?+?“年“?+?nMounth?+?“月份的天数是:“?);??}??else?if?(nMounth?==???||?nMounth?==???||?nMounth?==???||?nMounth?==?)??{??System.out.println(nYear?+?“年“?+?nMounth?+?“月份的天数是:“?);??}?辛苦,求java做动画代码import?java.awt.Canvas;import?java.awt.Color;import?java.awt.Dimension;import?java.awt.EventQueue;import?java.awt.Frame;import?java.awt.Graphics;import?java.awt.GraphicsD;import?java.awt.Image;import?java.awt.RenderingHints;import?java.awt.event.KeyEvent;import?java.awt.event.KeyListener;import?java.awt.event.WindowAdapter;import?java.awt.event.WindowEvent;import?java.awt.image.BufferedImage;import?java.io.File;import?java.io.IOException;import?javax.imageio.ImageIO;public?class?TestImage?extends?Frame{ private?static?final?long?serialVersionUID?=?L; private?static?boolean?PRESSED?=?false; private?static?int?pointX?=?; private?static?int?pointy?=?; private?static?int?RIGHT_GO?=?; private?static?int?LEFT_GO?=?; private?static?int?DIR?=?; private?static?int?ANGLE?=?; private?static?int?W?=?; private?static?int?H?=?; private?_Canvas?canvas?=?null; public?TestImage?() { add?(canvas?=?new?_Canvas?()); setIgnoreRepaint?(true); requestFocus?(); } public?class?_Canvas?extends?Canvas?implements?Runnable { private?static?final?long?serialVersionUID?=?L; private?BufferedImage?bi?=?null; private?Image?bufferedImage?=?null; private?Thread?thread?=?null; private?long?sleepTime?=?; public?_Canvas?() { try { bi?=?ImageIO.read?(new?File?(“go.png“)); } catch?(IOException?e) {} setBackground?(Color.BLACK); requestFocus?(); addKeyListener?(new?KeyListener?() { Override public?void?keyTyped?(?KeyEvent?e?) {} Override public?void?keyReleased?(?KeyEvent?e?) { RIGHT_GO?=?; PRESSED?=?false; } Override public?void?keyPressed?(?KeyEvent?e?) { //????上下左右 DIR?=?e.getKeyCode?(); PRESSED?=?true; } }); } Override public?void?paint?(?Graphics?g?) { GraphicsD?gd?=?(GraphicsD)?g; gd.setRenderingHint?(RenderingHints.KEY_INTERPOLATION,?RenderingHints.VALUE_INTERPOLATION_BILINEAR); gd.drawImage?(rotateImage?(bi.getSubimage?(RIGHT_GO,?LEFT_GO,?W,?H),?ANGLE,?true),?pointX,?pointy,?W,?H, this); gd.dispose?(); } Override public?void?update?(?Graphics?g?) { if?(null?==?bufferedImage) { bufferedImage?=?createImage?(getWidth?(),?getHeight?()); } Graphics?bufferedG?=?bufferedImage.getGraphics?(); bufferedG.clearRect?(,?,?getWidth?(),?getHeight?()); paint?(bufferedG); bufferedG.dispose?(); g.drawImage?(bufferedImage,?,?,?this); g.dispose?(); } public?void?start?() { thread?=?new?Thread?(this); thread.setName?(“TestImage“); thread.setPriority?(Thread.MIN_PRIORITY); thread.start?(); } public?synchronized?void?stop?() { thread?=?null; notify?(); } Override public?void?run?() { Thread?me?=?Thread.currentThread?(); while?(thread?==?me?&&?!isShowing?()?||?getSize?().width?==?) { try { Thread.sleep?(); } catch?(InterruptedException?e) { return; } } while?(thread?==?me?&&?isShowing?()) { if?(PRESSED) { try { if?(DIR?==?) { RIGHT_GO?=?RIGHT_GO?+?; LEFT_GO?=?; pointX?=?pointX?+?; if?(pointX?》?) { ANGLE?=?; pointX--; pointy--; W?=?; H?=?; } if?(RIGHT_GO?》?) { RIGHT_GO?=?; } } else?if?(DIR?==?) { pointX?=?pointX?-?; RIGHT_GO?=?RIGHT_GO?+?; LEFT_GO?=?; if?(pointX?《?) { ANGLE?=?-; pointX++; pointy--; W?=?; H?=?; } if?(RIGHT_GO?》?) { RIGHT_GO?=?; } } else?if?(DIR?==?) { W?=?; H?=?; pointy?=?; ANGLE?=?; RIGHT_GO?=?; } else?if?(DIR?==?) { W?=?; H?=?; ANGLE?=?; pointy?=?; RIGHT_GO?=?; } Thread.sleep?(sleepTime); repaint?(); } catch?(InterruptedException?e) { break; } } else { RIGHT_GO?=?RIGHT_GO?+?; LEFT_GO?=?; pointX?=?pointX?+?; if?(RIGHT_GO?》?) { RIGHT_GO?=?; } if?(pointX?》?) { pointX?=?; } try { Thread.sleep?(sleepTime); repaint?(); } catch?(InterruptedException?e) { break; } } } thread?=?null; } } /** ?*?旋转图像为指定角度 ?*? ?*?param?degree ?*?return ?*/ public?static?BufferedImage?rotateImage?(?final?BufferedImage?image,?final?int?angdeg,?final?boolean?d?) { int?w?=?image.getWidth?(); int?h?=?image.getHeight?(); int?type?=?image.getColorModel?().getTransparency?(); BufferedImage?img; GraphicsD?graphicsd; (?graphicsd?=?(?img?=?new?BufferedImage?(w,?h,?type)?).createGraphics?()?).setRenderingHint?( RenderingHints.KEY_INTERPOLATION,?RenderingHints.VALUE_INTERPOLATION_BILINEAR); graphicsd.rotate?(d???-Math.toRadians?(angdeg)?:?Math.toRadians?(angdeg),?w?/?,?h?/?); graphicsd.drawImage?(image,?,?,?null); graphicsd.dispose?(); return?img; } public?static?void?main?(?String?args?) { EventQueue.invokeLater?(new?Runnable?() { Override public?void?run?() { final?TestImage?ti?=?new?TestImage?(); ti.setSize?(new?Dimension?(,?)); ti.setLocationRelativeTo?(null); ti.addWindowListener?(new?WindowAdapter?() { Override public?void?windowClosing?(?WindowEvent?e?) { System.exit?(); } Override public?void?windowDeiconified?(?WindowEvent?e?) { ti.canvas.start?(); } Override public?void?windowIconified?(?WindowEvent?e?) { ti.canvas.stop?(); } }); ti.setResizable?(false); ti.canvas.start?(); ti.setVisible?(true); } }); }}java代码*?Created?by?yn?on?//.?*?.输出控制台传递的默认参数?*/??public?class?JavaDay_?{??public?static?void?main(String?args)?{??System.out.println(args);??}??}??/**?*?Created?by?yn?on?//.?*?.编程求表达式的结果?*/??public?class?JavaDay_?{??public?static?void?main(String?args)?{??System.out.println(“?&??=?“?+?(?&?));??System.out.println(“?|??=?“?+?(?|?));??System.out.println(“?^??=?“?+?(?^?));??}??}??/**?*?Created?by?yn?on?//.?*?.从键盘上输入个数,java中的getMonth()函数和Calendar.get(Calendar.MONTH)函数Dated=newDate();Calendarc=Calendar.getInstance();c.setTime(d);System.out.println(c.get(Calendar.MONTH));一月对应十二月对应javaswing中怎样使用绝对布局Swing中窗体具有默认的布局管理器,即不使用任何布局管理器,虽然布局管理器能够简化程序的开发,是哦那个该布局的步骤如下:(?使用Container.setLayout(null)方式取消布局管理器,求出这三个数字中的最大值,但是为了获取最大的灵活性。

  ⑶java中的getMonth()函数和Calendar.get(Calendar.MONTH)函数

  ⑷Dated=newDate();Calendarc=Calendar.getInstance();c.setTime(d);System.out.println(c.get(Calendar.MONTH));一月对应十二月对应

  ⑸javaswing中怎样使用绝对布局

  ⑹Swing中窗体具有默认的布局管理器,如JFrame使用是边界布局。虽然布局管理器能够简化程序的开发,但是为了获取最大的灵活性,可以使用绝对布局,即不使用任何布局管理器,是哦那个该布局的步骤如下:

  ⑺?使用Container.setLayout(null)方式取消布局管理器。

  ⑻使用ponent.setBounds()方法来设置每个控件的大小与位置。

  ⑼求java做动画代码

  ⑽import?java.awt.Canvas;import?java.awt.Color;import?java.awt.Dimension;import?java.awt.EventQueue;import?java.awt.Frame;import?java.awt.Graphics;import?java.awt.GraphicsD;import?java.awt.Image;import?java.awt.RenderingHints;import?java.awt.event.KeyEvent;import?java.awt.event.KeyListener;import?java.awt.event.WindowAdapter;import?java.awt.event.WindowEvent;import?java.awt.image.BufferedImage;import?java.io.File;import?java.io.IOException;import?javax.imageio.ImageIO;public?class?TestImage?extends?Frame{ private?static?final?long?serialVersionUID?=?L; private?static?boolean?PRESSED?=?false; private?static?int?pointX?=?; private?static?int?pointy?=?; private?static?int?RIGHT_GO?=?; private?static?int?LEFT_GO?=?; private?static?int?DIR?=?; private?static?int?ANGLE?=?; private?static?int?W?=?; private?static?int?H?=?; private?_Canvas?canvas?=?null; public?TestImage?() { add?(canvas?=?new?_Canvas?()); setIgnoreRepaint?(true); requestFocus?(); } public?class?_Canvas?extends?Canvas?implements?Runnable { private?static?final?long?serialVersionUID?=?L; private?BufferedImage?bi?=?null; private?Image?bufferedImage?=?null; private?Thread?thread?=?null; private?long?sleepTime?=?; public?_Canvas?() { try { bi?=?ImageIO.read?(new?File?(“go.png“)); } catch?(IOException?e) {} setBackground?(Color.BLACK); requestFocus?(); addKeyListener?(new?KeyListener?() { Override public?void?keyTyped?(?KeyEvent?e?) {} Override public?void?keyReleased?(?KeyEvent?e?) { RIGHT_GO?=?; PRESSED?=?false; } Override public?void?keyPressed?(?KeyEvent?e?) { //????上下左右 DIR?=?e.getKeyCode?(); PRESSED?=?true; } }); } Override public?void?paint?(?Graphics?g?) { GraphicsD?gd?=?(GraphicsD)?g; gd.setRenderingHint?(RenderingHints.KEY_INTERPOLATION,?RenderingHints.VALUE_INTERPOLATION_BILINEAR); gd.drawImage?(rotateImage?(bi.getSubimage?(RIGHT_GO,?LEFT_GO,?W,?H),?ANGLE,?true),?pointX,?pointy,?W,?H, this); gd.dispose?(); } Override public?void?update?(?Graphics?g?) { if?(null?==?bufferedImage) { bufferedImage?=?createImage?(getWidth?(),?getHeight?()); } Graphics?bufferedG?=?bufferedImage.getGraphics?(); bufferedG.clearRect?(,?,?getWidth?(),?getHeight?()); paint?(bufferedG); bufferedG.dispose?(); g.drawImage?(bufferedImage,?,?,?this); g.dispose?(); } public?void?start?() { thread?=?new?Thread?(this); thread.setName?(“TestImage“); thread.setPriority?(Thread.MIN_PRIORITY); thread.start?(); } public?synchronized?void?stop?() { thread?=?null; notify?(); } Override public?void?run?() { Thread?me?=?Thread.currentThread?(); while?(thread?==?me?&&?!isShowing?()?||?getSize?().width?==?) { try { Thread.sleep?(); } catch?(InterruptedException?e) { return; } } while?(thread?==?me?&&?isShowing?()) { if?(PRESSED) { try { if?(DIR?==?) { RIGHT_GO?=?RIGHT_GO?+?; LEFT_GO?=?; pointX?=?pointX?+?; if?(pointX?》?) { ANGLE?=?; pointX--; pointy--; W?=?; H?=?; } if?(RIGHT_GO?》?) { RIGHT_GO?=?; } } else?if?(DIR?==?) { pointX?=?pointX?-?; RIGHT_GO?=?RIGHT_GO?+?; LEFT_GO?=?; if?(pointX?《?) { ANGLE?=?-; pointX++; pointy--; W?=?; H?=?; } if?(RIGHT_GO?》?) { RIGHT_GO?=?; } } else?if?(DIR?==?) { W?=?; H?=?; pointy?=?; ANGLE?=?; RIGHT_GO?=?; } else?if?(DIR?==?) { W?=?; H?=?; ANGLE?=?; pointy?=?; RIGHT_GO?=?; } Thread.sleep?(sleepTime); repaint?(); } catch?(InterruptedException?e) { break; } } else { RIGHT_GO?=?RIGHT_GO?+?; LEFT_GO?=?; pointX?=?pointX?+?; if?(RIGHT_GO?》?) { RIGHT_GO?=?; } if?(pointX?》?) { pointX?=?; } try { Thread.sleep?(sleepTime); repaint?(); } catch?(InterruptedException?e) { break; } } } thread?=?null; } } /** ?*?旋转图像为指定角度 ?*? ?*?param?degree ?*?return ?*/ public?static?BufferedImage?rotateImage?(?final?BufferedImage?image,?final?int?angdeg,?final?boolean?d?) { int?w?=?image.getWidth?(); int?h?=?image.getHeight?(); int?type?=?image.getColorModel?().getTransparency?(); BufferedImage?img; GraphicsD?graphicsd; (?graphicsd?=?(?img?=?new?BufferedImage?(w,?h,?type)?).createGraphics?()?).setRenderingHint?( RenderingHints.KEY_INTERPOLATION,?RenderingHints.VALUE_INTERPOLATION_BILINEAR); graphicsd.rotate?(d???-Math.toRadians?(angdeg)?:?Math.toRadians?(angdeg),?w?/?,?h?/?); graphicsd.drawImage?(image,?,?,?null); graphicsd.dispose?(); return?img; } public?static?void?main?(?String?args?) { EventQueue.invokeLater?(new?Runnable?() { Override public?void?run?() { final?TestImage?ti?=?new?TestImage?(); ti.setSize?(new?Dimension?(,?)); ti.setLocationRelativeTo?(null); ti.addWindowListener?(new?WindowAdapter?() { Override public?void?windowClosing?(?WindowEvent?e?) { System.exit?(); } Override public?void?windowDeiconified?(?WindowEvent?e?) { ti.canvas.start?(); } Override public?void?windowIconified?(?WindowEvent?e?) { ti.canvas.stop?(); } }); ti.setResizable?(false); ti.canvas.start?(); ti.setVisible?(true); } }); }}

您可能感兴趣的文章:

相关文章