Java Text Component

hello everyone, i need help regarding java swing Text component. I want to create a photo album in java. i tried to use JTextPane to view picture and text, and it works fine, but when i tried to make the JTextPane uneditable, the JTextPane display only the text without the picture.
maybe you can suggest how to solve this problem or suggest me to use other java component. Thank you very much in advance for your help.

JSplitPane

Similar Messages

  • Add & use custom jars in "Java embedding" component

    I need to generate pdf file in process.
    So I included "Java embedding" component, and write my code. For clarity example:
    com.itextpdf.text.Document document = new com.itextpdf.text.Document( 
                        com.itextpdf.text.PageSize.A4, 50, 50, 50, 50); 
              try { 
                   com.itextpdf.text.pdf.PdfWriter pdf = com.itextpdf.text.pdf.PdfWriter 
                             .getInstance(document, new java.io.FileOutputStream("c:\\text.pdf")); 
                   document.open(); 
                   document.add(new com.itextpdf.text.Paragraph("This is test message")); 
                   catch (com.itextpdf.text.DocumentException de) { System.err.println(de.getMessage());  }
                   catch (Exception de) { System.err.println(de.getMessage());}
              document.close();Im using external jar file, of course I add it to classpath (right click soa project -> properties -> libraries and classpath ->add jar).
    But I get folowing error (no during compilation, but during deploying):
    Failed to compile bpel generated classes.
    failure to compile the generated BPEL classes for BPEL process "SimpleProcess" of composite "default/SOAProject!1.0*soa_9f8e80a4-346d-424e-9e12-1b69e2024e58"
    The class path setting is incorrect.
    Ensure that the class path is set correctly. If this happens on the server side, verify that the custom classes or jars which this BPEL process is depending on are deployed correctly. Also verify that the run time is using the same release/version.
    [04:35:23 PM] Check server log for more details.
    [04:35:23 PM] Error deploying archive sca_SOAProject_rev1.0.jar to soa_server1 [[fe80:0:0:0:5968:cb45:2001:f6ce]:8001] 
    [04:35:23 PM] ####  Deployment incomplete.  ####
    [04:35:23 PM] Error deploying archive file:/C:/Projects/SOAProject/deploy/sca_SOAProject_rev1.0.jar
    (oracle.tip.tools.ide.fabric.deploy.common.SOARemoteDeployer)where ist the problem???
    Edited by: user1175491 on Nov 2, 2010 4:39 PM

    Ajaykumar, can u please write me what exactly append to bpel:exec part (which classes include?)? it looks now:
    <bpelx:exec name="GeneratePDF" version="1.5" language="java">
    <![CDATA[
                  com.itextpdf.text.Document document = new com.itextpdf.text.Document(  
                        com.itextpdf.text.PageSize.A4, 50, 50, 50, 50);  
              try {  
                   com.itextpdf.text.pdf.PdfWriter pdf = com.itextpdf.text.pdf.PdfWriter  
                             .getInstance(document, new java.io.FileOutputStream("c:\\text.pdf"));  
                   document.open();  
                   document.add(new com.itextpdf.text.Paragraph("This is test message"));  
                   catch (com.itextpdf.text.DocumentException de) {System.err.println(de.getMessage());}
                   catch (java.lang.Exception de) {System.err.println(de.getMessage());}  
              document.close();]]>
    </bpelx:exec>Edited by: user1175491 on Nov 2, 2010 5:07 PM
    Edited by: user1175491 on Nov 2, 2010 5:08 PM

  • Center text in a text component with line wrapping

    I need to display dynamic text in a text component. I need line wrapping (on work boundaries) and also need horizontal and vertical center alignment.
    How do I do this? I saw a previous post on aligning text in a JTextArea that said to use a JTextPane but I don't see in JTextPane how to do word wrapping.
    Thanks,
    John

    //  File:          SystemInfoWindow.java.java
    //  Classes:     SystemInfoWindow
    //  Package:     utilities.msglib
    //  Purpose:     Implement the SystemInfoWindow class.
    //     Author:          JJB 
    //     Revision History:
    //     Date            By   Rel#  Description of change
    //     =============  ===  ====  ===============================================
    //     Jul 3, 2006   JJB  1.00  Original version
    //  Public Types / Classes          Type Description
    //  ========================     =============================================
    //     SystemInfoWindow
    package utilities.msglib;
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTextArea;
    import javax.swing.JTextPane;
    import javax.swing.SwingUtilities;
    * TODO Enter description
    class SystemInfoWindow extends JDialog {
          * @param args
         public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        Test thisClass = new Test();
                        thisClass.setVisible(true);
                        SystemInfoWindow window = new SystemInfoWindow(thisClass);
                        window.setMessage("System shutdown in progress ... lot sof atatarte athis tis a sa logoint of tesxt it keeps going and going and going thsoreoiat afsjkjslakjs fshafhdskrjlkjsdfj");
                        window.setVisible(true);
         //     ------------------------  Inner Classes ---------------------
         static class Test extends JFrame {
              private JPanel jContentPane = null;
               * This is the default constructor
              public Test() {
                   super();
                   initialize();
               * This method initializes this
               * @return void
              private void initialize() {
                   this.setSize(300, 200);
                   this.setContentPane(getJContentPane());
                   this.setTitle("JFrame");
               * This method initializes jContentPane
               * @return javax.swing.JPanel
              private JPanel getJContentPane() {
                   if (jContentPane == null) {
                        jContentPane = new JPanel();
                        jContentPane.setLayout(new BorderLayout());
                   return jContentPane;
         //     ------------------------  Static Fields ---------------------
         private static final long serialVersionUID = -8602533190114692294L;
         //     ------------------------  Static Methods --------------------
         //     ------------------------  Public Fields ---------------------
         //     ------------------------  Non-Public Fields -----------------
         private JPanel jContentPane = null;
         private JTextPane textField = null;
         public SystemInfoWindow(JFrame frame) {
              super(frame);
              initialize();
              //setUndecorated(true);
              setLocationRelativeTo(frame);
              pack();
         //     ------------------------  Interface Implementations ---------
         //     ------------------------  Public Methods --------------------
         public void setMessage(String text){
              textField.setText(text);
              adjustSize();
         //     ------------------------  Non-Public Methods ----------------
         private void adjustSize(){
              Dimension oldSize = textField.getPreferredSize();
              textField.setPreferredSize(new Dimension(
                        oldSize.width, oldSize.height + 30));
              pack();
         //     ------------------------  Generated Code --------------------
          * This method initializes this
          * @return void
         private void initialize() {
              this.setSize(300, 200);
              this.setModal(true);
              this.setContentPane(getJContentPane());
              this.addWindowListener(new java.awt.event.WindowAdapter() {
                   public void windowOpened(java.awt.event.WindowEvent e) {
                        //setLocationRelativeTo(MsgLibGlobals.parent);
                        pack();
          * This method initializes jContentPane
          * @return javax.swing.JPanel
         private JPanel getJContentPane() {
              if (jContentPane == null) {
                   jContentPane = new JPanel();
                   jContentPane.setLayout(new BorderLayout());
                   jContentPane.setMaximumSize(new java.awt.Dimension(50,2147483647));
                   jContentPane.add(getTextField(), java.awt.BorderLayout.CENTER);
              return jContentPane;
          * This method initializes textField     
          * @return javax.swing.JTextPane     
         private JTextPane getTextField() {
              if (textField == null) {
                   textField = new JTextPane();
                   textField.setEditable(false);
                   textField.setMaximumSize(new java.awt.Dimension(20,2147483647));
              return textField;
    }Message was edited by:
    BaltimoreJohn

  • Retrieve RowSet and Display in Output Text Component

    To retrieve a row object, took more effort than I expected with this tool. I wanted to populate a simple output text component with a db object pulled from a row, and I binded it to the rowset column. It worked great, but it kept retrieving the first row, since in the JSP it was calling this:
    #{questionsetup.questionRowSet.currentRow['question']}
    To get it to increment rows per output text component I did this:
    questionRowSet.setDataSourceName("java:comp/env/jdbc/SelfService");
            questionRowSet.setCommand("SELECT ALL dbo.Question.quesId, dbo.Question.question, dbo.Question.lastChangeDate  FROM dbo.Question");
            questionRowSet.execute();
            questionRowSet.next();
            outputText3.setValue(questionRowSet.getString("question"));
            questionRowSet.next();
            outputText4.setValue(questionRowSet.getString("question"));
            questionRowSet.next();
            outputText5.setValue(questionRowSet.getString("question"));Is there another way to do this automatically? The Studio Creator way? Or is this correct? The Studio Creator help file explains how to bind a simple component, and using the binding, but it even says it will retrieve the data in the first row. Incremenet rows or specifying a specific one would really help!
    Thank you very much!

    Maybe take control of the Select statement myself...
    So I decided to get the MIN value of my ID
    like this
    "select MIN(T21id) AS ttt from persons"
    now this is valid in SQLyog
    BUT Creator says
    Description: An unhandled exception ...
    Exception Details: javax.faces.el.PropertyNotFoundException
    Invalid column name: BaseRemuneration
    nb why is this "unhandled" since it is inside a try block?
    why does it mention BaseRemuneration which is a completely different but valid column??
    So Sun Creator will accept an unknown subset of valid SQL commands, and give bizarre irrelevant exception error messages on the set of valid SQL statements that it doesnt like.
    The documents appear to state that MIN is not handled by the IDE but can be entered manually.
    In fact it can NOT be enmtered manually.
    So is there an accurate list of valid SQL that is accepted?

  • Line highlighting in Text Component

    I'm trying to figure out how to apply a colored background to certain lines of a text component. This is common, for instance, in a lot of editors, especially IDE's (notably, Eclipse), where the currently selected line has a separate background color from the rest of the page. I'm having a lot of trouble understanding how to use Elements and Views and EditorKits and all that, and I'm not even sure if that will solve the problem. All I've been able to do so far is put a colored background behind individual characters; but then it stops at the end of the line, instead of continuing for the width of the text component.
    Any help is greatly appreciated.

    I assumed you were using the built-in Highlighter classes to do the coloring. If you aren't, you're doing a lot more work than you need to. Here's what I use:import java.awt.Color;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
    import javax.swing.text.*;
    * Usage: new CurrentLineHighlighter(myColor).install(myTextComponent);
    public class CurrentLineHighlighter implements ChangeListener
      static final Color DEFAULT_COLOR = new Color(0, 0, 0, 15);
      private Highlighter.HighlightPainter painter;
      private Object highlight;
      private JTextComponent comp;
      public CurrentLineHighlighter()
        this(null);
      public CurrentLineHighlighter(Color highlightColor)
        Color c = highlightColor != null ? highlightColor : DEFAULT_COLOR;
        painter = new DefaultHighlighter.DefaultHighlightPainter(c);
      public void install(JTextComponent tc)
        comp = tc;
        comp.getCaret().addChangeListener(this);
      public void stateChanged(ChangeEvent evt)
        if (highlight != null)
          comp.getHighlighter().removeHighlight(highlight);
          highlight = null;
        int pos = comp.getCaretPosition();
        Element elem = Utilities.getParagraphElement(comp, pos);
        int start = elem.getStartOffset();
        int end = elem.getEndOffset();
        try
          highlight = comp.getHighlighter().addHighlight(start, end, painter);
        catch (BadLocationException ex)
          ex.printStackTrace();
    }

  • Passing text component to methods

    I have a method that reads a file and output puts it to a JTextArea. Everything is working fine but I am wondering if I can pass an object from a class above JTextArea (like TextComponent). Looking for a generic feel with whatever text based component I passed...will this make a difference with lightweight and heavyweigth components (swing vs. awt)? Or even streams for that matter? Will byte and character streams act differently?
    What is the super class of all text based gui components?
    What is the super class of all streams?
    Yes I have read the java api doc on streams and using swing! Thanks

    You have me until
    Everything is working fine but I am wondering if I can pass an object from a class above JTextArea (like TextComponent).What are you asking for here?
    You want to know if you can pass an object to a method? Yes.
    You want to know if you can modify a class further up in JTextArea's hierarchy, so it has a method that passes an object to another method? Yes, by extending it and implementing the functionality you want.
    Looking for a generic feel with whatever text based component I passed...will this make a difference with lightweight and heavyweigth components (swing vs. awt)?Not sure what you were asking for in the first place, so I'm unable to help you with this one.
    Or even streams for that matter? Will byte and character streams act differently?If you're asking, "When I pass a stream through a method, will it act differently when I use it inside that method?", then I can answer no, it will not. You are passing your stream by reference.
    class MyClass {
       private Object anObject;
       public MyClass() {
          anObject = new Object();
          MySecondClass secondClass = new MySecondClass(anObject);
    class MySecondClass {
       private Object theSameObject;
       public MyClass(Object argument) {
          theSameObject = argument;
    }In the above example, anObject was created in MyClass, and passed to the constructor of MySecondClass. The field theSameObject in MySecondClass is set to point to the Object passed into its constructor, which just happens to be the Object anObject created in MyClass. anObject was created in MyClass. theSameObject is essentially the exact same Object in that it references (points to) anObject.
    If I'm wrong feel free to call me on it, java gurus.
    What is the super class of all text based gui components?AWT or Swing?
    If it's AWT, look up the API for an AWT text component, try TextField, and look at the class hierarchy.
    If it's Swing, do the same for JTextField. You can easily do some detective work and figure out the super classes of 'text based gui components'.
    What is the super class of all streams?You can do the same as above for streams as well.
    Yes I have read the java api doc on streams and using swing! ThanksIf you've read the API docs on streams and Swing, then why did you ask the last two questions? Not trying to offend, it just seems kind of wierd.

  • Implementing a Text Component

    Hi all, I have to implement a custom text component for a
    project im working on. I was hoping someone could give me
    some direction on how to implement the text storage.
    I wont need more than the regular 256 ascii characters and
    text sizes could reach 4+ megs.
    1 - an array list of bytes
    2 - a stringbuffer
    3 - a LONG string
    I was thinking about doing every line as an arraylist of bytes
    and then putting the line objects into an arraylist - as opposed
    to a contiguous list of bytes.
    that way moving through the data will be easier.
    As well, im most interested in knowing how they implement the
    actual component. I was going to draw the characters (im using
    custom fonts) onto a bufferedimage and then display them onto
    a custom component that will be a JPanel with a drawn on scrollbar
    that will control the drawing bounds.
    i was hoping someone with a knowledge of how Java implements
    text components could give a brief comment on how
    text is stored in memory and drawn on to the screen in a
    text component - id be forever grateful!
    i hear a lot of people say they read the Java source code but i
    wouldnt even know where to begin in such a process, lol.
    thanks!

    Secondly, I don't really understand what you are doing or
    why you feel you need to create a custom component to display textIm working on a mathematics project.
    There is an equation editor that has to be integrated with
    graphics routines (graphs, models etc).
    This JPanel will have keypresses mapped to symbols and
    special functions with the "text" formatted around the embedded
    graphics.
    The implementation will be easy - BUT it did get me curious
    on how the JVM implements a text component.
    From the internal representation (maybe stringbuffers?) to
    how it converts each Unicode char and then paints it into
    the component.
    After all looking up each char and then decoding the TrueType
    format (which i read uses a Virtual Machine with instruction sets)
    and drawing it (directly to the component or to an image?) seems
    like it would be intensive - but text components always seem
    very fast.

  • Scrollable Text Component

    I need to make a scrollable text component which reads characters from an InputStream object. I have two questions.
    Q1: My first attempt was to make a Text Area but I couldn't find any ways to easily make it scrollable. The method in the JTextComponent class that returns the scrollable object needs a Rectangle object in its paramaters. But I don't have a Rectangle object, I have a Text Area object. This gets me thinking that perhaps I should be using a different object than a Text Area. So, what class/object should I use from the API to make a scrollable text component?
    Q2: I want this scrollable Text Component to read characters from an InputStream object. How can I do this easily?

    * SaveReloadText.java
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import javax.swing.*;
    public class SaveReloadText extends JFrame {
        public SaveReloadText() {
            initComponents();
        private void initComponents() {
            setTitle("Save-Reload JTextArea");
            toolbar = new JToolBar();
            saveButton = new JButton("Save");
            reloadButton = new JButton("Reload");
            reloadButton.setEnabled(false);
            textarea = new JTextArea();
            setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            saveButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    saveButtonActionPerformed(evt);
            toolbar.add(saveButton);
            reloadButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    reloadButtonActionPerformed(evt);
            toolbar.add(reloadButton);
            getContentPane().add(toolbar, BorderLayout.NORTH);
            textarea.setBackground(new Color(204, 204, 204));
            textarea.setText(
                    "BLA BLA BLA\n" +
                    "\n" +
                    "bla bla bla bla bla bla bla bla blabla bla bla  bla bla bla, \n" +
                    "bla bla bla bla bla bla bla bla blabla bla bla  bl, etc. \n" +
                    "\n" +
                    "Bla bla bla bla bla bla bla bla blabla bla bla  bla bla bla bla bla. \n" +
                    "\n" +
                    "Bla bla bla bla bla bla bla bla blabla bla bla  bla bla bla, \n" +
                    "bla bla bla bla bla bla bla bla blabla bla bla  bla bla bla bla bla bla blabla. \n" +
                    "Bla bla bla bla . \n" +
                    "\n" +
                    "bla bla bla bla bla bla,  bla bla blabla bla bla . \n" +
                    "\n" +
                    "bla bla bla bla bla bla bla bla blabla bla bla  bla bla bla bla bla  bla bla bla \n" +
                    "bla bla bla, blahhhhhhhhhhh. "
            getContentPane().add(new JScrollPane(textarea), BorderLayout.CENTER);
            setSize(300,200);
            setLocationRelativeTo(null);
        private void saveButtonActionPerformed(final ActionEvent evt) {
            try{
                doSave();
            }catch(IOException ex){
                ex.printStackTrace();
                return;
            textarea.setText("");
            saveButton.setEnabled(false);
            reloadButton.setEnabled(true);
        private void reloadButtonActionPerformed(final ActionEvent evt) {
            try{
                doReload();
            }catch(IOException ex){
                ex.printStackTrace();
                return;
            saveButton.setEnabled(true);
            reloadButton.setEnabled(false);
        private void doSave() throws IOException{
            Writer writer = new BufferedWriter(new FileWriter(new File(FILE_NAME)));
            textarea.write(writer);
            writer.close();
        private void doReload() throws IOException{
            Reader reader = new BufferedReader(new FileReader(new File(FILE_NAME)));
            textarea.read(reader,null);
            reader.close();
        public static void main(final String args[]) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new SaveReloadText().setVisible(true);
        private final String FILE_NAME = "c:\\Masturbation_Technique.txt";
        private BufferedWriter writer;
        private BufferedReader reader;
        private JButton saveButton,reloadButton;
        private JTextArea textarea;
        private JToolBar toolbar;
    }

  • Please help with choosing the right text component

    Hello,
    In my applet, I need a single-line text component with the following capabilities:
    1: Support for bold font (entire text,not just part of it)
    2: Support for underlined text (entire text,not just part of it)
    3: Support for blinking text
    4: Ability to put caret anywhere within the text field with mouse
    5: Support for field validation
    6: Ability to handle various key events and modify the text and/or move around caret position accordingly.
    Now, I know there are at least 4 different text components: JTextField, JTextArea, JEditorPane, JTextPane. Which one of these is most suitable for the above features? Is it possible to use JTextField to support all of the above?

    Here is a link to the Java Swing tutorial which discusses the text components.
    http://java.sun.com/docs/books/tutorial/uiswing/components/text.html
    I think you need to use a JEditorPane or a JTextPane (although I'm not sure any of the components support blinking text). A demo program shows some of the capabilities of these components:
    http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html

  • How to email text from a text component in my applet on a the host server ?

    How to email text from a text component in my applet on a the host server, back to my email address ?
    Assuming I have Email Form on the host server.
    Help will be appreciated.

    You can do like below
    =REPLACE(Fields!Column.Value," " & Parameters!ParameterName.value & " ","<b>" & Parameters!ParameterName.value & "</b>")
    The select the expression and  right click and choose placeholder properties
    Inside that set Markup type as HTML 
    then it will highlight the passed parameter value in bold within the full xml string
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Making a java browser component for Mac platform(Urgent)

    I was trying to make a simple java browser component from scratch for running on Mac platform. I was using JFrame/JEditorPane. Although JEditorPane can open web pages but it can't support Javascript, flash and other interactive features of many websites. Does anyone know any way to make JEditorPane support javascript?
    I also researched on JDIC java web browser, but unfortunately they don't support for Mac yet. Is there any free third party tool available which I can use?
    Any quick help is appreciated. Thanks.

    I was trying to make a simple java browser component from scratch for running on Mac platform. I was using JFrame/JEditorPane. Although JEditorPane can open web pages but it can't support Javascript, flash and other interactive features of many websites. Does anyone know any way to make JEditorPane support javascript?
    I also researched on JDIC java web browser, but unfortunately they don't support for Mac yet. Is there any free third party tool available which I can use?
    Any quick help is appreciated. Thanks.

  • Word processing within a text component

    Although this is a potentially great application, I am at present prevented from using it to create a website due to the lack, as far as I can determine, of any form of processing individual text within the text components e.g. making individual words or word groups bold or italic or giving them COLORS.
    I have large informatory text areas on my pages which need this sort of processing in order to avoid client eyestrain as well as my own.
    Of course one can get around this to some extent by using multiple components but for long texts this quickly becomes very tedious and error prone, especially if one wants to copy from another source.
    The Static Text component, which I presume is meant for this sort of text, in it's present simple form allows word wrap but no line formatting. The basic Text Area component (multiple lines) has no word wrap but does allow line formatting. However when one sets the Read Only property, it seems that any self created line formatting is duly destroyed. This is strangely not the case with the old Standard Mutliline Text Area component.
    I may be missing something but if not I hope that these features may yet be incorporated.
    Regards,
    Dave

    You can use static text to render pure HTML, just set "escape" property to false.
    Note that the HTML text must be well former.
    Regards.

  • Parse Exception : java.text.ParseException: Unparseable date

    I have inherited a UDF in some mapping that on the whole, works okay...
    but it throws an error after mapping a few dates:
    Parse Exception : java.text.ParseException: Unparseable date: "2010-03-18T00:00:00.000Z"
    Parse Exception : java.text.ParseException: Unparseable date: "2010-03-23T23:59:00.000Z"
    Parse Exception : java.text.ParseException: Unparseable date: "2010-03-18T00:00:00.000Z"
    Parse Exception : java.text.ParseException: Unparseable date: "2010-03-23T23:59:00.000Z"
    Parse Exception : java.text.ParseException: Unparseable date: "2010-03-18T00:00:00.000Z"
    Parse Exception : java.text.ParseException: Unparseable date: "2010-03-23T23:59:00.000Z"
    the first few map okay...  then i get the exception.
    the UDF is as follows:
    public String convertDateTimeToUTC(String strDate, Container container) throws StreamTransformationException{
    AbstractTrace trace = container.getTrace();
    Date date=null;
    SimpleDateFormat sdfSource = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
    try{
    String dt = strDate;
    date = sdfSource.parse(dt);
    trace.addInfo("Local Date:"+date);
    SimpleDateFormat sdfDestination = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    strDate = sdfDestination.format(date);
    catch(ParseException pe){
    trace.addInfo("Parse Exception : " + pe);
    return strDate;
    can anyone see why this fails after successfully mapping a few fields???

    the first mapping works correctly...
    then we reuse the same fields to map to the additional segments.
    the context is correct as it is trying to pull the same fields in...  it just throw the error with the same data in the same UDF/Function Library but for different segments! :o(
    http://img199.imageshack.us/img199/3104/dateconversion.jpg
    as you can see from the screenshot above, the mapping works in the first instance, then fails on subsequent nodes.

  • Java.text.ParseException :UnparseableDate

    Hi,
    Iam trying to convert a String into Date and that Date in to a customized Date format...,Here it is what iam doing..
    import java.util.*;
    import java.io.*;
    import java.text.*;
    public class str2date
    public static void main(String[] args)
    try
    String mystr="01-03-2003";
         SimpleDateFormat converttodt=new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
         java.util.Date mydt=converttodt.parse(mystr.trim());
         System.out.println("mydt"+mydt);
         String output=converttodt.format(mydt);
         System.out.println(output);
         catch(ParseException e)
         System.out.println(e.toString());
    Error:"java.text.ParseException :UnparseableDate 01-03-2003"
    Can any one help me out... URGENT...,
    Thanks in Advance
    Rao.

    Well, the problem is right in front of you. You're telling it the format of the date is going to be
    yyyy-MM-dd'T'hh:mm:ss
    and then you're giving it the date in a format of
    MM-dd-yyyy
    and wondering why it's not accepting it? If you want to input a date from one format and output it in another you need to create two SimpleDateFormat objects, one to parse the date from a String to a Date object, and a second (or reuse the first with a different parse string) to format the Date and output it as a String.

  • How to create a text Component With Certain Properties

    I need to create a text component with the following properties:
    Has Capability to be italic, right/left aligned, have different background / foreground colors, and most importantly, the ability to have a fixed width and a height that is set by the amount of text in it (ie line wrapping expands the field vertically).
    It should be a simple exercise, but I cannot seem to figure out how to do it.

    Here is the correct syntax :
    private static JEditorPane constructPane(String text, int normWidth, int normHeight, boolean rightAlign, boolean italic,boolean isWhite) {
              JEditorPane pane = new JEditorPane();
              pane.setEditable(false);
              pane.setContentType("text/html");
              pane.setText(
                   "<html><head></head><body>"
                   + (italic?"<i>":"")
                   + "<table><COLGROUP><COL width=\""+normWidth+"\"><THREAD><tr><td valign=\"top\" align="+(rightAlign?"\"right\"":"\"left\"")+">"
                   + text+"</td></tr></table>"
                   + (italic?"</i>":"")
                   + "</body></html>");
              pane.setSize(normWidth,normHeight);
              if(isWhite)
                   pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(1,0,1,0,Color.WHITE),BorderFactory.createEmptyBorder(0,1,0,1)));
                   pane.setForeground(Color.WHITE);
              else {
                   pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(1,0,1,0,Color.BLACK),BorderFactory.createEmptyBorder(0,1,0,1)));
                   pane.setForeground(Color.BLACK);
              return pane;
         }

Maybe you are looking for

  • HT204088 how to i get refunded for things that i didnt buy?

    I checked my bank acct and there were charges from itunes looked at my order history and there we charges that we did not make> what do  we do to get a refund?

  • How to create an XML Port in we21

    Hi friends, Please help me in creating the XML Port in we21. what are the inputs I need to pass to create the XML File  Port. Kindly suggest me Thanks in Advance, Ganesh

  • Outer join With a constant value

    Hi all, In one of query i have found out that the outer join with a constant value like to_currency(+)='USD' to_currency is a column name in a table.can any one please explain this outer join condtn. Thanks in advance Senthil

  • System Copy on Microsoft Cluster

    Hi, We have ECC 6.0 SR2 with Microsoft Cluster on Oracle 10.2 & Windows 2003 Enterprise edition 64bit. Installation is ABAP+java stack Installation of CI and DB on same host. Virtual hostname for database is ORACLEOT1 Virtual hostname for CI is SAPOT

  • Help with sycning with Mail program

    I use the Mail program on our iMac, which syncs with my yahoo account. However, the folders I have set up through the Mail program differ from yahoo and Mail simply syncs the emails themselves. How do I get my iPhone to sync with Mail instead of yaho