it’s my first post in here, but you have been helping me indirectly in many ways. But this kind of thing, like the title says, I still can’t figure out.
I think I don’t need to say I’m a noob in such a thing, and any kind of help would be great =] .. By the way, I’m using netbeans (Java).
So, here’s my problem:
- I have a jFrame1 with 3 textFields.
- Also, in this jFrame1, I have a button that should do the following:
+Look through the whole 3 textFields and only select the words that are between “” and/or between **. Other words should not be used. Also, this button should redirect me to jFrame2. - In the other jFrame2, the ‘special’ words found in the 3 textFields (jFram1), should be put in there, inside a jTextArea1.
And that’s where I’m lost. Because I can’t find a way to get these ‘special’ words and throw them in there.
Let me post the code in here, so you guys can take a closer look to what I’m doing right/wrong:
//Below, the Jframe1
public class JFrame1 extends javax.swing.JFrame {
public TxtFieldsQuotationMarks tfqm = new TxtFieldsQuotationMarks();
public TxtFieldsAsterisk tfa = new TxtFieldsAsterisk();
public JFrame1()
{
initComponents();
}
//Below, the classes I created to support the textFields in JFrame1
public class TxtFieldsQuotationMarks
{
public String field1;
public String field2;
public String field3;
}
public class TxtFieldsAsterisk
{
public String field1;
public String field2;
public String field3;
}
//Bellow, the function that should do the trick (of finding those ‘special words’)
private String Get_Fields_FindWords()(String Value)
{
if (Value.isEmpty())
{
return "";
}
else
{
String AuxStr = Value.substring(Value.indexOf('"'),Value.length());
return AuxStr.substring(1, AuxStr.indexOf('"'));
}
}
private String Get_Fields_Asterisk_FindWords(String Value)
{
if (Value.isEmpty())
{
return "";
}
else
{
String AuxStr = Value.substring(Value.indexOf('*'),Value.length());
return AuxStr.substring(1, AuxStr.indexOf('*'));
}
}
//Below, the button in JFrame1, that should find the words and open the JFrame2 for me with those words (Quotation Marks on top and Asterisks below it)
private void btnJFrame1ActionPerformed(java.awt.event.ActionEvent evt)
{
Get_Fields_FindWords();
Get_Fields_Asterisks_FindWords();
JFrame2 jf2 = new JFrame2();
jf2.setVisible(true);
}
//Below, the methods I tried to implement, in order to save the ‘special words’ in the textFields (this is also in the JFrame1)
public void Get_Fields()
{
fields.field1 = Return_StringQuotationMarks(txtField1.getText());
fields.field2 = Retorna_StringAspas(txtField2.getText());
fields.field3 = Retorna_StringAspas(txtField3.getText());
}
public void Get_Fields_Asterisk()
{
fields_asterisk.field1 = Return_StringAsterisk(txtField1.getText());
fields_asterisk.field2 = Return_StringAsterisk(txtField2.getText());
fields_asterisk.field3 = Return_StringAsterisk(txtField3.getText());
}
//Finally, here’s the second JFrame (Jframe2), with the textArea (textArea)
public class JFrame2 extends javax.swing.JFrame {
TxtFieldsQuotationMarks tfqm = new TxtFieldsQuotationMarks();
TxtFieldsAsterisk tfa = new TxtFieldsAsterisk();
public JFrame2()
{
initComponents();
}
}
That’s pretty much it, guys. I hope you can understand what I’m trying to do and can help me somehow. I really need this thing done as soon as possible.
Well I think you can pass the words founds by constructor of JFrame2. For example:
And the constructor of JFrame2:
Then you can initializate components in JFrame2 with the values searched in JFrame1.
You don’t need to save it somewhere you only need it in initialization.