Skip to content

Add more javabeginners files #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Java_Beginners/51_javaBeginners.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//tuna.java file
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class tuna extends JFrame{

private JLabel item1;

public tuna(){
super("The title bar");
setLayout(new FlowLayout());

item1 = new JLabel("this is sentence");
item1.setToolTipText("This is gona show up on hover");
add(item1);
}

}
//apples.java
import javax.swing.JFrame;

class apples {
public static void main(String[] args){

tuna bucky = new tuna();
bucky.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
bucky.setSize(275,180);
bucky.setVisible(true);
}
}
72 changes: 72 additions & 0 deletions Java_Beginners/52_53_54_javaBeginners.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//tuna.jav file
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JOptionPane;

public class tuna extends JFrame{

private JTextField item1;
private JTextField item2;
private JTextField item3;
private JPasswordField passwordField;

public tuna(){
super("The Title");
setLayout(new FlowLayout);

item1 = new JTextField(10);
add(item1);

item2 = new JTextField("enter text here");
add(item2);

item3 = new JTextField("uneditbale", 20);
item3.setEditable(false);
add(item3);

passwordField = new JPasswordField("mypass");
add(passwordField);

thehandler handler = new thehandler();
item1.addActionListener(handler);
item2.addActionListener(handler);
item3.addActionListener(handler);
passwordField.addActionListener(handler);
}

private class thehandler implements ActionListener{
public void actionPerformed(ActionEvent event){

String string = "";

if(event.getSource()==item1)
string=String.format("field 1: %s", event.getActionCommand);
else if(event.getSource()==item2)
string=String.format("field 2: %s", event.getActionCommand);
else if(event.getSource()==item3)
string=String.format("field 3: %s", event.getActionCommand);
else if(event.getSource()==passwordField)
string=String.format("password field is : %s",event.getActionCommand);

JOptionPane.showMessageDialog(null, string);
}

}
}

//apples.java file
import javax.swing.JFrame;

class apples{
public static void main(String[] args)
{
tuna bucky = new tuna();
bucky.setDefalutCloseOperation(JFrame.EXIT_ON_CLOSE);
bucky.setSize(350,100);
bucky.setVisible(true);
}
}
37 changes: 37 additions & 0 deletions Java_Beginners/55_javaBeginners.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//food.java file

public class food{
void eat(){
System.out.println(" this food is great");
}

//tuna.java file

public class tuna extends food{
void eat(){
System.out.println(" this tuna is great");
}

//potpie.java file

public class potpie extends food{
void eat(){
System.out.println(" this potpie is great");
}
}

//apples.java file

class apples {
public static void main(String[] args)
{
food bucky[] = new food[2];
bucky[0]=new potpie();
bucky[1]=new tuna();

for(int x=0;x<2;++x){
bucky[x].eat();
}
}
}

39 changes: 39 additions & 0 deletions Java_Beginners/56_javaBeginners.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//food.java file

public class food{
void eat(){
System.out.println(" this food is great");
}

//tuna.java file

public class tuna extends food{
void eat(){
System.out.println(" this tuna is great");
}

//potpie.java file

public class potpie extends food{
void eat(){
System.out.println(" this potpie is great");
}
}

//fatty.java file

public class fatty{
public void digest(food x){
x.eat();
}
}
//apples.java file
public static void main(String[] args)
{
fatty bucky = new fatty();
food fo = new food();
food po = new potpie();

bucky.digest(fo);
bucky.digest(po);
}