Java example code, how to use extends and implements in class package myjavaexample; public class MyJavaExample { private interface DoSomething { public void sound(); } private class Animal { public String voice= "Animal" ; public Animal() { } public Animal(String voice) { this .voice=voice; } } private class Pet extends Animal implements DoSomething { public Pet() { } public Pet(String voice) { super(voice); } public void sound() { System.out.println( this .voice); } } public void experiment() { Pet dog= new Pet(); dog.sound(); Pet cat= new Pet( "Miauww" ); cat.sound(); Pet bird= new Pet( "Cici" ); bird.sound(); } ...
This is the Java code example how to activated right click in JTextArea. package myjavaexample; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.ActionEvent; import javax.swing.Action; import javax.swing.BoxLayout; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.KeyStroke; import javax.swing.border.EmptyBorder; import javax.swing.text.DefaultEditorKit; import javax.swing.text.JTextComponent; import javax.swing.text.TextAction; public class MyJavaExample extends JFrame { public void setup() { this .setSize(800,600); this .setLocation(200,200); this .setTitle( "JTextArea Right Click" ); this .setLayout( new BorderLayout()); JPanel panel= new JPanel(); panel.setBorder( new EmptyBorder(5, 10, 5, 10)); JTextArea t...
Comments
Post a Comment