LEARNING JAVA #6steemCreated with Sketch.

in #java5 years ago (edited)

LEARNING JAVA
Published with SteemPeak

ScreenshotScreenshot by Willi Glenz

UPDATE #6

008 MODIFIER

                Class Package Subclass World
private            ok       -        -     -
default            ok      ok        -     -
protected          ok      ok       ok     -
public             ok      ok       ok    ok


007 BASIC GUI-SNIPPET

package de.wglenz.java;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class Main {
    JFrame frame;
    JPanel panelWest;
    JPanel panelCenter;
    JLabel label;
    JButton buttonWest;
    JButton buttonSouth;
    JButton buttonEast;

    public Main() {
        super();

        panelWest = new JPanel();
        panelCenter = new JPanel();
        label = new JLabel("LabelCenter");
        
        buttonWest = new JButton("ButtonWest");
        buttonWest.addActionListener(new Listener1());

        buttonSouth = new JButton("ButtonSouth");
        buttonSouth.addActionListener(new Listener2());

        buttonEast = new JButton("ButtonEast");
        buttonEast.addActionListener(new Listener3());

        frame = new JFrame("Phoenix v 0.003");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(BorderLayout.CENTER, panelCenter);
        frame.getContentPane().add(BorderLayout.WEST, panelWest);
        frame.getContentPane().add(BorderLayout.SOUTH, buttonSouth);
        frame.getContentPane().add(BorderLayout.EAST, buttonEast);
        frame.setSize(1200, 600);
        frame.setVisible(true);
        
        panelCenter.add(label);
        panelWest.add(buttonWest);  }

    public static void main(String... args) {
        Main phoenix = new Main();
        phoenix.run();
    }

    class Listener1 implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            label.setText("ButtonWest: OK");
        }
    }

    class Listener2 implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            label.setText("ButtonSouth: OK");
        }
    }

    class Listener3 implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            label.setText("ButtonEast: OK");
        }
    }

    public void run() {
        //
    }

}

006 VIM

:!javac % && java ClassName
> or
:set makeprg=javac
:make % && java ClassName
005 OPERATORS

Arithmetic      + - * / & ++ --
Relational      == != > < >= <=
Bitwise         & | ^ ~ << >> >>>
Logical         && || !
Assignment      = += -= *= /= %= <<= >>=  &= ^= |=
Miscellaneous   ?: instanceof
004 VIMRC

$ vim ~/.vimrc
> " GENERAL
> syntax on
> filetype on
> filetype plugin on
> set laststatus=2
> set colorcolumn=80
> set nocompatible
> set number
> set relativenumber
> "set cursorline
> set incsearch
> set hlsearch
> set showmode
> set ruler
> set linebreak
> set showcmd
> set mouse=a
> set background=dark
> set encoding=utf8
> 
> " INDENT
> set autoindent
> 
> " TABs
> set tabstop=3
> set softtabstop=3
> set shiftwidth=3
> set expandtab
>
> " JAVA
> set makeprg=javac
> 
> " MAPs
> :nmap <leader>w :w!<cr>
> :map <F2> :echo 'Current time is ' . strftime('%c')<CR>
> :map <F5> :set list!<CR>
> :map <F6> :setlocal spell! spelllang=en_us<CR>
> :ab psv public static void(String[] args) {<cr>}<esc>ko
> :ab sout System.out.println(
003 BASIC CLI-SNIPPET

public class Main {
   private String msg;

   public Main() {
      super();
      this.msg = "Hello World!";
   }

   public static void main(String[] args) {
      Main phoenix = new Main();
      phoenix.run();
   }

   public void run() {
      System.out.println(msg);
   }

}
002 PRIMITIVE DATA TYPES

TYPE        SIZE    RANGE                   DEFAULT CLASS&FIELD
byte        8 bit   -2^7 to 2^7 -1          0
short       16 bit  -2^15 to 2^15 -1        0
int         32-bit  -2^31 to 2^31 -1        0       Integer.MIN_VALUE to Integer.MAX_VALUE
long        64 bit  -2^63 to 2^63-1         0L
float       32 bit  -3.4E38 to 3.4E38       0f
double      64 bit  -1.7E308 to 1.7E308     0d
char        16 bit  '\u0000' to '\uffff'    '\u0000'
                    (0 to 65,565)
boolean     1 bit                           false
001 SOURCES

Bradley Kjell   chortle.ccsu.edu/java5/index.html
TutorialsPoint  www.tutorialspoint.com/java/index.htm
JavaTpoint      www.javatpoint.com/java-tutorial
IdeOne          ideone.com
Sort:  

Congratulations @wglenz! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You published more than 550 posts. Your next target is to reach 600 posts.

You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

You can upvote this notification to help all Steem users. Learn how here!

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 63204.10
ETH 2560.70
USDT 1.00
SBD 2.79