Multi-line JTextPane: My SSCCE works, but not my reg. code . [LONG, sorry.]

So, I'm trying to code this flash cards program, and it's not working. The problem is that, when I change the text of the JTextPane to have multiple lines, the text disappears, and my JTextPane acts like it's empty. I included my SSCCE as a comparison, because it works just fine. I hope you guys don't mind that I included all of the code for my Cards program, even the stuff that I know isn't relevant, but I'm at a loss, and it's bedtime, so I'm done editing for the night. If you guys can fix my code, feel free to use it for your own personal use (as a reward for having to deal with the irrelevant stuff). How do I get my text to appear when it has multiple lines?
PS I know my button listeners aren't like they should be. I'm going to fix them after I fix the JTextPane.
PPS If this breaks anyone's browser, I'm sorry, but I included a file that is format-dependent, so I had to include it as is. Also, I had to include tabs and not spaces because of the length limit.
package sscce;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import javax.swing.WindowConstants;
import javax.swing.text.DefaultStyledDocument;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyleContext;
import javax.swing.text.StyledDocument;
public class SSCCE
     private final Font     bold          = new Font("Courier New", Font.BOLD, 12),
          plain = new Font("Courier New", Font.PLAIN, 12);
     JButton                    button          = new JButton("Press this button");
     final JLabel          labels[]     = {new JLabel("xyz"), new JLabel("xyz"),
          new JLabel("xyz"), new JLabel("xyz"), new JLabel("xyz"),
          new JLabel("xyz")               };
     final String          oldText          = "This text should wrap automatically because it is long.",
          newText = "This text should add height to the textPane because it is longer than the original.";
     boolean                    textSwitch     = true;
     final JTextPane          tp               = createTextPane();
     final JPanel          upperPanel     = new JPanel(new GridLayout(3, 1)),
          lowerPanel = new JPanel(new GridBagLayout());
     private SSCCE()
          final JFrame frame = new JFrame("SSCCE");
          button.addActionListener(new ButtonListener());
          start();
          frame.add(upperPanel, BorderLayout.CENTER);
          frame.add(lowerPanel, BorderLayout.SOUTH);
          frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
          frame.setSize(485, 338);
          frame.setVisible(true);
     public static void main(final String args[])
          new SSCCE();
     private void addItem(final String cell, final int colSpan,
          final int rowSpan, final JPanel pan)
          addItem(cell, colSpan, rowSpan, pan, new JLabel(" "), plain);
     private void addItem(final String cell, final int colSpan,
          final int rowSpan, final JPanel pan, final JComponent c, final Font f)
          final GridBagConstraints gc =
               new GridBagConstraints(cell.charAt(0) - 65, cell.charAt(1) - 49,
                    colSpan, rowSpan, 100, 100, GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0);
          try
               pan.setFont(f);
               pan.add(c, gc);
               pan.validate();
          catch (final Exception e)
               e.printStackTrace();
               System.exit(0);
     private JTextPane createTextPane()
          final StyleContext context = new StyleContext();
          final StyledDocument document = new DefaultStyledDocument(context);
          final Style style = context.getStyle(StyleContext.DEFAULT_STYLE);
          final JTextPane textPane = new JTextPane(document);
          textPane.setText(oldText);
          StyleConstants.setAlignment(style, StyleConstants.ALIGN_CENTER);
          textPane.setFont(new Font("Courier New", Font.BOLD, 12));
          textPane.setEditable(false);
          return textPane;
     private void start()
          upperPanel.setBackground(Color.WHITE);
          upperPanel.setLayout(new GridLayout(3, 1));
          lowerPanel.setLayout(new GridBagLayout());
          final JPanel topPanel = new JPanel(new GridBagLayout()), middlePanel =
               new JPanel(new GridBagLayout()), bottomPanel =
               new JPanel(new GridBagLayout());
          topPanel.setBackground(Color.RED);
          middlePanel.setBackground(Color.GREEN);
          bottomPanel.setBackground(Color.BLUE);
          upperPanel.setBackground(Color.BLACK);
          addItem("A1", 1, 1, topPanel);
          addItem("A2", 1, 1, topPanel, new JLabel("test1"), plain);
          addItem("A3", 1, 1, topPanel);
          addItem("A1", 1, 1, middlePanel);
          addItem("A2", 1, 1, middlePanel, tp, bold);
          addItem("A3", 1, 1, middlePanel);
          addItem("A1", 1, 1, bottomPanel);
          addItem("A2", 1, 1, bottomPanel, new JLabel("test2"), plain);
          addItem("A3", 1, 1, bottomPanel);
          addItem("A1", 1, 1, lowerPanel);
          addItem("B1", 1, 1, lowerPanel, button, plain);
          addItem("C1", 1, 1, lowerPanel);
          upperPanel.add(topPanel);
          upperPanel.add(middlePanel);
          upperPanel.add(bottomPanel);
     private class ButtonListener implements ActionListener
          @Override
          public void actionPerformed(final ActionEvent arg0)
               if (textSwitch)
                    tp.setText(newText);
               else
                    tp.setText(oldText);
               textSwitch = !textSwitch;
package fc;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.KeyboardFocusManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.Arrays;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextPane;
import javax.swing.WindowConstants;
import javax.swing.text.DefaultStyledDocument;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyleContext;
import javax.swing.text.StyledDocument;
public class Cards implements ActionListener, FocusListener
     private Cards          allDefs[]          = null;
     private final Font     bold               = new Font("Courier New", Font.BOLD, 12),
          plain = new Font("Courier New", Font.PLAIN, 12);
     private JButton          button1               = null;
     private JButton          button2               = null;
     private final int     card               = 0;
     private final int     CE                    = GridBagConstraints.CENTER,
          E = GridBagConstraints.EAST, W = GridBagConstraints.WEST;
     private boolean          clickedWrong     = true;
     private String          course               = null, def = null, page = null,
          word = null;
     private JLabel          courseLabel          = null;
     private Cards          currDef               = null;
     private JTextArea     enterDefn          = null, enterWord = null;
     private JFrame          frame               = null;
     private JButton          invis               = null;
     private JButton          learn               = null;
     private boolean          message               = true;
     private JPanel          p[]                    = null;
     private JLabel          pageLabel          = null;
     private JPanel          panel[]               = null;
     private JTextArea     rightDefn          = null;
     private JTextArea     rightWord          = null;
     private Cards          saveDefs[]          = null;
     private JTextPane     showLabel          = null;
     private JLabel          sizeLabel          = null;
     public Cards()
          try
               panel = new JPanel[2];
               panel[0] = new JPanel();
               panel[1] = new JPanel();
               panel[0].removeAll();
               panel[1].removeAll();
               panel[0].revalidate();
               panel[1].revalidate();
               allDefs = populate();
               button1 = new JButton();
               button2 = new JButton();
               learn = new JButton("Learn");
               button1.addActionListener(this);
               button2.addActionListener(this);
               learn.addActionListener(this);
               courseLabel = new JLabel();
               pageLabel = new JLabel();
               showLabel = createTextPane();
               sizeLabel = new JLabel();
               cardSetup();
               panel[0].setBackground(Color.WHITE);
               panel[1].setBackground(Color.WHITE);
               panel[0].setBorder(null);
               panel[1].setBorder(null);
               frame = new JFrame("Flash Cards");
               frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
               frame.setSize(485, 338);
               frame.setLocationRelativeTo(null);
               frame.add(panel[0], BorderLayout.CENTER);
               frame.add(panel[1], BorderLayout.SOUTH);
               frame.setResizable(false);
               frame.setVisible(true);
               start();
          catch (final Exception e)
               e.printStackTrace();
     public Cards(final String defCourse, final String defWord,
          final String defDef, final String defPage)
          course = defCourse;
          word = defWord;
          def = defDef;
          page = defPage;
     public static void main(final String args[])
          new Cards();
     @Override
     public void actionPerformed(final ActionEvent e)
          final Object src = e.getSource();
          if (src == button1)
               if (button1.getText().equals("Guess"))
                    button1.setText("Right");
                    button2.setText("Wrong");
                    showLabel.setText(currDef.def);
                    showLabel.setFont(bold);
                    panel[0].revalidate();
                    panel[1].revalidate();
               else
                    allDefs = remDef(allDefs, card);
                    if (allDefs != null)
                         button1.setText("Guess");
                         button2.setText("Skip");
                         showCard();
                    else
                         if (saveDefs == null)
                              frame.setVisible(false);
                              if (JOptionPane
                                   .showConfirmDialog(
                                        null,
                                        "According to you, you have guessed all the words right. Would you like to start over?",
                                        "All Correct!", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
                                   allDefs = populate();
                                   start();
                              else
                                   System.exit(0);
                         else
                              button1.setText("Guess");
                              button2.setText("Skip");
                              allDefs = Arrays.copyOf(saveDefs, saveDefs.length);
                              saveDefs = null;
                              if (clickedWrong)
                                   clickedWrong = false;
                                   JOptionPane
                                        .showMessageDialog(
                                             null,
                                             "You are now going over terms that you said you guessed wrong.",
                                             "", JOptionPane.INFORMATION_MESSAGE);
                              showCard();
          else if (src == learn)
               saveDefs = addDef(saveDefs, allDefs[card]);
               allDefs = remDef(allDefs, card);
               if (allDefs == null)
                    allDefs = Arrays.copyOf(saveDefs, saveDefs.length);
                    saveDefs = null;
                    if (clickedWrong)
                         clickedWrong = false;
                         JOptionPane
                              .showMessageDialog(
                                   null,
                                   "You are now going over terms that you said you guessed wrong.",
                                   "", JOptionPane.INFORMATION_MESSAGE);
               panel[0].removeAll();
               panel[1].removeAll();
               button1.setText("Guess");
               button2.setText("Skip");
               cardSetup();
               showCard();
          else
               if (button2.getText().equals("Wrong"))
                    int rows = 0;
                    final int colsWord = wordWrapWidth(allDefs[card].word, 21), colsDef =
                         67 - colsWord;
                    System.out.println(colsWord);
                    invis = new JButton("");
                    invis.setBackground(Color.BLACK);
                    p = new JPanel[3];
                    p[0] = new JPanel();
                    p[1] = new JPanel();
                    p[2] = new JPanel();
                    panel[0].setBackground(Color.BLACK);
                    rightWord = createTextArea(colsWord, allDefs[card].word);
                    rightDefn = createTextArea(colsDef, allDefs[card].def);
                    enterWord = createTextArea(colsWord);
                    enterDefn = createTextArea(colsDef);
                    enterWord.setBackground(Color.WHITE);
                    enterWord.setEditable(true);
                    enterWord.setFocusable(true);
                    p[0].setBackground(Color.BLACK);
                    p[1].setBackground(Color.BLACK);
                    p[2].setBackground(Color.BLACK);
                    p[0].add(rightWord);
                    p[0].add(rightDefn);
                    p[1].add(enterWord);
                    p[1].add(enterDefn);
                    p[2].add(invis); // otherwise invis appears when the word shows
                                             // up
                    panel[0].removeAll();
                    panel[1].removeAll();
                    panel[0].revalidate();
                    panel[1].revalidate();
                    learn.setEnabled(false);
                    rightWord.setEditable(false);
                    rightDefn.setEditable(false);
                    rightWord.setBackground(Color.GREEN);
                    rightDefn.setBackground(Color.GREEN);
                    panel[0].setLayout(new GridBagLayout());
                    panel[1].setLayout(new GridBagLayout());
                    addItem("A1", 3, 1, panel[0], p[0], bold, CE, 100, 0,
                         GridBagConstraints.BOTH);
                    addItem("A2", 3, 1, panel[0], p[1], bold, CE, 100, 100,
                         GridBagConstraints.BOTH);
                    addItem("A3", 3, 1, panel[0], p[2], bold, CE, 100, 0,
                         GridBagConstraints.BOTH);
                    addItem("A1", 1, 1, panel[1], new JLabel(" "), plain, W);
                    addItem("B1", 1, 1, panel[1], learn, plain, CE);
                    addItem("C1", 1, 1, panel[1], sizeLabel, plain, E);
                    panel[0].revalidate();
                    panel[1].revalidate();
                    try
                         Thread.sleep(50);
                    catch (final Exception i)
                         i.printStackTrace();
                    rows =
                         Math.max(wordWrapLines(rightWord), wordWrapLines(rightDefn));
                    rightWord.setRows(rows);
                    rightDefn.setRows(rows);
                    enterWord.setRows(rows);
                    enterDefn.setRows(rows);
                    enterWord.requestFocus();
     public Cards[] addDef(final Cards array[], final Cards defined)
          Cards newarray[] = null;
          if (array == null)
               newarray = new Cards[1];
          else
               newarray = Arrays.copyOf(array, array.length + 1);
          newarray[newarray.length - 1] = defined;
          return newarray;
     public void addItem(final String cell, final int colSpan,
          final int rowSpan, final JPanel pan)
          addItem(cell, colSpan, rowSpan, pan, new JLabel(" "), plain, E);
     public void addItem(final String cell, final int colSpan,
          final int rowSpan, final JPanel pan, final JComponent c, final Font f,
          final int anchor)
          addItem(cell, colSpan, rowSpan, pan, c, f, anchor, 100, 100);
     public void addItem(final String cell, final int colSpan,
          final int rowSpan, final JPanel pan, final JComponent c, final Font f,
          final int anchor, final int weightx, final int weighty)
          addItem(cell, colSpan, rowSpan, pan, c, f, anchor, weightx, weighty,
               GridBagConstraints.NONE);
     public void addItem(final String cell, final int colSpan,
          final int rowSpan, final JPanel pan, final JComponent c, final Font f,
          final int anchor, final int weightx, final int weighty, final int fill)
          final GridBagConstraints gc =
               new GridBagConstraints(cell.charAt(0) - 65, cell.charAt(1) - 49,
                    colSpan, rowSpan, weightx, weighty, anchor, fill, new Insets(0,
                         0, 0, 0), 0, 0);
          if (f != null)
               c.setFont(f);
          try
               pan.add(c, gc);
               pan.validate();
          catch (final Exception e)
               e.printStackTrace();
               System.exit(0);
     public void addItem(final String cell, final int colSpan,
          final int rowSpan, final JPanel pan, final JComponent c,
          final int anchor, final int weighty, final int weightx)
          final GridBagConstraints gc =
               new GridBagConstraints(cell.charAt(0) - 65, cell.charAt(1) - 49,
                    colSpan, rowSpan, weighty, weightx, anchor,
                    GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0);
          try
               pan.add(c, gc);
               pan.validate();
          catch (final Exception e)
               e.printStackTrace();
               System.exit(0);
     public void cardSetup()
          panel[0].setBackground(Color.WHITE);
          panel[0].setLayout(new GridLayout(3, 1));
          panel[1].setLayout(new GridBagLayout());
          final JPanel topPanel = new JPanel(new GridBagLayout()), middlePanel =
               new JPanel(new GridBagLayout()), bottomPanel =
               new JPanel(new GridBagLayout());
          middlePanel.setBackground(Color.GREEN);
          addItem("A1", 1, 3, topPanel);
          addItem("B1", 1, 2, topPanel);
          addItem("C1", 1, 1, topPanel);
          addItem("C2", 1, 1, topPanel, courseLabel, plain, E);
          addItem("C3", 1, 1, topPanel);
          addItem("A1", 1, 1, middlePanel, new JLabel(" "), bold, CE);
          addItem("A2", 1, 1, middlePanel, showLabel, bold, CE);
          addItem("A3", 1, 1, middlePanel, new JLabel(" "), bold, CE);
          addItem("A1", 1, 1, bottomPanel);
          addItem("B2", 1, 1, bottomPanel, pageLabel, plain, E);
          addItem("A3", 1, 1, bottomPanel);
          addItem("A1", 1, 1, panel[1]);
          addItem("B1", 1, 1, panel[1], button1, plain, E);
          addItem("C1", 1, 1, panel[1], button2, plain, W);
          addItem("D1", 1, 1, panel[1], sizeLabel, bold, E);
          panel[0].add(topPanel);
          panel[0].add(middlePanel);
          panel[0].add(bottomPanel);
     public JTextArea createTextArea(final int cols)
          return createTextArea(cols, "");
     public JTextArea createTextArea(final int cols, final String text)
          final JTextArea t = new JTextArea(text, 1, cols);
          t.addFocusListener(this);
          t.setBackground(Color.LIGHT_GRAY);
          t.setEditable(false);
          t.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
               null);
          t.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
               null);
          t.setFocusable(false);
          t.setFont(bold);
          t.setLineWrap(true);
          t.setWrapStyleWord(true);
          t.setSize(0, Short.MAX_VALUE);
          return t;
     private JTextPane createTextPane()
          final StyleContext context = new StyleContext();
          final StyledDocument document = new DefaultStyledDocument(context);
          final Style style = context.getStyle(StyleContext.DEFAULT_STYLE);
          final JTextPane textPane = new JTextPane(document);
          textPane
               .setText("This text should wrap automatically because it is long.");
          StyleConstants.setAlignment(style, StyleConstants.ALIGN_CENTER);
          textPane.setFont(new Font("Courier New", Font.BOLD, 12));
          textPane.setEditable(false);
          textPane.setBorder(BorderFactory.createLineBorder(Color.RED));
          return textPane;
     @Override
     public void focusGained(final FocusEvent e)
          final JTextArea src = (JTextArea) e.getSource();
          src.setBackground(Color.WHITE);
          src.setCaretPosition(0);
          src.setEditable(true);
     @Override
     public void focusLost(final FocusEvent e)
          final JTextArea src = (JTextArea) e.getSource();
          boolean correct = false;
          if (src == enterWord)
               correct = src.getText().equals(rightWord.getText());
          else if (src == enterDefn)
               correct = src.getText().equals(rightDefn.getText());
          if (correct)
               src.setBackground(Color.GREEN);
               src.setEditable(false);
               if (src == enterWord)
                    enterDefn.setFocusable(true);
                    enterDefn.setEditable(true);
                    enterDefn.requestFocus();
               if (src == enterDefn)
                    invis.setFocusable(false);
                    learn.setEnabled(true);
                    learn.requestFocus();
          else
               if (message)
                    if (src == enterWord)
                         int rightChars = 0;
                         for (int c = 0; c < rightWord.getText().length()
                              && c < src.getText().length(); c++)
                              if (rightWord.getText().charAt(c) != src.getText()
                                   .charAt(c))
                                   break;
                              rightChars++;
                         JOptionPane.showMessageDialog(
                              null,
                              rightWord.getText().substring(0, rightChars)
                                   + "|"
                                   + rightWord.getText().substring(rightChars,
                                        rightWord.getText().length())
                                   + "\n"
                                   + src.getText().substring(0, rightChars)
                                   + "|"
                                   + src.getText().substring(rightChars,
                                        src.getText().length()), "Incorrect",
                              JOptionPane.ERROR_MESSAGE);
                    if (src == enterDefn)
                         int rightChars = 0;
                         for (int c = 0; c < rightDefn.getText().length()
                              && c < src.getText().length(); c++)
                              if (rightDefn.getText().charAt(c) != src.getText()
                                   .charAt(c))
                                   break;
                              rightChars++;
                         JOptionPane.showMessageDialog(
                              null,
                              rightDefn.getText().substring(0, rightChars)
                                   + "|"
                                   + rightDefn.getText().substring(rightChars,
                                        rightDefn.getText().length())
                                   + "\n"
                                   + src.getText().substring(0, rightChars)
                                   + "|"
                                   + src.getText().substring(rightChars,
                                        src.getText().length()), "Incorrect",
                              JOptionPane.ERROR_MESSAGE);
                    src.requestFocus();
               message = !message;
     public Cards[] populate()
          Cards c[] = null;
          try
               final File file = new File("FC.txt");
               if (file.exists())
                    final BufferedReader in =
                         new BufferedReader(new FileReader(file));
                    String line = null;
                    int badTerms = 0, goodTerms = 0;
                    while ((line = in.readLine()) != null)
                         final String lines[] = line.split("\t");
                         if (lines.length == 4)
                              c =
                                   addDef(c, new Cards(lines[0], lines[1], lines[2],
                                        lines[3]));
                              goodTerms++;
                         else
                              badTerms++;
                    if (badTerms > 0)
                         JOptionPane
                              .showMessageDialog(
                                   null,
                                   "There were "
                                        + badTerms
                                        + " bad term(s) and "
                                        + goodTerms
                                        + " good term(s). You will see only the good entries for the terms.",
                                   "There were bad terms.",
                                   JOptionPane.INFORMATION_MESSAGE);
               else
                    JOptionPane
                         .showMessageDialog(
                              null,
                              "The file "
                                   + file.getCanonicalPath()
                                   + " does not exist. Please download the file or create it, and then restart the program.",
                              "File Not Found", JOptionPane.ERROR_MESSAGE);
                    System.exit(0);
          catch (final Exception e)
               e.printStackTrace();
          return c;
     public void printTA(final JTextArea ta)
          System.out.println("cols=" + ta.getColumns());
          System.out.println("rows=" + ta.getRows());
          System.out.println("text=" + ta.getText());
          System.out.println("getText.length()=" + ta.getText().length());
     public Cards[] remDef(final Cards[] array, final int cardnum)
          Cards temp[] = null;
          if (array.length > 1)
               temp = new Cards[array.length - 1];
               int defLength = 0;
               for (int l = 0; l < array.length; l++)
                    if (!array[cardnum].equals(array[l]))
                         temp[defLength] = array[l];
                    else
                         defLength--;
                    defLength++;
          return temp;
     private void showCard()
          currDef = allDefs[(int) Math.floor(Math.random() * allDefs.length)];
          courseLabel.setText(currDef.course);
          pageLabel.setText(currDef.page);
          showLabel.setText(currDef.word);
          sizeLabel.setText("Left: " + allDefs.length);
     private void start()
          button1.setText("Guess");
          button2.setText("Skip");
          showCard();
          frame.setVisible(true);
     @Override
     public String toString()
          return "Java.lang.Cards[" + course + "," + word + "," + def + ","
               + page + "]";
     public String wordWrap(final String string, final int w)
          String newStr = "", s = string;
          final int width = w;
          int oldSpace = 0;
          if (s.length() < w)
               return s;
          for (int c = 0; c < s.length(); c++)
               if (c == s.length() - 1)
                    if (s.length() > width && oldSpace != 0)
                         newStr +=
                              s.substring(0, oldSpace).replace("(", "\\(")
                                   .replace(")", "\\)")
                                   + "<br/>" + s.substring(oldSpace + 1, s.length());
                    else
                         newStr += s;
               else if (s.charAt(c) == ' ')
                    if (c > width)
                         newStr += s.substring(0, oldSpace) + "<br/>";
                         s =
                              s.replaceFirst(
                                   s.substring(0, oldSpace).replace("(", "\\(")
                                        .replace(")", "\\)")
                                        + " ", "");
                         c = 0;
                    oldSpace = c;
          return newStr;
     private int wordWrapLines(final JTextArea t)
          return wordWrap(t.getText(), t.getColumns()).replaceAll("<br/>", "\n")
               .split("\n").length;
     private int wordWrapWidth(final String s, final int w)
          final String lines[] =
               wordWrap(s, w).replaceAll("<br/>", "\n").split("\n");
          int maxWidth = 0;
          for (final String line : lines)
               if (line.length() > maxWidth)
                    maxWidth = line.length();
          if (maxWidth > w)
               return w;
          return maxWidth;
}And here is the accompanying file for Cards.java
ET115     accuracy     the difference between the measured and accepted or "true" value of a measurement     01.04.013.2
ET115     ampere-hour rating     a number given in ampere-hours; determined by multiplying a current in amps times the length of time in hours a battery can deliver that current to a load     03.07.093.1
ET115     atom     the smallest element particle that possesses the unique characteristics of that element     02.01.024.1
ET115     battery     an energy source that uses a chemical reaction to convert chemical energy into electrical energy     02.03.031.1
ET115     charge     an electrical property of matter that exists because of an excess or deficiency of electrons     02.02.028.1
ET115     circuit     an interconnection of a source, a load, and an interconnecting current path that are designed produce a desired result     02.06.047.1
ET115     circuit breaker     a resettable protective device used for interrupting excessive current in an electric circuit     02.06.050.2
ET115     colour code     a system of colour bands or dots that identify the vale of a resistor or other component     02.05.040.2
ET115     conductance     the ability of a circuit to allow current; the reciprocal of resistance     02.05.038.3
ET115     conductor     a material in which electrical current is established with relative ease     02.01.027.1
ET115     coulomb     the unit of electrical charge; the total charge possessed by 6.25 * 10^18 electrons     02.02.028.2
ET115     DMM     digital multimeter; an electronic instrument that combines meters for the measurement of voltage, current, and resistance     02.07.057.1
ET115     electronic     related to the movement and control of free electrons in semiconductors or vacuum devices     02.01.027.3
ET115     engineering notation     a system for representing any number as a one-, two-, or three-digit number, times a power of ten with an exponent that is a multiple of 3     01.01.007.1
ET115     error     the difference between the true measured and best-accepted value of a measurement     01.04.013.1
ET115     free electron     a valence electron that has broken away from its parent atom and is free to move from atom to atom within the atomic structure of a material     02.01.026.1
ET115     fuse     a protective device that burns open when there is excessive current in a circuit     02.06.050.1
ET115     half-splitting     a troubleshooting procedure where one starts in the middle of a circuit or system and, depending on the first measurement, works toward the output or toward the input to find the fault     03.08.096.1
ET115     ion     an atom that has gained or lost a valence electron and resulted in a net positive or negative charge     02.01.026.2
ET115     load     a resistor or other component that is connected across the output terminals of a circuit, draws current from the source, and has work done upon it     02.06.047.2
ET115     metric prefix     a symbol that is used to replace the power of ten in numbers expressed in engineering notation     01.02.010.1
ET115     Ohm's law     a law stating that current is directly proportional to voltage and inversely proportional to resistance     03.01.075.1
ET115     orbit     the path an electron takes as it circles around the nucleus of an atom     02.01.025.2
ET115     photovoltaic effect     the process where light energy converts directly into electrical energy     02.03.033.1
ET115     piezoelectric effect     the property of a crystal where a changing mechanical stress produces a voltage across the crystal     02.03.034.2
ET115     power of ten     a numerical representation consisting of a base 10 and an exponent; the number 10 raised to a power     01.01.004.2
ET115     power rating     the maximum amount of power a resistor can dissipate without being damaged by excessive heat build-up     03.05.088.1
ET115     precision     a measure of the repeatability or consistency of a series of measurements     01.04.013.3
ET115     resistor     an electrical component designed specifically to have a certain amount of resistance     02.05.039.1
ET115     round off     the process of dropping one or more digits to the right of the last significant digit in a number     01.04.015.1
ET115     scientific notation     a system for representing any number as a number between 1 and 10 times an appropriate power of ten     01.01.004.1
ET115     Seebeck effect     the generation of a voltage at the junction of two different metals that have a temperature difference between them     02.03.034.1
ET115     semiconductor     a material that has a conductance value between that of a conductor and an insulator     02.01.027.2
ET115     SI     standardised international system of units used for all engineering and scientific work; abbreviation for French Le Systeme International d'Unites     01.02.009.1
ET115     switch     an electrical or electronic device for opening and closing a current path     02.06.048.4
ET115     thermistor     a type of temperature transducer in which resistance is inversely proportional to temperature     02.05.046.2
ET115     thermocouple     a thermoelectric type of voltage source that is commonly used to sense temperature     02.03.033.4
ET115     troubleshooting     a systematic process of isolating, identifying, and correcting a fault in a circuit or system     03.08.095.1
ET115     voltage     the amount of energy available to move a certain number of electrons from one point or another in an electrical circuit     02.03.029.Edited by: ElectrifiedBrain on Apr 12, 2011 12:08 AM

EJP wrote:
No way anybody in their right mind is going to look at all that. Find the salient differences between your SCCE and your non-working code.I didn't think so, but it was worth a shot. I did my best to find it last night, but I just couldn't.
Kleopatra wrote:
hahahaha ... you really think that'll work: "I'm tired, so going for a nap - hope you'll clean the mess and have it fixed when I wakeup"
Dream well
JeanetteIt was midnight, and I had to wake up at 5:30, so that was true. I didn't really think it was going to work, but I was hoping.
Anyway, this can be locked too, I guess. I have an idea on how to find what's wrong.

Similar Messages

  • Hi!My 6 month old MBP 13" has suddenly stop charging.Mac is working,but not charging

    Hi!My 6 month old MBP 13" has suddenly stop charging.Mac is working,but not charging

    Troubleshooting MagSafe adapters  http://support.apple.com/kb/ts1713
    If you need to pursue further you can do it on-line,  start here
    https://selfsolve.apple.com/agreementWarrantyDynamic.do

  • Problem with drivers for HP B109 a-m all-in-one, have printer working but not scanner in windows 8

    Still have a problem with the drivers in Windows 8 release preview, for my HP B109 a-m all-in-one, have printer working but not scanner, is there any chance of a fix before final release of Windows 8 ?.

    Review my post here:
    http://h30434.www3.hp.com/t5/Windows-8-Release-Preview/SOLUTION-Get-Win-7-Printer-Drivers-HP-Solutio...
    And see if something similar will work for you.

  • Schedule lines present on R/3 but not available on BW.

    Schedule lines present on R/3 but not available on BW.
    It is observed that some schedule line records are uploaded to BW with recordmode ‘R’ causing deletion from ODS, though they are present on R/3 side (in EKET). We use 2lis_02_scl to upload schedule line data system BI 7.0. Anyone faced such problem?
    Points shall be assigned if found helpful.

    Kalyan ,
    refer to oss notes : 690106
    here he talks about what is the real motive for changing R mode to X mode .
    So but this notes does an undo operation for the same .
    We need to re do the same again in start routine if we want to maintain the deleted records . Also search the OSS by giving the data source name & record mode R , then you will also get the original problem in extractors with R mode .
    i forgot about the OSS numbers
    -Sourav

  • My Mac Mini doesn't recognize my Avengers DVD--it keeps saying "Supported disc not available." I've tried other DVD's which work, but not this one. itunes and everything else has been updated to the newest versions. Help?

    My Mac Mini doesn't recognize my Avengers DVD--it keeps saying "Supported disc not available." I've tried other DVD's which work, but not this one. itunes and everything else has been updated to the newest versions. Help? Also...It doesn't recognize the digital copy DVD.

    I have ALL the exact same symptoms as on my home computer.
    It sure sounds to me like something on the iPod is broken. If it's under warranty then I would send it back for repair. If not, check out some of the web repair services, such as iPodResQ etc.

  • Allt he links in the header of any websites are not working, I reinstalled fiorefix and it s the same. No problem in others browser. the tool bar is working but not the link sinside the web page located between the top 300px height

    all the links in the header of any websites are not working, the cursor is not changing into pointer and no way to click on any link located at the top of any website page. I reinstalled firefox and it s the same. No problem in others browser. the tool bar is working but not the links inside any web page located between the top 300px height.
    So I can t tlog into any website, i cant write an email as the compose button is located in the top of the page.. Please help, i have all my bookmarks into my firefox...

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode
    *https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes

  • Speakerphone problem - lost voice from speakerphone while playing music or gaming youtube, while call or voice recording playing - all works fine, so speakerphone is working but not on all apps. hard reset done - no changes

    or gaming youtube, while call or voice recording playing - all works fine, so speakerphone is working but not on all apps. hard reset done - no changes.
    iphone 4
    SOLVED plugin to charger solved it - so problem was with contacts -- no idea why - phone is new - no water - no havy dust - usual using  
    hope will never return. Thanks

    We checked it with an iPhone 5 in house multiple times and could not reproduce this Problem. Must be something specific to your device. Maybe your speakerphone volume is turned down completely?
    Follow the latest Skype Community News
    ↓ Did my reply answer your question? Accept it as a solution to help others, Thanks. ↓

  • My iPad cannot connect to my internet.  the internet is working but not with my ipad.

    my iPad cannot connect to my internet.  the internet is working but not with my ipad.

    Call your ISP (Internet Service Provider) and explain them your issue, it could range from having your router configured incorrectly to having a wiring issue. Personally, I have Comcast and they are great, no issues, and awesome customer service.
    Hope you get up and running ASAP

  • HT4993 My volume down button is not working.  The UP button works, but not the down button.  I have tried to restart it and that didn't solve the problem.

    My volume down button doesn't work on my iPhone.  The UP buttown works, but not the down button.  I have tried a hard reset and that didn't fix it.

    Try this.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.

  • ICloud keeps asking for password but will not take it. All other devices work but not my IMac???

    ICloud keeps asking for password but will not take it. All other devices work but not my IMac???

    Exactly which password are you inputting? iCloud looks for your AppleID password.

  • Wake on Lan (works, but not always)

    Iam trying to get Wak on Lan working on my iMac. It works, but not always. When I put my mac to sleep en send the magic package, my mac turns back on. But when my mac turns to sleep and I wait a few hours (the next morning), my Mac doesn't respond to the same magic packag. When I wake up the Mac by hand, and put it back to sleep again, the magic package works again en turns the mac on.
    It almost looks like the mac goes into a deeper sleep mode after a few hours. Does anyone knows what could ben the reazon.

    mmm, It seems like my mac doesn't always turns to sleep mode. Most of the time it only turns off the screen (solid light). My energy settings are 10 minutes for the screen and 15 minutes for the mac. But after turning of the screen it never turns to sleepmode. Ecxept when I put it to sleep manualy.
    Strange thing is: when the screen is turned of, shouldn't I be able to get tot my files... (I can't actualy).

  • Sap xi SCENARIO source directory working ,but not working target directory

    sap xi SCENARIO source directory working ,but not working target directory..
    plz help me

    Hi,
    Be more specific on the problem you are facing so that the ppl here can help..
    looks like your are trying to file to file scenario and the file is not generating at the target folder ...
    then check the communication logs of the receiver adapter using RWB->CC logs..
    post the error you have received there..
    HTH
    Rajesh

  • Can't sync ical on my iphone and imac. email and note work but not ical.  can anyone help.

    can't sync ical on my iphone and imac. email and note work but not ical.  can anyone help.
    thanks
    bmoreimac

    So how can i make it work that way, i asked one of my friends, and she says it works like that...when she delete the email on her iphone it is deleted on the mac too, what do i do to change this?....my mail it's hotmail, i don't know if its relevant

  • TS1702 facetime on my iphone works but not on my ipad

    Facetime on my iPhone 4S works but not on my iPad (3rd or 4th Gen)

    From the iPad User Guide:
    To use FaceTime, you need an Apple ID and a Wi-Fi connection to the Internet. When you open
    FaceTime, you may be prompted to sign in using your Apple ID, or to create a new account.
    Make a FaceTime call: Tap Contacts, choose a name, then tap the phone number or email address the person uses for FaceTime.
    You can also make a FaceTime call from the Contacts app.
    Rotate iPad to use FaceTime in either landscape or portrait orientation. To avoid unwanted orientation changes, lock iPad in portrait orientation. See Portrait and landscape orientation on page 20.

  • Just bought an iPhone 5C.. Safari is non-functional! A blank frozen screen! Any one else experience this? Horrid design Apple! It's your freaking web browser! Google Chrome works but not Safari! I may simply return this "upgrade" unless someone can help

    Just bought an iPhone 5C.. Safari is non-functional! A blank frozen screen... What gives? Safari is Apple's browser for gods sakes! Google Chrom works but not Safari? This is nuts. This is an "upgrade"?? Anyone else experiencing this? Or should I just give up and return this

    Are you always like this?
    First try a Reset: Hold down the home and sleep buttons, wait for the Apple logo, let go of the buttons.

Maybe you are looking for