Jumat, 05 Agustus 2011

[java swing] Component : Text

- Ketikkan kode berikut :
import java.awt.*;
public class WindowText extends Frame {
public void paint(Graphics g) {
setSize(300, 200);
setTitle(getClass().getName());
Font f = new Font( "Monospaced" , Font.BOLD, 16);
g.setFont(f);
g.drawString( "Hello ... ", 10 , 100);
g.drawString( "Salam kenal dari Frame ... ", 30 ,120);
}
public static void main(String[ ] args) {
WindowText coba = new WindowText();
coba.setSize(500, 300);
coba.setLocation(200, 100);
coba.setTitle("Window Text ");
coba.show();
}
}

- Simpan dengan nama WindowText.java
- Compile $>javac WindowText.java
- Compile $>java WindowText

[java swing] Container : Frame

- Ketikkan kode berikut di editor :

import javax.swing.*;
class FramePertamaku extends JFrame {
public FramePertamaku() {
setTitle( "Frame Pertama ");
setSize( 300 , 200 );
}
}
public class Frameku {
public static void main (String args[ ] ) {
FramePertamaku coba = new FramePertamaku();
coba.show();
}
}

- Simpan dengan nama Frmaeku.java
- compile dengan command $>javac Frameku.java
- Lanjutkan dengan command $>java Frameku

Kamis, 04 Agustus 2011

[java] Hello World

- Ketikkan kode berikut di editor (notepad dan semacamnya) :

public class Hei{
public static void main(String[] args){
System.out.println("tes");
}
}

- Simpan dengan nama Hei.java.
- Buka command prompt
- Masuk directory file Hei.java
- Jalankan perintah $>java Hei.java (jika sukses, akan dihasilkan file Hei.class)
- Jalankan perintah $>javac Hei (jika sukses, akan tampil tulisan tes)

Semoga bermanfaat

Senin, 18 Juli 2011

vi

Berikut cara menggunakan editor vi di console :

STARTING vi
   vi filename    edit a file named "filename" 
   vi newfile     create a new file named "newfile"
ENTERING TEXT
     i            insert text left of cursor
     a            append text right of cursor
MOVING THE CURSOR
     h            left one space
     j            down one line
     k            up one line
     l            right one space
BASIC EDITING
     x         delete character
     nx        delete n characters
     X         delete character before cursor
     dw        delete word
     ndw       delete n words
     dd        delete line
     ndd       delete n lines
     D         delete characters from cursor to end of line
     r         replace character under cursor
     cw        replace a word
     ncw       replace n words
     C         change text from cursor to end of line
     o         insert blank line below cursor
                  (ready for insertion)
     O         insert blank line above cursor
                  (ready for insertion)
     J         join succeeding line to current cursor line
     nJ        join n succeeding lines to current cursor line
     u         undo last change
     U         restore current line
MOVING AROUND IN A FILE
     w            forward word by word
     b            backward word by word
     $            to end of line
     0 (zero)     to beginning of line
     H            to top line of screen
     M            to middle line of screen
     L            to last line of screen
     G            to last line of file
     1G           to first line of file
     <Control>f   scroll forward one screen
     <Control>b   scroll backward one screen
     <Control>d   scroll down one-half screen
     <Control>u   scroll up one-half screen
     n            repeat last search in same direction
     N            repeat last search in opposite direction
CLOSING AND SAVING A FILE
     ZZ            save file and then quit
     :w            save file
     :q!           discard changes and quit file
 
Sumber : sumber