自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(43)
  • 收藏
  • 关注

原创 JAVA Swing布局:流布局FlowLayout;边界布局BorderLayout;网格布局GridLayout;网格组布局管理器GridBagLayout

流布局 FlowLayout从左向右排列 默认居中对齐(像流水一样 向某个方向流动 遇到障碍就折回)运行效果:注意红色箭头的方向 从左至右排列 位置不足就另起一行继续从左至右(若拖动改变窗口大小 就会排列),且默认居中排列(按钮9) 注意若窗体过小 会导致组件显示不全若想选择其他对齐方式 添加如下代码到new FlowLayout里面:有以上各种对齐方式,这里使用左...

2020-01-11 16:12:27 1573 1

原创 JAVA Swing 标签(JLabel)图标的使用(在窗体里添加图片)

JLabel 的一些简单操作图标的使用(在窗体里添加图片)下图中 获取图片路径是通过 Demo.class.getResource 来寻找Demo类目录下的 meinv.png 文件 来返回URL路径输出:以及运行过程中读取的图片路径如下还可以通过直接指定文件的方式来加载图片(直接告诉编译器获取src文件里的图片文件名)另...

2020-01-10 11:51:53 9781 2

原创 JAVA Swing概述 常用组件实例 JFrame窗体 JDialog 窗体(简单的涉及了布局和监听器知识)

Swing 概述AWT会因运行平台不同而有不同的外观,而Swing都是统一风格外观Swing 常用组件:JPanel可以理解为一个空的容器,不能单独显示 必须放在JFrame 或者 JDialog里JFrame 窗体JDK8以前 JFrame无法直接add组件, 但是JDK8已经可以了. 所以并不需要每次都去对顶层pane进行操作....

2020-01-09 14:00:29 600

原创 Course Note: Java Swing 窗体设计及监听器

http://c.biancheng.net/view/1209.html创建一个窗体运行效果需要注意此时即使点右上角的关闭后,程序依然不会停止运行。需要手动点击停止运行程序若想做到点击关闭按钮后停止运行程序则要加入如下代码:此外还有如下方法可供调用(根据名字和方法的命名规则记忆)以上代码运行后,会发现窗口尺寸非常小,因为我们没有设置窗口的初...

2019-09-22 18:12:18 256

原创 Course Note: 内部类

内部类含义好处:不需要额外新建一个类文件成员内部类定义注意:内用外,随意访问。但外用内需要借助内部类的对象。如上图,在内部类里 可以直接访问外部类的成员变量。成员内部类的使用1.间接方法: 在外部类方法中使用内部类,然后mainclass只调用外部类的方法在外部类的方法里 对内部类进行实例化,然后访问内部类方法。之后再在主class里...

2019-09-15 08:36:55 128

原创 Course Note: 堆Stack,队列Queue 操作

在Java中,堆和队列等操作 都是对集合进行操作堆Stack 操作:最后结果:队列Queue操作:通常与LinkedList一起用LinkedList这个子接口多继承了Queue和List从队列头部移除元素换成其他类型元素,例如为先来的顾客优先提供服务:...

2019-09-11 14:09:22 89

原创 Course Note: ArrayList

ArrayList 是一个集合,也是一个类。只不过这个集合像数组一样拥有多个相同类型的元素。使用 import java.util.ArrayList 导包泛型(generic type)因为集合里保存的都是地址值,但是基本类型没有地址值,所以说ArrayList的泛型generic type不能是基本类型注意对于ArrayList集合,直接打印,可以出...

2019-09-11 10:53:55 114

原创 Course Note: 接口Interface 及UML

接口Interface接口就是一种公共的规范标准Java里的接口就是多个类的公共规范。接口是一种引用数据类型定义方法如下:(将class改成interface,但编译生成的字节码文件仍然是 .class)与继承相比,一个类可以有implements多个接口,但只能有一个父类接口里的内容有:上图课堂里教的是普通的方法,下面补充其他类型的方法...

2019-09-11 08:59:25 538

原创 Course Note: 多态Polymorphism,instanceof

多态:有多种形态。前提:有上下级关系(继承,接口)。父类引用指向子类对象:格式: 父类名称 对象名 = new 子类名称();子类:父类:此时运行的时子类Zi的method。这种情况下方法的优先级和普通继承的一样,先找子类的方法,若子类没有该方法,就去父类里找并运行。多态下成员变量的访问访问方法与普通的继承一样,但因为多态的格式与普通继...

2019-08-15 17:53:08 225

原创 Course Note: 抽象类Abstract classes

概念:如图,虽然父类里有相关方法,但由于这样的方法必须根据具体情况才能确定方法体如何实现(即过于抽象),因此这样的方法叫抽象方法,这样的父类叫抽象类。抽象方法的写法:(抽象方法所在类必须是抽象类)在返回值类型前加上abstract,并且不写大括号及内容(方法体)。抽象类的写法:在class之前写上abstract除此之外,抽象类也可以...

2019-08-15 16:07:45 206

原创 Course Note: The Object Class,Class Hierarchies

在Java里,万物皆对象。比如String, Scanner等等。这些类在使用时,都被实例化为对象再进行使用。And all classes are derived ultimately from the Object class.The Object class is defined in the java.lang package of the Java Standard Clas...

2019-08-14 20:05:50 173

原创 Course Note: 继承(Inheritance,Is-a Relationship) super,protected关键字

面向对象三大特性: 封装性(Polymorphism),继承性(Inheritance),多态性(Polymorphism)继承是多态的前提,没有继承就没有多态!继承继承主要解决:共性抽取如图,因为讲师类和助教类都有相同属性(姓名和工号),因此将这两个属性抽取出来放在员工类,让讲师类和助教类继承员工类的属性。这样就不用每个类都定义一遍相同的属性(或方法):...

2019-08-06 08:57:25 226

原创 Course note: Strings,String Methods

Strings要用数组的思想来理解String与数组声明方法类似,也与类的实例化思想相同The String object is immutable, meaning once a String object is created, its value cannot be lengthened or shortened; none of the characters canchan...

2019-08-05 17:35:27 123

原创 Course note: Arrays(及内存原理,遍历), An (Object of )Arrays of Objects, 2D Array,As Return Type

Array(数组)数组初始化:与C语言一样,在内存中创建一个数组,并赋予默认值注意JAVA的数组声明与c语言格式不一样 ! !Java是把[ ] 放数组名的前面 ! !1.动态初始化(在最开始时定义数组长度)数据类型[ ] 数组名称 = new 数据类型[数组长度];2.静态初始化(在最开始时指定具体内容)数据类型[ ] 数组名称= new 数据类型[...

2019-08-05 16:05:29 129

原创 Course note: Encapsulation(private),toString(),static keyword,final keyword,Enumeration(作业中用法),UML

()EncapsulationThe instance data of an object should be modified only by that object.(An object should be encapsulated from the rest ofthe system.)需用如下方法才能 调用或修改 private data:The names of acces...

2019-07-29 19:41:36 148

原创 Course Note: Create Methods,Public Access Modifier,Method Overload,Documentation Standards

Define A MethodStep 1:Define the method signature• name• input parameters• return typeWrite the method signature and body in the classStep 2: Return valueStep 3: Method body当一个类...

2019-07-25 18:10:14 103

原创 Course note:Object Referencing,Null Pointer Exception,Wrapper Classes,Instances,Constructor

Object ReferencingA variable can hold either a primitive value or a reference to an object (itdoesn't actually hold the object itself).Can think object references like C pointers, a refer...

2019-07-25 17:35:20 103

原创 Some Points of Class Definition, Variables.,Scanner(用类与对象的思想理解,及其陷阱。通过匿名对象来使用)

Class definitionWhen we type the name of clas:The name should be started by capital and there is no white-space between words. (unless the word is required to be all capitals)Variables...

2019-07-18 15:55:08 159

原创 Introduce JAVA OOP(Object,Class,Method), Character strings, their use, concatenation and conversion

A small JAVA programMethods (方法)A method is a group of programming statements that is given a name.即C语言中的的 function(函数)。定义与调用:(与C语言一样, 但方法需定义在class里面)Java is Object-Oriented Parad...

2019-07-15 19:21:21 117

原创 Windows Programming, MSDN, Win32 MsgBox

Windows Handles (窗口句柄)The Windows Operating system uses “handles” to refer to components of windowsHANDLE:This is a Windows.h type and typedef void* HANDLE(address)It stores the handle of...

2019-07-15 17:21:44 125

原创 Header Files, Static Libraries, P1Colour, Input Polling

The .h FileThe header file is used to declare function prototypesIn this case: the main.c file includes the myfunction.h header file to get access to the myfunction.c functions.As this Prot...

2019-07-02 16:57:41 119

原创 Windows API

Windows API: StringsASCII vs Unicode (char vs wchar_t)sizeof(char)evaluates to be 1 byte.sizeof(wchar_t) evaluates to be 2 bytes.Windows API: System FunctionsThese will return an int...

2019-07-02 16:57:32 533

原创 Bitwise Operators

Bitwise Operators:Bit ShiftingBit Flags:int alive = 1;int tired = 2; Using Bit Flags to pack multiple pieces of knowledge into a single variableint studen...

2019-07-02 16:57:21 262

原创 Dynamic Memory, The Heap, Memory Leaks, Recursive Composition

Dynamic Memory Allocation: mallocallocated memory at runtimeStack vs Heap:Stack Frames store per function call:Local variables, parameters, return value Heap stores:Dynamic alloca...

2019-07-02 16:57:12 135

原创 Function Pointers, Callbacks, QSort, BSearch

2019-07-02 16:57:03 81

原创 File Input and Output, Hex Editor

File input/output:Writing to text files is very similar to using printf..Reading in text from a text file:is very similar to using scanfA Hex Editor is a program...

2019-07-02 16:56:54 156

原创 typedef, Testing, VS Memory Patterns, New SLN, Warnings

view the “Warning Level”:right click the project -> choose the “properties” -> go to “C/C++” section, and find the “General” tab->set the level to leve 4...

2019-07-02 16:56:43 53

原创 Multi-Dimensional Arrays, main Parameters, Casting, void Pointers

2D Arraystypearray_name[dimension1] [dimension2]A 2D array is often useful for storing tabular dataArray initialization:Multi-Dimensional Arrays: 3D Arrays or moreF...

2019-07-02 16:56:34 201

原创 The Pre-Processor, Assert, Build Targets, Function Comments

Preprocessor DirectivesPreprocessor Directives tell the Preprocessor to perform specific actions:#include: Copy the contents of the included file into this source file…#define: Create a Ma...

2019-07-02 16:56:21 131

原创 Pointers, Pass by Reference, Passing Arrays and C-Strings, Pointer Arithmetic

PointerFirstly, let’s review how to print the hexadecimal(16 base)Remember: Every time the program is run, the address of data will likely be different.When declare...

2019-07-02 16:56:08 105

原创 Structures, Dot Operator, Passing Structures, Data Abstraction,

StructuresUsing StructuresPassing Structures to Functions, by ValueReturning a Structure from a FunctionArrays of Structuressizeof and structThe Ord...

2019-06-27 11:24:44 98

原创 Function Bugs, Side Effects, Recursion, Enumeration,Slot Machine

Common Function Bugs / Mistakes :Functions with Side Effects: (Any extra actions that a function does)A function with no side effects is known as a pure function (otherwise, call impu...

2019-06-27 11:21:37 141

原创 Functions, void, return, The Call Stack,Arguments, Parameters, Call by Value, Scope, Returning Data

Invoking Functions:The void keyword for invoking functions(when define a funciton):Define and call a function:The return key in function(when we need the function return something to...

2019-06-27 11:16:42 130

原创 Nested Loops, goto, Scope, Variable Lifespan,

Nested Loops:Nested while loops:ASCII Art Triangle:Printing a Holiday Tree:The goto Keyword:The life span of variable:Once ...

2019-06-27 11:12:17 200

原创 for, Arrays and for Loops,for Loop bugs, Nested Selection

for KeywordUsing for loops with ArraysOutput all the elements on the array.Divide Each Element by 2Can use while to achieve same targetSimilar with using %s with print...

2019-06-27 11:08:58 152

原创 Common Selection Bugs, switch, Conditional Operator,Repetition, while, do while, break, continue

Notice: the comparation of char: =>For the on litter (char), the ‘’ should be used inside comparationFor the string use the “ ” :Do not use if (input == 'y' || 'Y')should be...

2019-06-27 11:05:27 171

原创 Selection, if, else, Relational Operators,Nested Selection,else if, Logical Operators

The if Keyword a == b means does a equal b? a != b means does a not equal b? a > b means is a greater than b? a >= b ...

2019-06-27 11:03:01 86

原创 Practical Test Reminders, Character Arrays, C-Strings

Printing a Character ArrayPrinting blocks of text (%s) C-Stringprint from the array specified, until it finds an element in the char array that has the value 0C-Strings: a collecti...

2019-06-27 10:53:42 144

原创 Solving Programming Problems, Whitespace, The Debugger

Input-Process-OutputProcedure:Understand the problem Identify the outputs Decide the type of data Design an algorithmDesign Algorithm:Analysis task Solve the problem by hand Solve ...

2019-06-27 10:52:15 180

原创 Arrays, Memory Window, Math, Random Numbers

ArraysDeclarationint array1[5]; (number is how much components in the array)this array includes the components: array1[0], array1[1], array1[2], array1[3], array1[4]This process can b...

2019-06-27 10:28:34 84

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除