JAVA - How To Change A JTextField Font Color, Name, Style, And Size In Java

JAVA - How To Change A JTextField Font Color, Name, Style, And Size In Java

                                                                         


Source Code:


package JavaDB_001;

import java.awt.Color;
import java.awt.Font;
import javax.swing.*;


public class Project extends JFrame{
    public Project(){
    super("Change JTextField Font Name, Style, Size, Color");
    
    //"Verdana" = font name;
    //Font.BOLD = font style, You Can Also Put An Int;
    // 30 = size;
    Font f = new Font("Verdana",Font.BOLD,30);
    JTextField tf = new JTextField(60);
    //set the font to the JTextField
    tf.setFont(f);
    //change a JTextField font color
    tf.setForeground(Color.red);
    tf.setBounds(80,20,250,50);
    add(tf);
    setLayout(null);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLocationRelativeTo(null);
    setSize(400,200);
    setVisible(true);
    }
    public static void main(String[] args){
        new Project();
    }
   }
///////////////////////OUTPUT:
                    
Jtextfield font color , name,size,style
 Jtextfield font color , name,size,style 
See Also In Jlabel

JAVA - How To Change A Jlabel Font Color, Name, Style, And Size In Java

JAVA - How To Change A Jlabel Font Color, Name, Style, And Size In Java

                                                                        

Source Code:

package JavaDB_001;
import java.awt.Color;
import java.awt.Font;
import javax.swing.*;

public class Project extends JFrame{
    JLabel label;
    public Project(){
    super("Change JLabel Font Name, Style, Size, Color");
    label = new JLabel("This Is My Text Here");

    //"TimesRoman" = font name;
    //Font.ITALIC = font style, You Can Also Put An Int;
    // 20 = size;

    Font f = new Font("TimesRoman",Font.BOLD,25);
    //change a jlabel font color
    label.setForeground(Color.red);
  //set the font to the Jlabel 
    label.setFont(f);
    label.setBounds(80,20,250,80);
    
    setLayout(null);
    add(label);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLocationRelativeTo(null);
    setSize(400,200);
    setVisible(true);
    }
    public static void main(String[] args){
        new Project();

        //to know some font style number
        System.out.println(Font.BOLD);
        System.out.println(Font.CENTER_BASELINE);
        System.out.println(Font.HANGING_BASELINE);
        System.out.println(Font.ITALIC);
        System.out.println(Font.LAYOUT_LEFT_TO_RIGHT);
        System.out.println(Font.LAYOUT_NO_LIMIT_CONTEXT);
        System.out.println(Font.LAYOUT_NO_START_CONTEXT);
        System.out.println(Font.LAYOUT_RIGHT_TO_LEFT);
        System.out.println(Font.PLAIN);
        System.out.println(Font.ROMAN_BASELINE);
        System.out.println(Font.TRUETYPE_FONT);
        System.out.println(Font.TYPE1_FONT);
    }
   }
/////////////////////////OUTPUT:

Change A Jlabel Font Color, Name, Style, And Size In Java
Change A Jlabel Font Color, Name, Style, And Size In Java
1
1
2
2
0
4
2
1
0
0
0
1

JAVA - How To Use HashMap In Java With Iterator

JAVA - How To Use HashMap In Java With Iterator

                                                                                                                                                            
using hashmap with iterator in java

In this java Collection tutorial we will see How To Use A HashMap With Iterator In Java NetBeans

Source Code:

package JavaDB_001;
import java.util.*;


public class Work {
    public static void main(String[] args){
        //create a HashMap
        //Key is String 
        //value is Integer
       HashMap<String,Integer> employer = new HashMap<String,Integer>();
       
       //filling the HashMap with put method
       employer.put("employer 1", 34);
       employer.put("employer 2", 43);
       employer.put("employer 3", 36);
       employer.put("employer 5", 55);
       employer.put("employer 6", 29);
       employer.put("employer 7", 27);
       employer.put("employer 8", 30);
       employer.put("employer 9", 51);
       
       //displaying only the key of the hashmap
       System.out.println("_______Key_______");
         Iterator<String> itName = employer.keySet().iterator();
            while(itName.hasNext())
             System.out.println(itName.next());
       
       //displaying only the value of the hashmap
       System.out.println("_______Value_______");
        Iterator<Integer> itAge = employer.values().iterator();
          while(itAge.hasNext())
            System.out.println(itAge.next());
       
      //displaying the key and the value of the hashmap
       System.out.println("_______Key_And_Value_______");  
         Iterator<String> itname = employer.keySet().iterator();
            while(itname.hasNext()){
                String s = itname.next();
              System.out.println(itname.next()+" -*- "+employer.get(s));
           }
    }
       
}
///////////////////////////OUTPUT:
_______Key_______
employer 9
employer 5
employer 6
employer 7
employer 8
employer 1
employer 2
employer 3
_______Value_______
51
55
29
27
30
34
43
36
_______Key_And_Value_______
employer 9 -*- 51
employer 5 -*- 55
employer 6 -*- 29
employer 7 -*- 27
employer 8 -*- 30
employer 1 -*- 34
employer 2 -*- 43
employer 3 -*- 36


See Also: How To Use HashMap In Java

JAVA - How To Use HashMap In Java

JAVA - How To Use HashMap In Java NetBeans

                                                                                                                                                            
using hashmap in java


In this java Collection Code we will see How To Use A HashMap In Java NetBeans
With Some Java HashMap Example of Methodes.
1: how to create a HashMap 
2: how to dispaly data from it
3: how to remove an element

4: how to clear all elements from it
and more........

Source Code:

package JavaDB_001;
import java.util.*;


public class Work {
    public static void main(String[] args){
        //create a HashMap
        //Key is String 
        //value is Integer
       HashMap<String,Integer> employer = new HashMap<String,Integer>();
       
       //filling the HashMap with put method
       employer.put("employer 1", 34);
       employer.put("employer 2", 43);
       employer.put("employer 3", 36);
       employer.put("employer 5", 55);
       employer.put("employer 6", 29);
       employer.put("employer 7", 27);
       employer.put("employer 8", 30);
       employer.put("employer 9", 51);
       
       //displaying only the key of the hashmap
       Set<String> EmployerName = employer.keySet();
       System.out.println("_______Key_______");
       for(String s: EmployerName)
           System.out.println(s);
       
       //displaying only the value of the hashmap
       Collection<Integer> Age = employer.values();
       System.out.println("_______Value_______");
       for(Integer i : Age)
           System.out.println(i);
       
      //displaying the key and the value of the hashmap
       System.out.println("_______Key_And_Value_______");
      Set<String> EmpName = employer.keySet();
       for(String s: EmpName)
           System.out.println("Key => ["+s +"] Value => ["+employer.get(s)+"]");
    }
       
}
///////////////////////////OUTPUT:
_______Key_______
employer 9
employer 5
employer 6
employer 7
employer 8
employer 1
employer 2
employer 3
_______Value_______
51
55
29
27
30
34
43
36
_______Key_And_Value_______
Key => [employer 9] Value => [51]
Key => [employer 5] Value => [55]
Key => [employer 6] Value => [29]
Key => [employer 7] Value => [27]
Key => [employer 8] Value => [30]
Key => [employer 1] Value => [34]
Key => [employer 2] Value => [43]
Key => [employer 3] Value => [36]


Another Source Code:

package javaapp;

import java.util.ArrayList;
import java.util.HashMap;


public class Work {
    public static void main(String[] args){
        HashMap<Integer, String> map = new HashMap<Integer, String>();
        map.put(10, "A");
        map.put(20, "B");
        map.put(30, "C");
        map.put(40, "D");
        map.put(50, "E");
        map.put(60, "F");
        
        printData(map);
        
        // delete an elemnt from the hashmap
        map.remove(60);
        printData(map);
        System.out.println("");
        System.out.println(map);
        
        map.replace(10, "Z");
        System.out.println(map);
        
        // see if the map contains a value
        boolean statVal = map.containsValue("Z");
        System.out.println(statVal);
        
        // see if the map contains a key
        boolean statKey = map.containsKey(40);
        System.out.println(statKey);
        
        // get value using his key
        String val = map.get(100);
        System.out.println(val);
        
        // check if the map is empty
        boolean isEmpty = map.isEmpty();
        System.out.println(isEmpty);

        // insert tvalues from hashmap to arraylist
        ArrayList<String> values = new ArrayList<String>(map.values());
        System.out.println("Values: "+values); 
        
        // create another hashmap
        HashMap<Integer, String> map2 = new HashMap<Integer, String>();
        map2.put(100,"MAP2-1");
        map2.put(200,"MAP2-2");
        map2.put(300,"MAP2-3");
        
        // insert a map in another map
        map.putAll(map2);
        printData(map);
        
       // clone the hashmap 
       Object obj = map.clone();
       System.out.println(obj);
       
       /*
       If the specified key is not associated with a value
       or the value is null associates it with the given value 
       in this example the key is 111 and value is null
       */
       map.put(111, null);
       map.putIfAbsent(111, "NewValue");
       System.out.println(map);
       
        // get the HashMap Size
        int mapSize = map.size();
        System.out.println(mapSize);
        
        // clear all elements from the hashmap
        map.clear();
        mapSize = map.size();
        System.out.println(mapSize);
        System.out.println("The HashMap Is Clear: "+map);
        System.out.println("The HashMap is Empty Now = "+map.isEmpty());
        
    }
    
    // cretate a function to print data from the hashmap 
    public static void printData(HashMap<Integer,String> list){
        for(Integer i : list.keySet()){
            System.out.println("Key: "+i+" Value: "+list.get(i));
        }
        System.out.println("-----------------------");
    }
}

//OUTPUT:

Key: 50 Value: E
Key: 20 Value: B
Key: 40 Value: D
Key: 10 Value: A
Key: 60 Value: F
Key: 30 Value: C
-----------------------
Key: 50 Value: E
Key: 20 Value: B
Key: 40 Value: D
Key: 10 Value: A
Key: 30 Value: C
-----------------------

{50=E, 20=B, 40=D, 10=A, 30=C}
{50=E, 20=B, 40=D, 10=Z, 30=C}
true
true
null
false
Values: [E, B, D, Z, C]
Key: 50 Value: E
Key: 20 Value: B
Key: 100 Value: MAP2-1
Key: 40 Value: D
Key: 200 Value: MAP2-2
Key: 10 Value: Z
Key: 300 Value: MAP2-3
Key: 30 Value: C
-----------------------
{50=E, 20=B, 100=MAP2-1, 40=D, 200=MAP2-2, 10=Z, 300=MAP2-3, 30=C}
{50=E, 20=B, 100=MAP2-1, 40=D, 200=MAP2-2, 10=Z, 300=MAP2-3, 30=C, 111=NewValue}
9
0
The HashMap Is Clear: {}

The HashMap is Empty Now = true



See Also : HashMap In Java With Iterator
JAVA - How To Remove All Objects In An Arraylist That Exist In Another Arraylist

JAVA - How To Remove All Objects In An Arraylist That Exist In Another Arraylist

JAVA - How To Remove All Objects In An Arraylist If Exist In Another Arraylist

_________________________________________________________________________

In this java Collection Tutorial we will see How To Delete All Elements from ArrayList
If Elements Exist In Another ArrayList In Java NetBeans .

Source Code:

package javadb_001;
import java.util.ArrayList;
import java.util.List;
public class Learn {
    
public static void main(String[] args){
    String[] str1 = {"C#","JAVA","Android","ASP.NET","J2EE","PHP"};
 List<String> list = new ArrayList<String>(); 
 //fill the list
 for(String s1 : str1){
     list.add(s1);
     }
     String[] str2 = {"C","C++","JAVA","DELPHY","HTML","CSS","C#"};
     List<String> list2 = new ArrayList<String>();
     
     //fill the list2
     for(String s2 : str2){
         list2.add(s2);
     }
     
    //display the list2 Objects before removing existing objects
     for(String s : list2){
         System.out.println(s);
     }
      System.out.println("____________________");
      
     for(int i = 0; i < list.size(); i++){
         for(int j = 0; j < list2.size(); j++)
         {
             if(list.get(i).equals(list2.get(j))){
                 list2.remove(j);
             }
         }
     }
     
     //display the list2 Objects after removing existing objects
     for(String s : list2){
         System.out.println(s);
     }
}
}
JAVA - How To Use setActionCommand In Java Swing

JAVA - How To Use setActionCommand In Java Swing

Using setActionCommand In Java NetBeans

_______________________________________________________________________________

In this java Collection Tutorial we will see How To Use setActionCommand With Button
 In Java NetBeans .

Source Code:


package JavaDB_001;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;



public class Project extends JFrame {
    JButton btnOK,btnYES,btnNO;
    
public Project(){
    btnOK = new JButton("OK");
    btnYES = new JButton("YES");
    btnNO = new JButton("NO");
    
    btnOK.setActionCommand("OK");
    btnYES.setActionCommand("YES");
    btnNO.setActionCommand("NO");
    
    btnOK.addActionListener(new BtnAction());
    btnYES.addActionListener(new BtnAction());
    btnNO.addActionListener(new BtnAction());
    
    btnOK.setBounds(20, 20, 100, 20);
    btnYES.setBounds(140, 20, 100, 20);
    btnNO.setBounds(260, 20, 100, 20);
    
    add(btnOK);
    add(btnYES);
    add(btnNO);
    
    setLayout(null);
    setSize(400, 120);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    getContentPane().setBackground(Color.decode("#bdb76b"));
    setVisible(true);
}

public class BtnAction implements ActionListener{
    public void actionPerformed(ActionEvent e){
        String s = e.getActionCommand();
        if(s.equals("OK")){
          JOptionPane.showMessageDialog(null, "CLICK OK");
        }
        if(s.equals("YES")){
            JOptionPane.showMessageDialog(null, "CLICK YES");
        }
        if(s.equals("NO")){
            JOptionPane.showMessageDialog(null, "CLICK NO");
        }
    }
    }
public static void main(String[] args){
  new Project();
}
}

JAVA - How To Use JCheckBox In Java Swing

How To Use JCheckBox In Java NetBeans

_______________________________________________________________________________

package JavaDB_001;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;


public class Project extends JFrame {

    //declare JCheckBox Object
    JCheckBox ch;

public Project(){
     ch = new JCheckBox("CheckBox");
    //add Action to ch
    ch.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            //if JCheckBox is selected
          if(ch.isSelected()){
              JOptionPane.showMessageDialog(null, "Checked");
          }
         // if JCheckBox is not selected
          else
              JOptionPane.showMessageDialog(null, "UnChecked");
        }
    });
    ch.setBounds(160, 30, 90, 20);
    add(ch);
    setLayout(null);
    setSize(400, 120);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    getContentPane().setBackground(Color.decode("#bdb76b"));
    setVisible(true);
}
 
public static void main(String[] args) throws IOException{
  new Project();
}
}

JCheckBox In Java
JCheckBox In JFrame

How To Make Money With Your Source Code

How To Make Money With Your Source Code

________________________________________________________________________________

if you ask your self how i can sell my source code plugin, script you are in the right place
first let me introduce you this website: codecanyon
CodeCanyon is part of Envato Market. At CodeCanyon, you can purchase and sell scripts and components for a variety of languages and frameworks, currently including JavaScript, PHP, ASP.NET.
also you can Browse the largest script and code marketplace on the web. Find WordPress plugins, jQuery plugins, Javascript, CSS and more. Save time, Buy code.
at this time is ranked in alexa:


Now Create An Envato Account Here
Create An Envato Account

fill your information
codecanyon account
you should confirm your registration

Now You Can Sell Your Android IOS Codes, Your WordPress Plugin, NavBar, and more

All you Have To do Now Is Start Making Awesome Source Code And Start Selling => CodeCanyon

You can also be an affiliate and sell codes from other person 
JAVA - Some Java String Functions

JAVA - Some Java String Functions

JAVA - Some Java String Functions

____________________________________________________________________

In this java Tutorial we will see Some String Methode In Java NetBeans .

Source Code:

package JavaDB_001;

public class Project {

public static void main(String[] args){
 String str = "1bestcsharp.blogspot.com";

 System.out.println("length: "+str.length());
 System.out.println("indexOf: "+str.indexOf("."));
 System.out.println("lastIndexOf: "+str.lastIndexOf("."));
 System.out.println("startsWith: "+str.startsWith("1"));
 System.out.println("endsWith: "+str.endsWith("m"));
 System.out.println("compareTo: "+str.compareTo("1bestcsharp"));
 System.out.println("compareTo: "+str.compareTo("1bestcsharp.blogspot.com"));
 System.out.println("compareTo: "+str.compareTo("www.1bestcsharp.blogspot.com"));
 System.out.println("equals"+str.equals(new String("1bestcsharp")));
 System.out.println("toUpperCase: "+str.toUpperCase());
 System.out.println("toLowerCase: "+str.toLowerCase());
 System.out.println("trim: "+new String("        1bestcsharp.blogspot.com").trim());
 System.out.println("replace: "+str.replace("com", "net"));
}

}
/////// OUTPUT:
length: 24
indexOf: 11
lastIndexOf: 20
startsWith: true
endsWith: true
compareTo: 13
compareTo: 0
compareTo: -70
equalsfalse
toUpperCase: 1BESTCSHARP.BLOGSPOT.COM
toLowerCase: 1bestcsharp.blogspot.com
trim: 1bestcsharp.blogspot.com
replace: 1bestcsharp.blogspot.net
JAVA - How To Create A Multiplication Tables In Java Netbeans

JAVA - How To Create A Multiplication Tables In Java Netbeans

How To Make A Multiplication Tables In Java

________________________________________________________________________________

package JavaDB_001;

public class Project {

public static void main(String[] args){
    for(int i = 1;i < 10;i++){
        for(int j = 1; j <= 10; j++){
            System.out.println(i +" X "+j+" = "+i*j);
        }
        System.out.println("-----------------");
    }
}

}
  
/////////// OUTPUT:      
 run:
1 X 1 = 1
1 X 2 = 2
1 X 3 = 3
1 X 4 = 4
1 X 5 = 5
1 X 6 = 6
1 X 7 = 7
1 X 8 = 8
1 X 9 = 9
1 X 10 = 10
-----------------
2 X 1 = 2
2 X 2 = 4
2 X 3 = 6
2 X 4 = 8
2 X 5 = 10
2 X 6 = 12
2 X 7 = 14
2 X 8 = 16
2 X 9 = 18
2 X 10 = 20
-----------------
3 X 1 = 3
3 X 2 = 6
3 X 3 = 9
3 X 4 = 12
3 X 5 = 15
3 X 6 = 18
3 X 7 = 21
3 X 8 = 24
3 X 9 = 27
3 X 10 = 30
-----------------
4 X 1 = 4
4 X 2 = 8
4 X 3 = 12
4 X 4 = 16
4 X 5 = 20
4 X 6 = 24
4 X 7 = 28
4 X 8 = 32
4 X 9 = 36
4 X 10 = 40
-----------------
5 X 1 = 5
5 X 2 = 10
5 X 3 = 15
5 X 4 = 20
5 X 5 = 25
5 X 6 = 30
5 X 7 = 35
5 X 8 = 40
5 X 9 = 45
5 X 10 = 50
-----------------
6 X 1 = 6
6 X 2 = 12
6 X 3 = 18
6 X 4 = 24
6 X 5 = 30
6 X 6 = 36
6 X 7 = 42
6 X 8 = 48
6 X 9 = 54
6 X 10 = 60
-----------------
7 X 1 = 7
7 X 2 = 14
7 X 3 = 21
7 X 4 = 28
7 X 5 = 35
7 X 6 = 42
7 X 7 = 49
7 X 8 = 56
7 X 9 = 63
7 X 10 = 70
-----------------
8 X 1 = 8
8 X 2 = 16
8 X 3 = 24
8 X 4 = 32
8 X 5 = 40
8 X 6 = 48
8 X 7 = 56
8 X 8 = 64
8 X 9 = 72
8 X 10 = 80
-----------------
9 X 1 = 9
9 X 2 = 18
9 X 3 = 27
9 X 4 = 36
9 X 5 = 45
9 X 6 = 54
9 X 7 = 63
9 X 8 = 72
9 X 9 = 81
9 X 10 = 90
-----------------
BUILD SUCCESSFUL (total time: 0 seconds)

JAVA - How To Use JOptionPane.showInputDialog In Java NetBeans

JAVA - How To Use JOptionPane.showInputDialog In Java NetBeans

How To Use JOptionPane.showInputDialog In Java

__________________________________________________________________

package JavaDB_001;
import javax.swing.*;

public class Project {

public static void main(String[] args){
    
 String num1,num2;
 int sum;
//get the first number fom showInputDialog
 num1 = JOptionPane.showInputDialog("Enter The First Number");
//get the Seconde number fom showInputDialog
 num2 = JOptionPane.showInputDialog("Enter The Seconde Number");

//verify the inout is not null
 if(num1 == null){
     num1 = "0";
 }
  if(num2 == null){
     num2 = "0";
 }

     sum = Integer.parseInt(num1) + Integer.parseInt(num2);

 JOptionPane.showMessageDialog(null, "The Sum Of this Two Number Is: "+sum);
 System.exit(0);
}
}

C# - How To Drag And Drop Image From Desktop To PictureBox In C#

How To Drag And Drop Image From Desktop To PictureBox In C#

____________________________________________________________

In This C# Code We Will See How To  You Can Drag Image From Your DesKtop And Drop It In The PictureBox In CSharp Programming Language .

Project Source Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace WindowsFormsApplication1
{
    public partial class Project : Form
    {
        public Project()
        {
            InitializeComponent();
            pictureBox1.AllowDrop = true;
        }
        private void pictureBox1_DragEnter(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.Copy;
        }
 
        private void pictureBox1_DragDrop(object sender, DragEventArgs e)
        {
            foreach(string pic in ((string[])e.Data.GetData(DataFormats.FileDrop)))
            {
                Image img = Image.FromFile(pic);
                pictureBox1.Image = img;
            }
        }
    }
}


Drag And Drop Image From Desktop To PictureBox In C#
Image From Desktop To PictureBox In C#

Gravity Forms Styler - How To Style Your Gravity Forms

Gravity Forms Styler - How To Style Your Gravity Forms

Create And Apply Styles To Your Gravity Forms Using Gravity Forms Styler

_____________________________________________________________
plugin for gravity forms

       Gravity Forms Styler

     
gravity form
Gravity Forms Plugins

create and apply styles to your gravity forms standard fields, advanced fields, titles and descriptions, buttons, form borders, form labels, form backgrounds and you can even customize the form confirmation and error messages.
You can change each elements background color, border size, border color, border radius, font size, font type, font color and anything else that is possible using css.
We made it really easy for you to customize everything by simply moving the slider to change values, use color picker to choose any color you like and simply choose options from the drop down list.
The best part is you can create unlimited styles and apply to any gravity forms simply by changing the form id, so you can have one style for all the forms or you can have different style for each form.
On top of that we gave you an option to add custom css code for each form style you create.
The possibilities are endless and you don’t have to set gravity forms css output to NO and it will not change your existing form styles, because each of your form styled with Gravity Forms Styler will have independent css code generated dynamically, how cool is that? so what are you waiting for ? :-)
JAVA - How To Set A Timer In Java

JAVA - How To Set A Timer In Java

JAVA - How To Set A Timer In Java NetBeans

In this java Tutorial we will see How To Make A Timer In Java NetBeans .



Project Source Code:

package JavaDB_001;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.Timer;


public class Test extends JFrame {
    Timer tm1,tm2;
    JButton up,down;
    JPanel panel;
    public Test(){
        super("Timer");
        up = new JButton("up");
        down = new JButton("down");
        up.setBounds(150, 400, 100, 20);
        down.setBounds(260, 400, 100, 20);
        panel = new JPanel();
        panel.setBackground(Color.decode("#3a5795"));
        panel.setBounds(0, 0, 500, 0);
        
        tm1 = new Timer(50,new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
            
                if(panel.getHeight() != 350){
                    up.setEnabled(false);
                    down.setEnabled(false);
                    panel.setBounds(0, 0, 500, panel.getHeight()+5);
                    if(panel.getHeight() == 350){
                        tm1.stop();
                    up.setEnabled(true);
                    down.setEnabled(true); 
                    }
                }
            }
        });
        
        tm2 = new Timer(50, new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                
                if(panel.getHeight() !=0){
                         up.setEnabled(false);
                    down.setEnabled(false);
                        
                    panel.setBounds(0, 0, 500, panel.getHeight()-5);
                    if(panel.getHeight() == 0){
                        tm2.stop();
                       up.setEnabled(true);
                    down.setEnabled(true);
                    }
                }
            }
        });
        
        //Timer2 Start
        up.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                tm2.start();
            }
        });
        
         //Timer1 Start
        down.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                tm1.start();
            }
        });
        
        
        
        add(up);
        add(down);
        add(panel);
        setLayout(null);
        setSize(500, 500);
        getContentPane().setBackground(Color.decode("#bdb76b"));
        setLocationRelativeTo(null);
        setVisible(true);
    }
  
 
 public static void main(String[] args){
 
         new Test();
    }
}
Also See :
Slideshow In Java Swing