Results 1 to 13 of 13

Thread: Fun with text

  1. #1
    Blue2525989 is offline Senior Member
    Join Date
    Sep 2016
    Posts
    108
    Rep Power
    0

    Default Fun with text

    Hey people, so I am just messing around making programs to better learn how everything works. Here is one I made involving messing around with strings. you can choose to uppercase, lowercase, or reverse the text from the second text area. I'd like to add some more features. What else can I add to mess with strings? Also I am wondering if I want to type 2 words or whatever in the text area, is it possible to differintiate between them and only perform a method on first word or second word or whatever?

    Java Code:
    package com.blue2525989;
     
    import static com.blue2525989.load2.*;
    import static com.blue2525989.util2.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    
    public class Textual extends JFrame implements ActionListener {    
            
            static JLabel prompt = new JLabel("");
            static JTextArea output1a = new JTextArea("",10,43);
            static JTextArea output2a = new JTextArea("",2,25);
            static JLabel banner = new JLabel("Welcome, please make a selection.");
            static JButton b1 = new JButton("");
            static JButton b2 = new JButton("");
            static JButton b3 = new JButton("");
            static JMenu choices = new JMenu("Choices:");
            static JMenuBar bar = new JMenuBar();
            public static String[] keyword = {"Uppercase","Lowercase","Reverse","Exit."
            ,"Start","Reset","Enter the word you wish to capitalize:","Right here",
            "Enter the word you wish to lowercase:", "Enter the word you wish to reverse:"};
            public static String[] ans = {"Upper case.","Lower case.", "Exit.","Reverse."};
    
            
        public Textual (){
            super("Textual Fun");
        }  
            public void actionPerformed(ActionEvent event){
            String command = event.getActionCommand();
            
            if (command.equals(keyword[0])) {
                question(keyword[6],
                        keyword[7],ans[0],keyword[5]);            
            }        
            if (command.equals(keyword[1])){
                question(keyword[8],
                        keyword[7],ans[1],keyword[5]);
            }
            if (command.equals(keyword[2])){
                question(keyword[9],keyword[7],ans[3],keyword[5]);
            }
            if (command.equals(keyword[3])) {
                System.exit(0);
            }
            if (command.equals(keyword[5])) {
                clear(); 
                }
            if (command.equals(ans[0])) {
                String a = output2a.getText().trim();
                prnt1(a.toUpperCase());
                } 
            if (command.equals(ans[1])) {
                String a = output2a.getText().trim();
                prnt1(a.toLowerCase());
            }    
            if (command.equals(ans[3])) {
                String a = output2a.getText().trim();
                StringBuilder sb = new StringBuilder();
                for(int i = a.length() - 1; i >= 0; --i)
                sb.append(a.charAt(i));
                String b = sb.toString();
                prnt1(b);
            }
        }
        
        public void gui () {
              
            FlowLayout flo1 = new FlowLayout(FlowLayout.CENTER);
             
            JPanel pane1 = new JPanel();
            pane1.add(banner);
                    
            bar.add(choices);
            pane1.add(bar);
            JMenuItem choice1 = new JMenuItem(keyword[0]);
            JMenuItem choice2 = new JMenuItem(keyword[1]);
            JMenuItem choice3 = new JMenuItem(keyword[2]);
            JMenuItem choice4 = new JMenuItem(keyword[3]);
            choice1.addActionListener(this);
            choice2.addActionListener(this);
            choice3.addActionListener(this);
            choice4.addActionListener(this);
            choices.add(choice1);
            choices.add(choice2);
            choices.add(choice3);
            choices.add(choice4);
            pane1.setBackground(Color.LIGHT_GRAY);
             
            JPanel pane1a = new JPanel();
            pane1a.add(output1a);
            pane1a.setBackground(Color.LIGHT_GRAY);
            
            JPanel pane2a = new JPanel();
            pane2a.add(prompt);
            pane2a.setBackground(Color.LIGHT_GRAY);
             
            JPanel pane2 = new JPanel();
            pane2.setLayout(flo1);
            pane2.add(output2a);
            pane2.setBackground(Color.LIGHT_GRAY);
                     
            JPanel pane3 = new JPanel();
            GridLayout grd1 = new GridLayout(1,2);
            pane3.setLayout(grd1);
            b1.addActionListener(this);
            b2.addActionListener(this);
            pane3.add(b1);
            pane3.add(b2);
            pane2.setBackground(Color.LIGHT_GRAY);
             
            JFrame frame = new JFrame("Textual Fun.");
            BorderLayout brd = new BorderLayout();
            frame.setLayout(brd);
             
            Container mainC = frame.getContentPane();
            GridLayout grd2 = new GridLayout(5,1);
            mainC.setLayout(grd2);
            mainC.add(pane1);
            mainC.add(pane1a);
            mainC.add(pane2a);
            mainC.add(pane2);
            mainC.add(pane3);
             
            frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
            frame.setSize(500,500);
            frame.setVisible(true);
        }
        public static void main(String[] args) {
            new Textual().gui();
            question("Here you will be prompted for each choice.",
                 "Here you will enter some text",
                 "","");   
        }    
    }    
        
    class util2 extends Textual {
            public static void prnt1(String s) {
                output1a.setText(s);
            }
            public static void prnt2(String s) {
                output2a.setText(s);
            }
            public static void buttonSet(String s1, String s2) {
                b1.setText(s1);b2.setText(s2);
            }
            public static void prompt(String s1) {
                prompt.setText(s1);
            }
        }
    class load2 extends Textual {
        
            static void question(String s1, String s2, String s3, String s4) {
            prnt1("Here is where your text will be displayed");
            prompt(s1);
            prnt2(s2);
            buttonSet(s3,s4);
            }
            
            public static void clear() {
            prnt1("");
            prompt("Please enter a word below:");
            prnt2(keyword[7]);
    }
    }
    Last edited by Blue2525989; 11-11-2016 at 08:49 PM.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Fun with text

    It's great that you are experimenting as that is required to learn. However, you really
    need to get away from static methods. Otherwise you are not taking advantage of the
    OO capabilities of Java.

    Also, unless you are going to override a method in JFrame (which is rare), you should just
    create an instance of it and use that as the top level container for you JPanel instances.

    As far as additional functionality goes, you could include rotate left and rotate right methods.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    Blue2525989 is offline Senior Member
    Join Date
    Sep 2016
    Posts
    108
    Rep Power
    0

    Default Re: Fun with text

    Okay thanks. I think I will try converting the util class to return methods first when i get back home.

    As far as roatating right and left do you mean printing them one char per line first line first char sec line sec char etc etc and then do it again but starting with last letter at first line? Or something different?

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Fun with text

    Rotate right one character means for a string "foobar", the new string would b "rfooba." The character is removed from the end
    and placed at the beginning. Rotate left is the opposite. This operation is found quite often in bit manipulation routines. You could
    even take an argument to rotate the string. Any integer of any size could do. Just take the mod (remainder) of the string length
    as the number of characters to rotate. Even negative numbers would work. For a string "foobar", rotating right one would be the
    same as rotating left minus one.

    Regards,
    Jim
    Last edited by jim829; 11-11-2016 at 10:27 PM.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  5. #5
    Blue2525989 is offline Senior Member
    Join Date
    Sep 2016
    Posts
    108
    Rep Power
    0

    Default Re: Fun with text

    Okay that sounds like it would be fun to do. I will try that later on thanks for the idea.

  6. #6
    Blue2525989 is offline Senior Member
    Join Date
    Sep 2016
    Posts
    108
    Rep Power
    0

    Default Re: Fun with text

    so which methods would you suggest to convert from a static method to a return value method? Maybe a suggestion as how to do so.

  7. #7
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Fun with text

    If the method needs to access instance fields from the class, it usually should not be static (there are always exceptions).
    If the method is simply functional, then make it static. A classic example is the Math class. All static because they simply
    do conversions and calculations based on passed arguments.

    In your case, the conversion methods that operate on a passed string would be good candidates for static methods.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  8. #8
    Blue2525989 is offline Senior Member
    Join Date
    Sep 2016
    Posts
    108
    Rep Power
    0

    Default Re: Fun with text

    So I removed as many static keywords as I could from my program. I've added a remove all vowels and remove all consonants features as well as a calculator that has an extra JFrame pop up with the buttons when you select calculator. And then when you select any other option it closes the window and re open again once back in calculator feature :)

    I would like to know a better way to streamline the detecting if string contains vowels a-u or consonants b-z. My way seems tedious.

    Java Code:
    package com.blue2525989;
     
    import static com.blue2525989.load2.*;
    import static com.blue2525989.util2.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    
    public class Textual extends JFrame implements ActionListener {
                   
            static JLabel prompt = new JLabel("");
            static JTextArea output1a = new JTextArea("",10,43);
            static JTextArea output2a = new JTextArea("",2,25);
            JLabel banner = new JLabel("Welcome, please make a selection.");
            static JButton b1 = new JButton("");
            static JButton b2 = new JButton("");
            static JButton b3 = new JButton("");
            JMenu choices = new JMenu("Choices:");
            JMenuBar bar = new JMenuBar();
            
            String[] keyword = {"Uppercase","Lowercase","Reverse","Exit"
            ,"Start","Reset","Enter the word you wish to capitalize:","Right here",
            "Enter the word you wish to lowercase:", "Enter the word you wish to reverse:",
            "Enter the word you wish to remove the vowels from:",
            "Remove Vowels","Enter the word you wish to remove the consonants from:",
            "Remove Consonants","Enter a number:",
            "Calculator"};
            String[] ans = {"Upper case.","Lower case.","Reverse.",
            "Remove vowels.","Remove consonants.","Add to main text field."};
            String[] calcB = {"Add","Subtract","Multiply","Divide",
            "Square Root","Square","Power of","Square Foot","Log"};
            
            JFrame frame2 = new JFrame("Math Buttons.");
            JButton add = new JButton(calcB[0]);
            JButton sub = new JButton(calcB[1]);
            JButton mult = new JButton(calcB[2]);
            JButton div = new JButton(calcB[3]);
            JButton sqrt = new JButton(calcB[4]);
            JButton sq = new JButton(calcB[5]);
            JButton pow = new JButton(calcB[6]);
            JButton sqft = new JButton(calcB[7]);
            JButton log = new JButton(calcB[8]);
            
        public Textual (){
            
        }  
            public void actionPerformed(ActionEvent event){
            String command = event.getActionCommand();
            //actions for menu
            if (command.equals(keyword[0])) {
                frame2.setVisible(false);
                question(keyword[6],
                        keyword[7],ans[0],keyword[5]);            
            }        
            if (command.equals(keyword[1])){
                frame2.setVisible(false);
                question(keyword[8],
                        keyword[7],ans[1],keyword[5]);
            }
            if (command.equals(keyword[2])){
                frame2.setVisible(false);
                question(keyword[9],
                        keyword[7],ans[2],keyword[5]);
            }
            if (command.equals(keyword[11])) {
                frame2.setVisible(false);
                question(keyword[10],
                        keyword[7],ans[3],keyword[5]);
            }
            if (command.equals(keyword[13])) {
                frame2.setVisible(false);
                question(keyword[12],
                        keyword[7],ans[4],keyword[5]);
            }
            if (command.equals(keyword[15])) {
                frame2.setVisible(true);
                question(keyword[14],
                        keyword[7],ans[5],keyword[5]);
            }
            if (command.equals(keyword[3])) {
                System.exit(0);
            }
            //actions for button 1
            if (command.equals(keyword[5])) {
                clear(keyword[7]); 
                }
            if (command.equals(ans[0])) {
                String a = output2a.getText().trim();
                prnt1(a.toUpperCase());
                } 
            if (command.equals(ans[1])) {
                String a = output2a.getText().trim();
                prnt1(a.toLowerCase());
            }    
            if (command.equals(ans[2])) {
                String a = output2a.getText().trim();
                StringBuilder sb = new StringBuilder();
                sb.append(a);
                sb.reverse();
                String b = sb.toString();
                prnt1(b);
            }
            if (command.equals(ans[3])) {
                String a = output2a.getText().toLowerCase().trim();
                String aa = "a",e = "e",i = "i",o = "o",u = "u";
                String space = " ";
                StringBuilder sb = new StringBuilder();
                sb.append(a.replaceAll(aa, space).replaceAll(e, space).replaceAll(i,
                        space).replaceAll(o,space).replaceAll(u, space));
                String b = sb.toString();
                prnt1(b);
            }
            if (command.equals(ans[4])) {
                String a = output2a.getText().toLowerCase().trim();
                String b="b",c="c",d="d",f="f",g="g",h="h",j="j",k="k",l="l",
                        m="m",n="n",p="p",q="q",r="r",s="s",t="t",v="v",w="w",
                        x="x",y="y",z="z",space=" ";
                
                StringBuilder sb = new StringBuilder();
                sb.append(a.replaceAll(b, space).replaceAll(c,space).replaceAll(d,
                space).replaceAll(f,space).replaceAll(g,space).replaceAll(h,
                space).replaceAll(j,space).replaceAll(k,space).replaceAll(l,
                space).replaceAll(m,space).replaceAll(n,space).replaceAll(p,
                space).replaceAll(q,space).replaceAll(r,space).replaceAll(s,
                space).replaceAll(t,space).replaceAll(v,space).replaceAll(w,
                space).replaceAll(x,space).replaceAll(y,space).replaceAll(z,
                space));
                String aa = sb.toString();
                prnt1(aa);
            }
            //math button set up
            if (command.equals(ans[5]))try {
                String a = output2a.getText().trim();
                double aa = Double.parseDouble(a);
                prnt1(aa+"");
                } catch(NumberFormatException e) {prnt1(e+" is not a number");}
            
            if (command.equals(calcB[0])) try {
                String a = output2a.getText().trim();
                double bb = Double.parseDouble(a);
                String b = output1a.getText().trim();
                double aa = Double.parseDouble(b);
                double sum = aa + bb;
                prnt1(sum+"");        
            }catch(NumberFormatException e) {prnt1(e+" is not a number");}
            
            if (command.equals(calcB[1])) try{
                String a = output2a.getText().trim();
                double aa = Double.parseDouble(a);
                String b = output1a.getText().trim();
                double bb = Double.parseDouble(b);
                double sum = bb - aa;
                prnt1(sum+"");
            }catch(NumberFormatException e) {prnt1(e+" is not a number");}
            
            if (command.equals(calcB[2])) try{
                String a = output2a.getText().trim();
                double aa = Double.parseDouble(a);
                String b = output1a.getText().trim();
                double bb = Double.parseDouble(b);
                double sum = aa * bb;
                prnt1(sum+"");
            }catch(NumberFormatException e) {prnt1(e+" is not a number");}
            
            if (command.equals(calcB[3])) try{
                String a = output2a.getText().trim();
                double aa = Double.parseDouble(a);
                String b = output1a.getText().trim();
                double bb = Double.parseDouble(b);
                double sum = bb / aa;
                prnt1(sum+"");
            }catch(NumberFormatException e) {prnt1(e+" is not a number");}
            
            if (command.equals(calcB[4])) try{
                String a = output2a.getText().trim();
                double aa = Double.parseDouble(a);
                double sum = Math.sqrt(aa);
                prnt1(sum+"");
            }catch(NumberFormatException e) {prnt1(e+" is not a number");}
            
            if (command.equals(calcB[5])) try{
                String a = output2a.getText().trim();
                double aa = Double.parseDouble(a);
                double sum = (aa * aa);
                prnt1(sum+"");
            }catch(NumberFormatException e) {prnt1(e+" is not a number");}
            
            if (command.equals(calcB[6])) try{
                String a = output2a.getText().trim();
                double aa = Double.parseDouble(a);
                String b = output1a.getText().trim();
                double bb = Double.parseDouble(b);
                double sum = Math.pow(bb,aa);
                prnt1(sum+"");
            }catch(NumberFormatException e) {prnt1(e+" is not a number");}
            
            if (command.equals(calcB[7])) try{
                String a = output2a.getText().trim();
                double aa = Double.parseDouble(a);
                String b = output1a.getText().trim();
                double bb = Double.parseDouble(b);
                double sum = (aa * bb);
                prnt1(sum+"");
            }catch(NumberFormatException e) {prnt1(e+" is not a number");}
            
            if (command.equals(calcB[8])) try{
                String a = output2a.getText().trim();
                double aa = Double.parseDouble(a);
                double sum = Math.log(aa);
                prnt1(sum+"");            
            }catch(NumberFormatException e) {prnt1(e+" is not a number");}
    }
        
        public void gui () {
              
            JPanel pane1 = new JPanel();
            pane1.add(banner);
                    
            bar.add(choices);
            pane1.add(bar);
            JMenuItem choice1 = new JMenuItem(keyword[0]);
            JMenuItem choice2 = new JMenuItem(keyword[1]);
            JMenuItem choice3 = new JMenuItem(keyword[2]);
            JMenuItem choice4 = new JMenuItem(keyword[3]);
            JMenuItem choice5 = new JMenuItem(keyword[11]);
            JMenuItem choice6 = new JMenuItem(keyword[13]);
            JMenuItem choice7 = new JMenuItem(keyword[15]);
            choice1.addActionListener(this);
            choice2.addActionListener(this);
            choice3.addActionListener(this);
            choice4.addActionListener(this);
            choice5.addActionListener(this);
            choice6.addActionListener(this);
            choice7.addActionListener(this);
            choices.add(choice1);
            choices.add(choice2);
            choices.add(choice3);
            choices.add(choice5);
            choices.add(choice6);
            choices.add(choice7);
            choices.add(choice4);
            pane1.setBackground(Color.LIGHT_GRAY);
             
            JPanel pane1a = new JPanel();
            pane1a.add(output1a);
            pane1a.setBackground(Color.LIGHT_GRAY);
            
            JPanel pane2a = new JPanel();
            pane2a.add(prompt);
            pane2a.setBackground(Color.LIGHT_GRAY);
             
            JPanel pane2 = new JPanel();
            pane2.add(output2a);
            pane2.setBackground(Color.LIGHT_GRAY);
                     
            JPanel pane3 = new JPanel();
            GridLayout grd1 = new GridLayout(1,2);
            pane3.setLayout(grd1);
            b1.addActionListener(this);
            b2.addActionListener(this);
            pane3.add(b1);
            pane3.add(b2);
            pane2.setBackground(Color.LIGHT_GRAY);
             
            JFrame frame = new JFrame("Textual Fun.");
            GridLayout grd2 = new GridLayout(5,1);
            frame.setLayout(grd2);
            frame.add(pane1);
            frame.add(pane1a);
            frame.add(pane2a);
            frame.add(pane2);
            frame.add(pane3);
            frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
            frame.setSize(500,500);
            frame.setVisible(true);
            
            JPanel paneMath = new JPanel();
            GridLayout grd3 = new GridLayout(3,3);
            paneMath.setLayout(grd3);
            paneMath.add(add);
            paneMath.add(sub);
            paneMath.add(mult);
            paneMath.add(div);
            paneMath.add(sqrt);
            paneMath.add(sq);
            paneMath.add(pow);
            paneMath.add(sqft);
            paneMath.add(log);
            add.addActionListener(this);
            sub.addActionListener(this);
            mult.addActionListener(this);
            div.addActionListener(this);
            sqrt.addActionListener(this);
            sq.addActionListener(this);
            pow.addActionListener(this);
            sqft.addActionListener(this);
            log.addActionListener(this);
            
            frame2.add(paneMath);
            frame2.setLocation(500,0);
            frame2.setDefaultCloseOperation(EXIT_ON_CLOSE);
            frame2.setSize(500,500);
            frame2.setVisible(false);
        }
        public static void main(String[] args) {
            new Textual().gui();
            question("Here you will be prompted for each choice.",
                 "Here you will enter some text",
                 "","");   
        }    
    }    
        
    class util2 extends Textual {
            public static void prnt1(String s) {
                output1a.setText(s);
            }
            public static void prnt2(String s) {
                output2a.setText(s);
            }
            public static void buttonSet(String s1, String s2) {
                b1.setText(s1);b2.setText(s2);
            }
            public static void prompt(String s1) {
                prompt.setText(s1);
            }
        }
    class load2 extends Textual {
        
            static void question(String s1, String s2, String s3, String s4) {
            prnt1("Here is where your text and or numbers will be displayed");
            prompt(s1);
            prnt2(s2);
            buttonSet(s3,s4);
            }
            
            public static void clear(String s1) {
            prnt1("");
            prompt("Please enter some characters below:");
            prnt2(s1);
    }
    }

  9. #9
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Fun with text

    a better way to streamline the detecting if string contains vowels a-u or consonants b-z
    Can you add some comments to the code showing where the code is trying to do that making it easy to find the logic?
    Something like:
    // Find if the String contains any consonants

    In general the code could use more comments saying what the different sections of the code are trying to do. That would make it easier for some one to read the code and make suggestions on better ways to do what the comments say the code is trying to do.


    The code for each of the search routines needs to be isolated into their own methods.
    There is a lot of repeated code that should be reduced to the common lines of code with parameters passed to it for each special case.

    The long list of if statements could be replaced by a switch statement. switch statements now handle Strings.
    Last edited by Norm; 11-12-2016 at 05:01 PM.
    If you don't understand my response, don't ignore it, ask a question.

  10. #10
    Blue2525989 is offline Senior Member
    Join Date
    Sep 2016
    Posts
    108
    Rep Power
    0

    Default Re: Fun with text

    Yeah things are starting to get bigger more comments would be a plus. Lines 103 thru 129 is where i replace chars.

    I didn't think about adding a switch statement instead. I'll give that a try later on today.

  11. #11
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Fun with text

    Ok, my first reaction to the following code was "what the heck?" However,
    you probably didn't fully read the API on replaceAll.

    Java Code:
                String a = output2a.getText().toLowerCase().trim();
                String b="b",c="c",d="d",f="f",g="g",h="h",j="j",k="k",l="l",
                        m="m",n="n",p="p",q="q",r="r",s="s",t="t",v="v",w="w",
                        x="x",y="y",z="z",space=" ";
                 
                StringBuilder sb = new StringBuilder();
                sb.append(a.replaceAll(b, space).replaceAll(c,space).replaceAll(d,
                space).replaceAll(f,space).replaceAll(g,space).replaceAll(h,
                space).replaceAll(j,space).replaceAll(k,space).replaceAll(l,
                space).replaceAll(m,space).replaceAll(n,space).replaceAll(p,
                space).replaceAll(q,space).replaceAll(r,space).replaceAll(s,
                space).replaceAll(t,space).replaceAll(v,space).replaceAll(w,
                space).replaceAll(x,space).replaceAll(y,space).replaceAll(z,
                space));
    Notice the API for replaceAll takes a regular expression. There is even a link there. However
    click on the link below and see how you can condense your vowel and consonant removal code.

    Patterns


    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  12. #12
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Fun with text

    In a previous thread it was suggested that you create a question class to hold the responses, questions, and other
    pertinent data. Yet you still want to use arrays to hold the questions which is cumbersome.

    If you create a question class for each question and used a map to store the class keyed on the command type, your ActionListener
    code would be much cleaner. And you might even want to consider a separate action listener for each button (but that depends on the
    flexibility of your question class).

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  13. #13
    Blue2525989 is offline Senior Member
    Join Date
    Sep 2016
    Posts
    108
    Rep Power
    0

    Default Re: Fun with text

    Yeah i tried doing as much with my last one but i never could get it to work how yall suggested. I tried a bunch but just couldnt figure it out. The arraylist and maps are still something i have to figure out.

    And no i didnt fully read the api. I just learned about the stringbuilder while i was searching the internet for functions i could add for strings. Someone had used it an a example so i just started playing around with the different things i could do.

Similar Threads

  1. Replies: 1
    Last Post: 11-27-2014, 12:14 AM
  2. Replies: 0
    Last Post: 07-24-2012, 08:07 AM
  3. Replies: 8
    Last Post: 07-17-2011, 02:38 PM
  4. Replies: 7
    Last Post: 03-05-2011, 09:25 AM
  5. Replies: 0
    Last Post: 12-09-2010, 05:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •