Results 1 to 2 of 2
Thread: Convert java code to midlet code
- 08-09-2009, 12:52 PM #1
Convert java code to midlet code
hi guys can you help me convert my java application code entitled "flames" to java midlet source code???
heres my java application code I need to convert
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class chumma extends JFrame implements ActionListener
{
public static JPanel jp1, jp;
public static JButton jb;
public static JTextField name_1;
public static JTextField name_2;
public static JLabel jl;
public static JLabel Output,just;
public static Font f,f1;
public static StringBuffer name1, name2;
public chumma()
{
this.setVisible(true);
this.setSize(300, 200);
this.setLocation(400,300);
this.setTitle("The Simple Love Calculator");
f = new Font("serif", 2, 14);
f1=new Font("sansserif",Font.BOLD,16);
addWindowListener(new MyWindowAdapter(this));
jp = new JPanel(new GridLayout(6, 2));
jp1 = new JPanel(new GridLayout(1, 1));
jb = new JButton("Check It");
jb.setFont(f);
jl = new JLabel(" FLAMES ");
just=new JLabel(" The Relatioship is ");
just.setVisible(false);
name_1 = new JTextField();
name_1.setFont(f);
name_2 = new JTextField();
name_2.setFont(f);
Output = new JLabel(" ");
Output.setFont(f1);
jp.add(jl);
jp.add(new JLabel("Funny Reationship Finder"));
jp.add((new JLabel("Enter the NAme1")));
jp.add(name_1);
jp.add((new JLabel("Enter the NAme2")));
jp.add(name_2);
jp.add(new JLabel(" "));
jp.add(jb);
jp.add(just);
jp.add(Output);
// jp.add();
add(jp);
jb.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
FLAMES();
}
public void FLAMES()
{
name1 = new StringBuffer(name_1.getText());
name2 = new StringBuffer(name_2.getText());
for (int i = 0; i < name1.length(); i++)
{
char ch = name1.charAt(i);
for (int j = 0; j < name2.length(); j++)
{
if (ch == name2.charAt(j))
{
name1.deleteCharAt(i);
name2.deleteCharAt(j);
i = -1;
break;
}
}
}
int totallength = name1.length() + name2.length();
StringBuffer str = new StringBuffer("FLAMES");
int cancel_value = 1;
for (int i = 0; i < 5; i++)
{
cancel_value = totallength % str.length();
if (cancel_value == 0)
{
cancel_value = str.length();
}
cancel_value--;
if (cancel_value == 0)
{
str = new StringBuffer(str.substring(1));
} else if (cancel_value == (str.length() - 1))
{
str = new StringBuffer(str.substring(0, str.length() - 1));
} else
str = new StringBuffer(str.substring(cancel_value + 1)
+ str.substring(0, cancel_value));
}
just.setVisible(true);
Output.setText(relation(str.charAt(0)));
}
public static void main(String a[])
{
chumma aa=new chumma();
}
public String relation(char ch)
{
String str1="";
switch(ch)
{
case 'F':
str1= "FRIENDS";
break;
case 'L':
str1="LOVERS";
break;
case 'A':
str1= "AFFECTION";
break;
case 'M':
str1="MARRIAGE";
break;
case 'E':
str1="ENEMY";
break;
case 'S':
str1="SISTER";
break;
}
return str1;
}
}
class MyWindowAdapter extends WindowAdapter
{
chumma sampleFrame;
public MyWindowAdapter(chumma sampleFrame)
{
this.sampleFrame = sampleFrame;
}
public void windowClosing(WindowEvent we)
{
sampleFrame.setVisible(false);
System.exit(0);
}
}
thank you guys!!!
-
Similar Threads
-
Convert THE APPLET CODE TO SWING USING JPANEL
By jammyjamsticy in forum AWT / SwingReplies: 2Last Post: 12-22-2011, 09:16 AM -
Convert bar code to number
By samatha_kudi in forum Advanced JavaReplies: 1Last Post: 07-17-2009, 02:56 PM -
I need help fixing my code.. or non code?
By MrHuggykins in forum New To JavaReplies: 1Last Post: 03-19-2008, 10:12 PM -
how to convert source code to xml
By valery in forum XMLReplies: 2Last Post: 08-06-2007, 08:29 PM -
Generating Code Automatically Using Custom code Template In Eclipse
By JavaForums in forum EclipseReplies: 1Last Post: 04-26-2007, 03:52 PM
Bookmarks