Thursday, October 30, 2014

Java Icon Pro



Simple Java Vector

import java.util.Iterator;
import java.util.Vector;
public class SimpleVectorExample
{
public static void main(String[] args)
{
Vector v = new Vector();
v.add("1");
v.add("2");
v.add("3");
System.out.println("Getting elements of Vector");
System.out.println(v.get(0));
System.out.println(v.get(1));
System.out.println(v.get(2));
   }
}

Sort elements of Java Vector

import java.util.Vector;
import java.util.Collections;
public class SortJavaVectorExample
{
public static void main(String[] args)
{
Vector v = new Vector();
v.add("1");
v.add("3");
v.add("5");
v.add("2");
v.add("4");
Collections.sort(v);
System.out.println("Vector elements after sorting in ascending order : ");
for(int i=0; i
System.out.println(v.get(i));
  }
}

Align Icon in JLabel

import javax.swing.ImageIcon;
import javax.swing.JApplet;
import javax.swing.JLabel;
public class JLabelIconAlignmentExample extends JApplet
{
public void init()
{
ImageIcon icon = new ImageIcon("images/copy.gif");
JLabel imageLabel = new JLabel("Copy",icon, JLabel.CENTER); add(imageLabel);
   }
}
Check Whether JLabel is Visible or Enabled

import javax.swing.JApplet;
import javax.swing.JLabel;
public class JLabelCheckVisibleOrEnabledExample extends JApplet
{      
public void init()
{
JLabel label1 = new JLabel("This is JLabel Example."); add(label1); boolean visible = label1.isVisible();
boolean enabled = label1.isEnabled();
    }
}

Create JLabel with Image Icon

import javax.swing.ImageIcon;
import javax.swing.JApplet;
import javax.swing.JLabel;
public class JLabelWithIconExample extends JApplet
{      
public void init()
{
ImageIcon icon = new ImageIcon("images/copy.gif"); JLabel copyLabel = new JLabel(icon);
add(copyLabel);          
    }
}

No comments:

Post a Comment