Menu

#4 Basic HTML

Unstable (example)
open
nobody
None
3
2005-12-20
2005-12-19
No

This is just a quick hack which renders the content of
the question and answer as html instead of regular
text. This means it is now possible to include
pictures. However since this is a very quick(replacing
3 lines and adding an additional 4 lines) the editor is
still just basic text editing. One last beware, if you
like your overview to be nice and clean putting html
tags in your cards can really mess them up.

For some odd reason sf won't let me upload the patch so
here it is:

Index: src/jmemorize/gui/swing/CardSidesPanel.java

RCS file:
/cvsroot/jmemorize/jmemorize/src/jmemorize/gui/swing/CardSidesPanel.java,v
retrieving revision 1.14
diff -u -r1.14 CardSidesPanel.java
--- src/jmemorize/gui/swing/CardSidesPanel.java 9 Nov
2005 23:30:07 -0000 1.14
+++ src/jmemorize/gui/swing/CardSidesPanel.java 19 Dec
2005 19:50:51 -0000
@@ -1,5 +1,5 @@
/*
- * Created on 23. M�rz 2004, 19:15
+ * Created on 23. M�rz 2004, 19:15
*/
package jmemorize.gui.swing;

@@ -22,6 +22,7 @@
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
+import javax.swing.JEditorPane;
import javax.swing.KeyStroke;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
@@ -49,8 +50,8 @@
}

// swing elements
- private JTextPane m_frontTextPane = new JTextPane();
- private JTextPane m_backTextPane = new JTextPane();
+ private JEditorPane m_frontTextPane = new
JEditorPane();
+ private JEditorPane m_backTextPane = new
JEditorPane();

private JLabel m_frontLabel = new JLabel(
Localization.getString("General.FRONTSIDE"));
//$NON-NLS-1$
Index: src/jmemorize/gui/swing/LearnPanel.java
===================================================================
RCS file:
/cvsroot/jmemorize/jmemorize/src/jmemorize/gui/swing/LearnPanel.java,v
retrieving revision 1.47
diff -u -r1.47 LearnPanel.java
--- src/jmemorize/gui/swing/LearnPanel.java 14 Nov 2005
12:12:39 -0000 1.47
+++ src/jmemorize/gui/swing/LearnPanel.java 19 Dec 2005
19:50:53 -0000
@@ -1,5 +1,5 @@
/*
- * Created on 24. M�rz 2004, 00:12
+ * Created on 24. M�rz 2004, 00:12
*/
package jmemorize.gui.swing;

@@ -23,6 +23,7 @@
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTextPane;
+import javax.swing.JEditorPane;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
@@ -57,7 +58,7 @@
private JButton m_yesButton =
new JButton(
Localization.getString("Learn.YES"));
//$NON-NLS-1$

- private JTextPane m_questionTextPane =
new JTextPane();
+ private JEditorPane m_questionTextPane =
new JEditorPane();
private CardSidesPanel m_cardAnswerPanel =
new CardSidesPanel();
private JPanel m_answerMainPanel =
buildAnswerPanel();
private JPanel m_questionMainPanel =
buildQuestionPanel();
@@ -193,6 +194,7 @@

private void initComponents()
{
+ m_questionTextPane.setContentType("text/html");
m_cardPanel.setLayout(new java.awt.CardLayout());
m_cardPanel.add(m_questionMainPanel,
"questionCard"); //$NON-NLS-1$
m_cardPanel.add(m_answerMainPanel,
"answerCard"); //$NON-NLS-1$

Discussion

  • Adam Ehlers Nyholm Thomsen

    Logged In: YES
    user_id=328519

    What this needs to make it more usable is a way to strip
    the contents of the question string of all html markup and
    convert special characters before sending them to swing for
    use in the overview. Right now I am looking for a library
    which can do this, if anybody knows of this please tell me.
    I am not very versed in the J2SE API.

    I will also try as soon as I get home to upload the patch
    again.

     
  • Adam Ehlers Nyholm Thomsen

    • milestone: --> Unstable (example)
    • priority: 5 --> 3
     
  • Adam Ehlers Nyholm Thomsen

    Logged In: YES
    user_id=328519

    Else I guess the best alternative would be to write an XSLT
    to use wíth GNU Jaxp for parsing all the questions.

     

Log in to post a comment.

MongoDB Logo MongoDB