Here is a set of class that displays a graphic user interface.
These are multiple classes so you should obtain them all first at
http://www.mediafire.com/download.php?23vhz263zr696qi
Actor.java contains the main method
---------------------------------------------------------
import javax.swing.JOptionPane;
public class Actor {
static void newOpt(){
String[] Choices={"BorderLayout","Box Layout","Figures"};
int i=JOptionPane.showOptionDialog(null, "Pick your Ui", "You choose", JOptionPane.DEFAULT_OPTION , JOptionPane.CLOSED_OPTION, null, Choices, "");
System.out.println(""+i);
LaunchFrame LF=new LaunchFrame();
switch(i){
case 0: LF.BrdrL(Choices);break;
case 1: LF.BoxL();break;
case 2: LF.Figures();break;
}
}
public static void main(String[] args) {
String[] elems={"JFrame","JLabel","JTextField","JComboBox","JButton","Confirm Dialog","Input Dialog","Message dialog",
"Password","TextArea","Editor Pane","Menu","Tab","CheckBox & list"};
LaunchFrame LF=new LaunchFrame();
int i=JOptionPane.showOptionDialog(null, "Pick your Ui", "You choose", JOptionPane.DEFAULT_OPTION , JOptionPane.CLOSED_OPTION, null, elems, "");
System.out.println(""+i);
switch(i){
case 0: LF.Act1(); break;
case 1: LF.FrameLabel();break;
case 2: LF.TxtBx();break;
case 3: LF.Options();break;
case 4: LF.Buttons();break;
case 5: System.out.println("Returned "+JOptionPane.showConfirmDialog(null, elems[5])); break;
case 6: System.out.println("Returned "+JOptionPane.showInputDialog("Type something"));break;
case 7: JOptionPane.showMessageDialog(null, elems[7]);break;//returns void
case 8: LF.Password();break;
case 9: LF.TxtArea(); break;
case 10: LF.Ep();break;
case 11: LF.MenuB(); break;
case 12: LF.showTab(); break;
case 13: LF.Listing(elems);break;
default: newOpt();break;
}
}
}
---------------------------------------------------------
The launch frame has methods that displays the GUI component to be displayed
________________________
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
________________________
It has the following methods
Monday, February 28, 2011
Thursday, February 3, 2011
Immigration from C to java[to be finished]
In C | In java |
---|---|
main(){ /*Code here*/ } | public static void main(String[] args) { /*Code here*/ } |
int num; printf("Enter a number: "); scanf("%d",&num); | Scanner scn=new Scanner(System.in); System.out.print("Enter a number to a variable: "); int num=scn.nextInt(); //end of solution 1 //Start of solution 2 int num; Scanner scn=new Scanner(System.in); System.out.print("Enter a number to a variable: "); num=scn.nextInt(); |
int x=0; printf("x+1= %d\n",x+1); | int x=0; System.out.println("x+1= "+(x+1)); |
char word[10]; printf("Enter a word: "); scanf("%s",word); | String word; System.out.print("Enter a word: "); word=scn.next(); //scn is a defined scanner object from the code above |
int ArrInt[5]; | int[] ArrInt=new int[5] |
Subscribe to:
Posts (Atom)