GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add more javabeginners files · 4CGO/Source-Code-from-Tutorials@3febef0

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Java_Beginners
    • 51_javaBeginners.java
    • 52_53_54_javaBeginners.java
    • 55_javaBeginners.java
    • 56_javaBeginners.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Java_Beginners/51_javaBeginners.java‎

Copy file name to clipboard
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//tuna.java file
2+
import java.awt.FlowLayout;
3+
import javax.swing.JFrame;
4+
import javax.swing.JLabel;
5+
6+
public class tuna extends JFrame{
7+
8+
private JLabel item1;
9+
10+
public tuna(){
11+
super("The title bar");
12+
setLayout(new FlowLayout());
13+
14+
item1 = new JLabel("this is sentence");
15+
item1.setToolTipText("This is gona show up on hover");
16+
add(item1);
17+
}
18+
19+
}
20+
//apples.java
21+
import javax.swing.JFrame;
22+
23+
class apples {
24+
public static void main(String[] args){
25+
26+
tuna bucky = new tuna();
27+
bucky.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
28+
bucky.setSize(275,180);
29+
bucky.setVisible(true);
30+
}
31+
}
Collapse file

‎Java_Beginners/52_53_54_javaBeginners.java‎

Copy file name to clipboard
+72Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
//tuna.jav file
2+
import java.awt.FlowLayout;
3+
import java.awt.event.ActionListener;
4+
import java.awt.event.ActionEvent;
5+
import javax.swing.JFrame;
6+
import javax.swing.JTextField;
7+
import javax.swing.JPasswordField;
8+
import javax.swing.JOptionPane;
9+
10+
public class tuna extends JFrame{
11+
12+
private JTextField item1;
13+
private JTextField item2;
14+
private JTextField item3;
15+
private JPasswordField passwordField;
16+
17+
public tuna(){
18+
super("The Title");
19+
setLayout(new FlowLayout);
20+
21+
item1 = new JTextField(10);
22+
add(item1);
23+
24+
item2 = new JTextField("enter text here");
25+
add(item2);
26+
27+
item3 = new JTextField("uneditbale", 20);
28+
item3.setEditable(false);
29+
add(item3);
30+
31+
passwordField = new JPasswordField("mypass");
32+
add(passwordField);
33+
34+
thehandler handler = new thehandler();
35+
item1.addActionListener(handler);
36+
item2.addActionListener(handler);
37+
item3.addActionListener(handler);
38+
passwordField.addActionListener(handler);
39+
}
40+
41+
private class thehandler implements ActionListener{
42+
public void actionPerformed(ActionEvent event){
43+
44+
String string = "";
45+
46+
if(event.getSource()==item1)
47+
string=String.format("field 1: %s", event.getActionCommand);
48+
else if(event.getSource()==item2)
49+
string=String.format("field 2: %s", event.getActionCommand);
50+
else if(event.getSource()==item3)
51+
string=String.format("field 3: %s", event.getActionCommand);
52+
else if(event.getSource()==passwordField)
53+
string=String.format("password field is : %s",event.getActionCommand);
54+
55+
JOptionPane.showMessageDialog(null, string);
56+
}
57+
58+
}
59+
}
60+
61+
//apples.java file
62+
import javax.swing.JFrame;
63+
64+
class apples{
65+
public static void main(String[] args)
66+
{
67+
tuna bucky = new tuna();
68+
bucky.setDefalutCloseOperation(JFrame.EXIT_ON_CLOSE);
69+
bucky.setSize(350,100);
70+
bucky.setVisible(true);
71+
}
72+
}
Collapse file

‎Java_Beginners/55_javaBeginners.java‎

Copy file name to clipboard
+37Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//food.java file
2+
3+
public class food{
4+
void eat(){
5+
System.out.println(" this food is great");
6+
}
7+
8+
//tuna.java file
9+
10+
public class tuna extends food{
11+
void eat(){
12+
System.out.println(" this tuna is great");
13+
}
14+
15+
//potpie.java file
16+
17+
public class potpie extends food{
18+
void eat(){
19+
System.out.println(" this potpie is great");
20+
}
21+
}
22+
23+
//apples.java file
24+
25+
class apples {
26+
public static void main(String[] args)
27+
{
28+
food bucky[] = new food[2];
29+
bucky[0]=new potpie();
30+
bucky[1]=new tuna();
31+
32+
for(int x=0;x<2;++x){
33+
bucky[x].eat();
34+
}
35+
}
36+
}
37+
Collapse file

‎Java_Beginners/56_javaBeginners.java‎

Copy file name to clipboard
+39Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//food.java file
2+
3+
public class food{
4+
void eat(){
5+
System.out.println(" this food is great");
6+
}
7+
8+
//tuna.java file
9+
10+
public class tuna extends food{
11+
void eat(){
12+
System.out.println(" this tuna is great");
13+
}
14+
15+
//potpie.java file
16+
17+
public class potpie extends food{
18+
void eat(){
19+
System.out.println(" this potpie is great");
20+
}
21+
}
22+
23+
//fatty.java file
24+
25+
public class fatty{
26+
public void digest(food x){
27+
x.eat();
28+
}
29+
}
30+
//apples.java file
31+
public static void main(String[] args)
32+
{
33+
fatty bucky = new fatty();
34+
food fo = new food();
35+
food po = new potpie();
36+
37+
bucky.digest(fo);
38+
bucky.digest(po);
39+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.