Archive | EN Java

[JavaSwing] JLabel

Contents Create a simple JLabel Put color, JLabel JLabel background color is often used to display text or images to make the instructions, instructions on the user interface. In the picture above using 4 JLabel user to correctly enter the required information. Example 1: Create simple JLabel result we are 3 JLabel as follows (Note file […]

[JavaSwing] HelloWorld

In this article we will learn some basic steps to create a JFrame – That's roughly the application framework. Example 1: Create 1 frame 250×200 title “HelloWorld” appears in the coordinates (300, 200) on-screen. We have 4 constructor 1 JFrame: JFrame() : Initialize a new frame invisible JFrame(GraphicsConfiguration qc) : Create a Frame is just […]

[Java] Exercise Java library management

Threads: A library to manage documents include, Book, Journal, Newspaper + Each material properties: Code document, Imprint, Number release. + The type of management needed: Author Name, number of pages + The magazine should manage: Issue, May release + The report should manage: release date. 1. Building class […]

[Java] Recursive call in the main Java

Unexpectedly, when a friend gave this code and the test was run.

[Java] The level of access in java – Edit in Java

To protect data prevent free access from outside, object-oriented programming using the keywords specified range access the properties and methods of the class. Java uses some later complements to control access to the components of the object : public: Ingredients public, free access from outside. protected: Ingredients are […]

[Java] Permutation functions in Java – Swap in Java

The implementation of the function swap (swapped – conversion) in java it is somewhat different from C / C or Pascal,… To change the value of the variable out of a function, you must use the object. You can refer to 2 The following example function swap later if you want to read the details below or if the code was puzzled to read, then read […]

[Java] How to run Java code on ideone.com, Compound

Tran ideone.com page is a code that allows you to give up, stored in user accounts and special can compile and run it to us immediately. However with the introduction of Java code to which we often mistake: Main.java:6: error: class bt1 is public, should be declared in a file named bt1.java public class bt1 { ^ 1 Error error was due to name their class […]

[Java] Drifting in order to use Java Scanner

When using the scanner to enter data in Java are likely to be passed command. For example, as you simply enter the number first and then enter the string, Meanwhile characters “n” (enter) when you enter the number of buffers that have not been retrieved, results when executing the next entry it takes character strings “n” do you not get into. To […]

[Java] Get the file path in Java – Get File Path in Java

To get the path 1 Java file, use the command file.getAbsolutePath(); However, this command gives us the file we get, example: /media / agency / DATA / textfile.txt that sometimes we just want to get / media / agency / DATA. To do this we make the following: Code illustrations: Output: Absolute file Path : /media/quan/DATA/textfile.txt File Path : /media/quan/DATA

[Java] Creat file, directory in Java

Create a folder in the project : With our first order only declared but not yet created, to create 1 folder must write the second order. Create a folder in the path of any: Create a file in the project: When creating the file may be some exceptions, we have orders file.createNewFile(); trong try catch. Create a file in any folder created similar […]