4 1348 -
ts = textcheckarray.get(a);
-
if (ts.equals("selected")) //check box
-
-
[ ... ]
-
-
ds = disposecheckarray.get(f);
-
if (ds.equals("selected")); //checkbox
-
-
[ ... ]
-
These tests seem to succeed for every 'ts' and 'ds'. Since I can't see the type
of 'textcheckarray' and 'disposecheckarray' I can't tell anything more.
kind regards,
Jos
- textcheckarray = new ArrayList<String>();
-
disposecheckarray = new ArrayList<String>();
this?
i know this is annoying, but for the sake of giving you all the elements you need to solve my problem and the fact that i am confused, i will show you all my code. Thanks a lot. I really appreciate your help! - import javax.swing.*;
-
import java.awt.*;
-
import java.awt.event.*;
-
import java.util.ArrayList;
-
import java.io.*;
-
import javax.swing.event.*;
-
public class ClassWriter implements ActionListener
-
{
-
ArrayList<String> importstatements;
-
ArrayList<String> variables;
-
ArrayList<String> const_statements;
-
ArrayList<String> listener;
-
ArrayList<String> button;
-
ArrayList<String> jlabel;
-
ArrayList<String> dispose;
-
ArrayList<String> addtext;
-
ArrayList<String> textcheckarray;
-
ArrayList<String> disposecheckarray;
-
JPanel p1;
-
-
JButton b2, b3,bsubmit,jsubmit,addbutton,addjlabel;
-
JFrame f1;
-
JTextField t1,inbutton,inlabel;
-
JLabel l1;
-
Container c1;
-
String classname, constructor,btext,jtext,jXX,jYY,select,ts,ds;
-
boolean runb;
-
int i = 0;
-
int h = 0;
-
int a = 0;
-
int f = 0;
-
JRadioButton disposecheck,textcheck;
-
public ClassWriter(String cl,String jX,String jY,boolean runa)
-
{
-
disposecheck = new JRadioButton("Dispose GUI?");
-
disposecheck.setMnemonic(KeyEvent.VK_C);
-
disposecheck.setSelected(false);
-
-
runb=runa;
-
-
textcheck = new JRadioButton("Change Textbox?");
-
textcheck.setMnemonic(KeyEvent.VK_C);
-
textcheck.setSelected(false);
-
jXX = jX;
-
jYY = jY;
-
// ItemListener itemlistener = new ItemListener();
-
dispose = new ArrayList<String>();
-
addtext = new ArrayList<String>();
-
importstatements = new ArrayList<String>();
-
variables = new ArrayList<String>();
-
const_statements = new ArrayList<String>();
-
listener = new ArrayList<String>();
-
button = new ArrayList<String>();
-
jlabel = new ArrayList<String>();
-
textcheckarray = new ArrayList<String>();
-
disposecheckarray = new ArrayList<String>();
-
classname = "public class "+cl;
-
constructor = "public "+ cl +"() \n {";
-
-
inbutton = new JTextField(20);
-
inlabel = new JTextField(20);
-
addbutton = new JButton("Add Button");
-
addbutton.addActionListener(this);
-
addjlabel = new JButton("Add JLabel");
-
addjlabel.addActionListener(this);
-
bsubmit = new JButton("K");
-
bsubmit.addActionListener(this);
-
jsubmit = new JButton("K");
-
jsubmit.addActionListener(this);
-
-
f1 = new JFrame();
-
f1.setSize(300,150);
-
c1 = f1.getContentPane();
-
p1 = new JPanel();
-
l1 = new JLabel("Text in Button");
-
t1 = new JTextField(20);
-
-
b2 = new JButton("Input Data");
-
b2.addActionListener(this);
-
b3 = new JButton("Write Program");
-
b3.addActionListener(this);
-
-
// textcheck.addItemListener(itemlistener);
-
// disposecheck.addItemListener(itemlistener);
-
p1.add(addbutton);
-
p1.add(addjlabel);
-
p1.add(b2);
-
c1.add(p1);
-
f1.show();
-
-
}
-
-
-
public void actionPerformed(ActionEvent event)
-
{
-
-
-
if (event.getSource() == addbutton)
-
{
-
p1.remove(addjlabel);
-
p1.remove(addbutton);
-
p1.remove(b2);
-
p1.add(inbutton);
-
p1.add(disposecheck);
-
p1.add(textcheck);
-
p1.add(bsubmit);
-
f1.dispose();
-
f1.show();
-
}
-
if (event.getSource() == bsubmit)
-
{
-
-
-
btext = inbutton.getText();
-
button.add(i,btext);
-
inbutton.setText(null);
-
-
if (textcheck.isSelected()){
-
-
select="selected";
-
-
}
-
else{
-
select="unselected";
-
}
-
textcheckarray.add(a,select);
-
-
if (disposecheck.isSelected()){
-
-
select="selected";
-
-
}
-
else{
-
select="unselected";
-
}
-
disposecheckarray.add(f,select);
-
-
-
p1.remove(disposecheck);
-
p1.remove(textcheck);
-
p1.remove(jsubmit);
-
p1.remove(inlabel);
-
p1.remove(bsubmit);
-
p1.remove(inbutton);
-
p1.add(addbutton);
-
-
p1.add(addjlabel);
-
p1.add(b2);
-
i++;
-
f1.dispose();
-
f1.show();
-
-
}
-
if (event.getSource() == addjlabel)
-
{
-
-
p1.remove(addbutton);
-
p1.remove(addjlabel);
-
p1.remove(b2);
-
p1.add(inlabel);
-
p1.add(jsubmit);
-
f1.dispose();
-
f1.show();
-
}
-
if (event.getSource() == jsubmit)
-
{
-
jtext = inlabel.getText();
-
jlabel.add(h,jtext);
-
inlabel.setText(null);
-
inbutton.setText(null);
-
p1.remove(jsubmit);
-
p1.remove(inlabel);
-
p1.remove(bsubmit);
-
p1.remove(inbutton);
-
p1.add(addbutton);
-
p1.add(addjlabel);
-
p1.add(b2);
-
-
-
h++;
-
f1.dispose();
-
f1.show();
-
}
-
-
-
if (event.getSource() == b2)
-
{
-
importstatements.add("import javax.swing.*;");
-
importstatements.add("import java.awt.*;");
-
importstatements.add("import java.awt.event.*;");
-
-
-
classname = classname +" implements ActionListener";
-
-
variables.add("JFrame f1;");
-
variables.add("Container c1;");
-
variables.add("JPanel p1;");
-
for(int i = 0; i< button.size(); i++){
-
variables.add("JButton b"+i+";");
-
}
-
for(int h = 0; h< jlabel.size(); h++){
-
variables.add("JLabel L"+h+";");
-
}
-
-
const_statements.add("f1 = new JFrame();");
-
const_statements.add("f1.setSize("+jXX+","+jYY+")");
-
const_statements.add("c1 = f1.getContentPane(); ");
-
const_statements.add("p1 = new JPanel();");
-
for(int i = 0; i< button.size(); i++){
-
const_statements.add("b"+i+" = new JButton(\" "+ button.get(i) +" \")");
-
}
-
for(int h = 0; h< jlabel.size(); h++){
-
const_statements.add("L"+h+" = new JLabel(\" "+ jlabel.get(h) +" \")");
-
}
-
for(int i = 0; i< button.size(); i++){
-
const_statements.add("b"+i+".addActionListener(this);");
-
}
-
-
for(int i = 0; i< button.size(); i++){
-
const_statements.add("p1.add(b"+i+");");
-
}
-
for(int h = 0; h< jlabel.size(); h++){
-
const_statements.add("p1.add(L"+h+");");
-
}
-
const_statements.add("c1.add(p1);");
-
const_statements.add("f1.show();");
-
listener.add("public void actionPerformed(ActionEvent event); \n {");
-
for(int i = 0; i< button.size(); i++){
-
listener.add("if (event.getSource() == b"+i+")");
-
listener.add("{");
-
//action events text:a dispose:f
-
for(int a = 0; a< textcheckarray.size(); a++){
-
ts = textcheckarray.get(a);
-
if (ts.equals("selected"))
-
{
-
-
listener.add("textbox.setText(changetext)");
-
-
-
-
}
-
-
}
-
for(int f = 0; f< disposecheckarray.size(); f++){
-
ds = disposecheckarray.get(f);
-
if (ds.equals("selected"))
-
{
-
listener.add("f1.dispose()");
-
-
-
}
-
-
-
-
}
-
listener.add("");
-
listener.add("}");
-
}
-
-
-
p1.remove(l1);
-
p1.remove(t1);
-
p1.remove(b2);
-
p1.remove(addbutton);
-
p1.remove(addjlabel);
-
p1.add(b3);
-
f1.dispose();
-
f1.show();
-
-
}
-
if (event.getSource() == b3)
-
{
-
if (runb == true){
-
try{
-
FileWriter outfile = new FileWriter("runprogram.txt");
-
PrintWriter out = new PrintWriter(outfile);
-
-
out.println("public class RunProgram");
-
out.println("{");
-
out.println("public static void main(String[] args)");
-
out.println("{");
-
out.println("");
-
out.println("}");
-
out.println("}");
-
out.close();
-
}
-
catch (IOException e){}
-
}
-
-
-
-
-
-
-
-
-
try{
-
FileWriter outfile = new FileWriter("program.txt");
-
PrintWriter out = new PrintWriter(outfile);
-
-
for(int i = 0; i< importstatements.size(); i++)
-
out.println(importstatements.get(i));
-
-
out.println(classname);
-
out.println("{");
-
for(int i = 0; i< variables.size(); i++)
-
out.println(variables.get(i));
-
-
out.println(constructor);
-
for(int i = 0; i< const_statements.size(); i++)
-
out.println(const_statements.get(i));
-
out.println("}");
-
for(int i = 0; i< listener.size(); i++)
-
out.println(listener.get(i));
-
out.println("}");
-
out.println("}");
-
-
out.close();
-
p1.add(l1);
-
if (runb == true)
-
{
-
l1.setText("Your Program has been written...with run class");
-
}
-
else{
-
l1.setText("Your Program has been written...without run class");
-
}
-
p1.remove(b3);
-
f1.dispose();
-
f1.show();
-
}
-
catch (IOException e){}
-
-
}
-
-
-
-
}
-
}
Please don't do that; you just posted a whole lot of wallpaper for us to just find
out what you couldn't find yourself? Please try to narrow it down as much as
possible. Hint: System.out.println() sprinkled in your code at tactical places can
be of much help; give it a try.
kind regards,
Jos
Sign in to post your reply or Sign up for a free account.
Similar topics
by: pythonUser_07 |
last post by:
Is this the correct place to post a jython question?
I posted the following in the jython group, but I figured I'd post here
too:
_________________________________________
I am assuming that...
|
by: ºa¤Ö |
last post by:
I find a interesting question, and I cannot solve it
@.@
If i want to insert unicode data, I need using recordset.addnew instead of
using "insert into table" query or "stored procedure"
All...
|
by: Dylan Phillips |
last post by:
A strang error is occurring when I run the following code:
SqlConnection c = new SqlConnection();
c.ConnectionString = "Initial Catalog=Northwind;user
id=sa;password=kat1ie;Data Source=server";...
|
by: git_cs |
last post by:
Hey, guys and gals
Somedays ago, I had asked for the DES algorithm in C language.
Although I have written the algorthim in C myself, I am facing a
peculiar problem, which I hope some of u guys and...
|
by: Jax |
last post by:
I have this code, behold:
string message = "Are you sure? You will lose this
customer forever. (Well you'll have re-create from
scratch)";
string caption = "Delete";
MessageBoxButtons buttons...
|
by: Dino M. Buljubasic |
last post by:
I have two applications App1 and App2.
App1 is just checking for new version of App2.
If it finds newer version of App2 it will download App1 AND App2. (both of
them). That is what I am...
|
by: Claude Yih |
last post by:
Hi, everyone. I noticed an interesting thing about fread() this
afternoon. Well, I can't see why so I post this message in the hope of
getting some explanation. Please help me.
I wrote the...
|
by: v4vijayakumar |
last post by:
Happened to see my old (last millennium) c code. Almost forgot that I
wrote it .
It is interesting. :-)
int sqrt(int no)
{
int t;
no = t * t;
return t;
}
|
by: Will Honea |
last post by:
I've hit an interesting trap trying to migrate data off an OS/2 server
running version 7.2 (fp14) over to 8.2 on Linux. Seems that one table has
a column defined in the DDL as "BIGINT NOT NULL...
|
by: jacob navia |
last post by:
Buffer overflows are a fact of life, and, more specifically, a fact of
C.
All is not lost however. In the book
"Value Range Analysis of C programs" Axel Simon tries to establish a...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |