Featured post

Our First Windows

first window

In this part we will discuss the GUI (also referred to HMI for I nterfaces M ike M achine or GUI for G raphicalU ser I nterfaces) and, by extension, event programming. By this, you must understand that your program will not respond to keystrokes but events from a graphical component: a button, list, menu … and this is very important to really grasp when you first want to learn what is java!

The Java language provides different libraries for programming GUI, but in this book we primarily use the packages javax.swing and java.awt present automatically in Java. This chapter will help you learn to use the object JFrame , present in the package java.swing . You will then be able to create a window, set its size, etc.

The basic operation of HMI you will also be presented and you will learn that, in reality, a window is only a multitude of components placed on each other and that everyone has a role of its own.
But enough chatter useless, start now!

The JFrame object

Before we launch headlong into this game, you must know what we will use. In this course we will deal with javax.swing and java.awt . We do not use components awt , we will work only with componentsswing ; however, objects from the package awt will be used to interact and communicate with components swing . For example, a component can be represented by a button, a text box, a check box, etc.

To better understand how it all works, you should know that when Java was born, in version 1.0, only awtwas usable; swing did not exist, he appeared in version 1.2 Java (also called Java 2). The components awtare considered heavy (also called Heavyweight ) as they are strongly linked to the operating system, it is the latter which manages. The components swing themselves are designed in such a container, they are said to light (also called LightWeight ); they do not have the same rendering to the display, because it is no longer the operating system that manages them. There are also other differences, such as the number of usable components, management of borders …

For all these reasons, it is strongly recommended not to mix the components swing and awt in a single window; This could cause conflicts! If you combine the two, you will have great difficulties in developing a stable and valid HMI. Indeed, swing and awt have the same foundation but differ in their use.

This closed parenthesis, we can get into the thick of it. I am not asking you to create a project with a classhand , it must be ready for ages! To use a window type JFrame , you must instantiate it like this:

import javax.swing.JFrame;


public  class  Test  {

  public static void main(String[] args){       

    JFrame  fenetre  =  new  JFrame ();



When you run this code, you get nothing, because by default, your JFrame is not visible. So you have to say “be visible” in this way:

import javax.swing.JFrame;


public  class  Test  {

  public static void main(String[] args){

    JFrame  fenetre  =  new  JFrame ();




So when you run this code, you get the following figure.

what is java

To all those who say that this window is very small, I say, “Welcome to the world of event programming!”We need you to do, your components are not intelligent: he’ll have to tell them everything they need to do.

For a more substantial window should therefore:

  • to be larger;
  • it has a title (this would not be luxury!);
  • it appears in the center of the screen would be perfect;
  • that our program actually stops when you click on the red cross, because for those who have not noticed, the Eclipse process is still running even after closing the window.

For each of the elements I just mentioned, there will be a method to call to our JFrame know what to expect. Here is also a code that meets all our requirements:

import javax.swing.JFrame;


public  class  Test  {

  public static void main(String[] args){


    JFrame  fenetre  =  new  JFrame ();


    // Set a title for our window

    window . setTitle ( 'My first Java window " );

    // Set size: 400 pixels wide and 100 pixels high

    window . setSize ( 400 ,  100 );

    // We now ask our subject to position the center

    window . setLocationRelativeTo ( null );

    // Terminates the process when you click on the red cross


    // And finally, make it visible        




See the rendering of this code by following figure.

java 8

To avoid having to redefine the attributes each time, I think it would be helpful if we had our own object.That way we’ll have our own classroom!

To start, erase all the code we’ve written in our method hand . Next we create a class we’ll call Window and make it inherit JFrame . We will now create our constructor, in which we place our instructions.
This gives us:

import javax.swing.JFrame;


public class Fenetre extends JFrame {

  public  fenêtre () {

    this.setTitle("Ma première fenêtre Java");

    this.setSize(400, 500);






Then you have the choice: either you keep your class containing the method hand and you create an instance of Window or you delete this class and method you put your hand in your class Window . But in all cases, you must create an instance of your Window . Personally, I prefer to put my method hand in a class by itself … But I do not require you to join me! Whatever the location of your hand , the following line of code must be included:

Fenetre  fen  =  new  Fenetre ();

Run your new code, and … you get the exact same thing as before. You will agree that it is still more convenient not to write the same instructions each time. So you have a class that will be responsible for displaying your future program. And here is a list of methods that you will be likely to use.

Position the window on the screen

We have focused our window, but you might want to place it elsewhere. For this you can use the methodsetLocation (int x, int y) . With this method, you can specify which must be your window on the screen. The coordinates in pixels, are based on a benchmark whose origin is represented by the upper left corner (Figure below).

java training

The first value of the method positioned on the axis x , 0 corresponding to the beginning; positive values ​​move the window to the right while negative make it out of the screen from the left. The same rule applies to the values ​​of the axis y , except that the positive values ​​bring down the window from behind while negative make it come out on top of the screen.

Prevent window resizing

To do this, simply invoke the method setResizable (boolean b) : false prevents resizing while truepermits.

Keep the window to the foreground

This is still a method that takes a boolean parameter. Skip true leave the window to the foreground what happens, false void that. This method is setAlwaysOnTop (boolean b) .

Remove the contours and control buttons

To do this, use the method setUndecorated (boolean b) .

I will not go around all methods now because anyway, we’re going to use many of them very prochainement.Cependant, I guess you would rather fill your window. I thought so, but before you must still learn a breast. Indeed, your window, as it appears, you hide a few things!

You think, and that is legitimate, that your window is simple, devoid of any component (excluding contours). Well think again! A JFrame is divided into several overlapping parts, as shown in the following figure.



We have, in order:

  • the window;
  • the RootPane(green), the main container that contains other components;
  • the LayeredPane(purple), which just formed a panel composed of the global container and the menu bar ( MenuBar );
  • the MenuBar(in orange), the menu bar, when there is one;
  • the pane happy(pink): it is in this that we will put our components;
  • the GlassPane(transparent) layer used to intercept user actions before they reach the components.

Do not worry, we will use only the content pane. To retrieve it, we just need to use the methodgetContentPane () of the class JFrame . However, we will use a component other than the pane happy: a JPanel in which we will insert our components.

There are other types of window: the JWindow a JFrame borderless and not draggable (movable), and JDialog , a non-resizable window. We do not discuss here, however.



Java Programming – Step by Step tutorial

Easy to follow step by step Java programming tutorial.
Buy the full 4 hour video at http://www.patrickvideos.com.
The direct download link at https://gumroad.com/l/WloP

In 4 hrs you will learn all the important concepts of Java, each explained using small simple programs. The teaching method used, will be the easiest way to learn Java, that you will ever find.

Reproducing the previously top rated comment and my reply to it. This shows the exact advantage of my video.
From weefunkster:
Incredible pace and excellent learning structure. I bit the bullet and payed for the full course and I have no regrets whatsoever. The price would be worth it for the editing alone, I can’t tell you how bad it is for a learner to hear the instruction’s then have to wait for the instructor to type the code before getting an explanation. I didn’t realize it was so bad until I watched this and I wondered why my mind wondered all over the place and I didn’t learn a thing. Truly Brilliant

My Reply:
Thank You! I am so so happy that at-last someone realized the effort that went into editing and the true advantage of the video. People write and ask how can someone learn Java in 4 hrs? This is not a 4 hr class, but a full 5 day(40 hrs) class. Edited so tight(No err, uhh, sometimes I edited out even the time between the words) that what resulted is a 4hr video. Even I was shocked at so few hours!

Increment Operator and Assignment Operator – Java Tutorial part 6

Increment Operator and Assignment Operator – Java Tutorial part 6
Ubuntu,Software (Industry),Java (Software),Help,Tips,Tutorial (Media Genre),Introduction,Software (album),Computer,Installation (Award-Winning Work),Apple,Maker,Java Development Kit (Software),Windows,Assignment,Java (Programming Language),Increment And Decrement Operators,Tutorial (Media Genre),Project,Java (Software),Need,Industry (Organization Sector),Tricks,Class,Josh,Help,Please,install,download,jdk,se,ee,java,development,new,beginner,tutorials,eclipse
Like and share video if you feel good. Like Fan Page to learn more Tutorial https://www.facebook.com/pages/All-Tutorial-For-Beginners/681138468682230?ref=hl

Java EE 6/7: The Lean Parts

A pragmatic combination of Java EE 6/7 APIs makes the platform extremely productive. With Java EE 6/7, most of the J2EE patterns become obsolete. Even the popular Gang of Four (GOF) patterns are part of the platform and can be “activated” with a single annotation. This tutorial focuses on the lean Java EE 6 way of software development—99 percent business logic and 1 percent infrastructure—and covers the full lifecycle from inception to DevOps. The tutorial involves replacing existing best practices and introduces pragmatic approaches interactively and with executable code.

Copyright © 2013 Oracle and/or its affiliates. Oracle® is a registered trademark of Oracle and/or its affiliates. All rights reserved. Oracle disclaims any warranties or representations as to the accuracy or completeness of this recording, demonstration, and/or written materials (the “Materials”). The Materials are provided “as is” without any warranty of any kind, either express or implied, including without limitation warranties of merchantability, fitness for a particular purpose, and non-infringement.

Oracle 1Z0-850 Java SE 5 and 6, Certified Associate Exam

In this 1Z0-850 exam related video we will share some resources That can insure passing in Oracle 1Z0-850 exam. Read the Description or watch 1Z0-850 test video.
For More Information and Tips Check:

30-40% Candidates fail in Oracle exams even after getting through different tutorials, books and videos. The reason is: They do not validate there knowledge or practice the 1Z0-850 exam before attempting to actual 1Z0-850 exam. It’s a saying “Practice makes perfect”, Following this advice can help to be Oracle certified professional.

For practising and validating your knowledge you can use 1Z0-850 practice test that provides functionality of attempting exam with questions and multiple choices with every question.

The right way of 1Z0-850 test preparation can increase the confidence on your knowledge and what you’ve prepared for. Many Candidates fail in Oracle tests because of exam type or they lose confidence during the exam.

1Z0-850 Questions Answers PDF is also very helpful

“1Z0-850 test” “1Z0-850 test” “1Z0-850 questions” “Oracle1Z0-850 ” “Oracle1Z0-850 test” “1Z0-850 coupon” “1Z0-850 discounts”

SCJP Sun Certified Programmer for Java 6 Exam 310 065 Certification Exam Preparation Course in a Boo

All Exam topics (like looping constructs and variables, how well a programmer has understood the language constructs)are covered and insider secrets, complete explanations of all SCJP Sun Certified Programmer for Java 6 Exam 310-065 subjects, test tricks and tips, numerous highly realistic sample questions, and exercises designed to strengthen understanding of SCJP Sun Certified Programmer for Java 6 Exam 310-065 concepts and prepare you for exam success on the first attempt are provided.
…Offering numerous sample questions, critical time-saving tips plus information available nowhere else, this book will help you pass the SCJP Sun Certified Programmer for Java 6 Exam 310-065 exam on your FIRST try.

Oracle 1Z0-897 Java EE 6 Web Services Developer Exam

In this 1Z0-897 exam related video we will share some resources That can insure passing in Oracle 1Z0-897 exam. Read the Description or watch 1Z0-897 test video.
For More Information and Tips Check:

30-40% Candidates fail in Oracle exams even after getting through different tutorials, books and videos. The reason is: They do not validate there knowledge or practice the 1Z0-897 exam before attempting to actual 1Z0-897 exam. It’s a saying “Practice makes perfect”, Following this advice can help to be Oracle certified professional.

For practising and validating your knowledge you can use 1Z0-897 practice test that provides functionality of attempting exam with questions and multiple choices with every question.

The right way of 1Z0-897 test preparation can increase the confidence on your knowledge and what you’ve prepared for. Many Candidates fail in Oracle tests because of exam type or they lose confidence during the exam.

1Z0-897 Questions Answers PDF is also very helpful

“1Z0-897 test” “1Z0-897 test” “1Z0-897 questions” “Oracle 1Z0-897” “Oracle 1Z0-897 test” “1Z0-897 coupon” “1Z0-897 discounts”

Java Tips

7 Consejos prácticos para el desarrollo en el lenguaje Java
Ejemplos muy sencillos.

Sígueme en:

Java programming part 67 GUI : Adding Tool tips to components

Java Programming tutorial, GUI, Graphical User Interface. this tutorial is teaching You how to add a Tool Tips to your application Components and containers.

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;
public class UserFrame extends JFrame implements ActionListener{
static String name = “charles”;
static JMenuItem print;
setSize(600,550); }

public static void main(String[] args){

UserFrame f = new UserFrame();
JMenuBar bar = new JMenuBar();
bar.setToolTipText(“this is the manu bar please use this carefully”);
JToolBar tb = new JToolBar();
tb.setToolTipText(“This is a too bar”);
JButton jb11 = new JButton(“tb11”);
jb11.setToolTipText(“this button has a tool tip, please read!”);
JButton jb12 = new JButton(“tb12”);
JButton jb13 = new JButton(“tb13”);
JButton jb14 = new JButton(“tb14”);
JButton jb15 = new JButton(“tb15”);
JButton jb16 = new JButton(“tb16”);
JButton jb17 = new JButton(“tb17”);
JMenu fileMenu = new JMenu(“File”);
JMenu editMenu = new JMenu(“Edit”);
print = new JMenuItem(“print name”);
JMenuItem print2 = new JMenuItem(“print nothen”);

JPanel pan1 = new JPanel();
pan1.setLayout(new BorderLayout());
JPanel pan2 = new JPanel();
JPanel pan3 = new JPanel();
JPanel pan4 = new JPanel();
JPanel pan5 = new JPanel();
JPanel pan6 = new JPanel();
pan6.setLayout(new BorderLayout());
JButton jb = new JButton(“Hello”);
jb.setToolTipText(“Hello Button”);
JButton jb6 = new JButton(“WEST added”);
JButton jb7 = new JButton(“EAST added”);
JLabel lb = new JLabel(” label for panel, this is showing the paneel”);
lb.setToolTipText(“this is the label”);
JLabel lb2 = new JLabel(” East”);
pan6.setToolTipText(“this is panel 6”);
jb.setSize(50, 50);
pan1.setToolTipText(“this is panel 1”);
JButton jb2 = new JButton(“there”);
jb.setSize(50, 50);
JButton jb3 = new JButton(“North”);
jb.setSize(50, 50);
JButton jb4 = new JButton(“South”);
jb.setSize(50, 50);
JButton jb5 = new JButton(“Center”);
jb.setSize(50, 50);

public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
JMenuItem item = (JMenuItem) e.getSource();
System.out.println(“you clicked the hello button”);
System.out.println(“you clicked the there button”);



Java Tutorial For Beginners 6 – Math and Arithmetic Operators in Java

Java – Basic Operators
Basics of the Java operators
Searches related to java math operators
java math class
java math operators power
java math operators exponential
java math functions
java square root
java not equal to operator
java math division remainder
java arithmetic operators order
Assignment, Arithmetic, and Unary Operators
Basics of the Java operators
Java Or Operatoren
Java Bit Operatoren
Java Vergleichsoperatoren
Oder In Java
Java Or
Java Arithmetic Operators