Question to understand javax.swing.plaf.FontUIResource("Arial Unicode MS"..

Hi Commuity!
I have an Question about this function!
javax.swing.plaf.FontUIResource("Arial Unicode MS", Font.PLAIN, 12);
I have read the Java doc but this didn�t help!
I wanted to know, what happend, if this Font is not an the Client.
So i deleted the Font "Arial Unicode MS".
But the applikation still use this Font. But it is not on my local PC?
Were do Swing load the Font�s from?
Are the Fonts included in Java?
thx a lot
Florian

Has got nobody an idea, where swing load the fonts from?

Similar Messages

  • Where did javax.swing.plaf.metal go after 1.4?

    Dear Users of the java.swing libraries,
    I've made a schoolproject in javax.swing and i am using the javax.swing.plaf.metal.MetalLookAndFeel as LookAndFeel.
    The Problem is: it seems sun has removed the Metal LookAndFeel in versions past 1.4 or something like that. I read this in the source DefaultmetalTheme.java file:
    * This class describes the default Metal Theme.
    * <p>
    * <strong>Warning:</strong>
    * Serialized objects of this class will not be compatible with
    * future Swing releases. The current serialization support is
    * appropriate for short term storage or RMI between applications running
    * the same version of Swing.  As of 1.4, support for long term storage
    * of all JavaBeans<sup><font size="-2">TM</font></sup>
    * has been added to the <code>java.beans</code> package.
    * Please see {@link java.beans.XMLEncoder}.
    * @version 1.25 01/23/03
    * @author Steve Wilson
    */Now i wonder, can i find this cool Metal style anywhere else? In like the java.beans that was mentioned in the code of DefaultmetalTheme.java.
    In my current situation my project is ruined and i would relly appriciate some feedback on this!
    Yours Truthfully,
    Alexander Thore

    They would only be where you put them.
    You should be importing them to your computer regularly as you would with any digital camera, most especially before any update.
    If you failed to do this, then they are likely gone.
    You can try a restore from backup.

  • AAARGH!!! Can't understand javax.swing.text.*

    Good afternoon...
    does anybody understand javax.swing.text classes? i've read a number of
    books, downloaded docs (including those from the javax.swing.text author), and googled everything i could think of. but nothing seems to explain it to me so that i can understand it! maybe i'm just dense, but maybe it really is that difficult.
    i want to create a read-only document, who's source is not necessarily a
    string, but perhaps an ArrayList of objects with a HashMap of attributes. or even something simpler for now, just an object with a fixed number of attributes. i want to display this information in a JTextArea. i tried implementing a Document and passing it to the JTextArea constructor but just got a NullPointerException.
    does anybody know where i can find more information on creating my own
    document types?
    here's the code for my ReadOnlyDocument class if anyone of you are generous (& adventurous) enough to take a look:
    import java.util.ArrayList;
    import javax.swing.event.DocumentListener;
    import javax.swing.event.UndoableEditListener;
    import javax.swing.text.AttributeSet;
    import javax.swing.text.BadLocationException;
    import javax.swing.text.Document;
    import javax.swing.text.Element;
    import javax.swing.text.Position;
    import javax.swing.text.Segment;
    public class ReadOnlyDocument implements Document{
        private String myContent = "this is the contents of my document!";
        private ArrayList listeners;
        private ReadOnlyDocument refSelf = this;
        public ReadOnlyDocument() {
         System.out.println("ReadOnlyDocument.<init>");
        public int getLength() {
         System.out.println("ReadOnlyDocument.getLength() = " + myContent.length());
            return myContent.length();
        public void addDocumentListener(DocumentListener listener) {
         System.out.println("ReadOnlyDocument.addDocumentListener(" + listener + ")");
            if (listeners != null) {
                listeners = new ArrayList();
                listeners.add(listener);
            } else {
                listeners = new ArrayList();
                listeners.add(listener);
        public void removeDocumentListener(DocumentListener listener) {
         System.out.println("ReadOnlyDocument.removeDocumentListener(" +
    listener + ")");
            if (listeners != null) {
                listeners.remove(listener);
        public void addUndoableEditListener(UndoableEditListener listener) {
            // Read-only document, nothing to do here
         System.out.println("ReadOnlyDocument.addUndoableEditListener(" +
    listener + ")");
        public void removeUndoableEditListener(UndoableEditListener listener) {
            // Read-only document, nothing to do here
         System.out.println("ReadOnlyDocument.removeUndoableEditListener(" +
    listener + ")");
        public Object getProperty(Object key) {
            System.out.println("ReadOnlyDocument.getProperty(" + key + ") =
    null");
            return null;
        public void putProperty(Object key, Object value) {
               System.out.println("ReadOnlyDocument.putProperty(" + key + ")");
        public void remove(int offs, int len) throws BadLocationException {
            // Read-only document, nothing to do here
         System.out.println("ReadOnlyDocument.remove(" + offs + ", " + len +
        public void insertString(int offset, String str, AttributeSet a) throws
    BadLocationException {
            // Read-only document, nothing to do here
         System.out.println("ReadOnlyDocument.insertString(" + offset + ", " +
    str + ", " + a + ")");
        public String getText(int offset, int length) throws
    BadLocationException {
         System.out.print("ReadOnlyDocument.getText(" + offset + ", " + length +
    ") = ");
            if ((offset >= 0) && (length >= 0) && (offset+length <=
    myContent.length()+1)) {
             System.out.println(myContent.substring(offset, offset+length-1));
                return myContent.substring(offset, offset+length-1);
            } else {
             System.out.println("BadLocationException!");
                throw new BadLocationException("Bad location requested", 0);
        public void getText(int offset, int length, Segment txt) throws
    BadLocationException {
         System.out.print("ReadOnlyDocument.getText(" + offset + ", " + length +
    ", " + txt + ") = ");
            if ((offset >= 0) && (length >= 0) && (offset+length <=
    myContent.length()+1)) {
             System.out.println(myContent.substring(offset, offset+length-1));
                txt = new Segment(myContent.toCharArray(), offset, length);
            } else {
             System.out.println("BadLocationException!");
                throw new BadLocationException("Bad location requested", 0);
        public Position getStartPosition() {
         System.out.println("ReadOnlyDocument.getStartPosition() = 0");
      return new Position() {
       public int getOffset() {
        return 0;
        public Position getEndPosition() {
         System.out.println("ReadOnlyDocument.getEndPosition() = " +
    myContent.length());
      return new Position() {
       public int getOffset() {
        return myContent.length();
        public Position createPosition(int offs) throws BadLocationException {
         System.out.println("ReadOnlyDocument.createPosition(" + offs + ") =
    0");
            if ((offs >= 0) && (offs <= myContent.length()-1)) {
       return new Position() {
        public int getOffset() {
         return 0;
      } else {
       throw new BadLocationException("Bad location requested", 0);
        public Element[] getRootElements() {
         System.out.println("ReadOnlyDocument.getRootElements()");
         Element[] roots = {new Element() {
       public Document getDocument() {
        return refSelf;
       public Element getParentElement() {
        return null;
       public String getName() {
        return "ReadOnlyRoot";
       public AttributeSet getAttributes() {
        return null;
       public int getStartOffset() {
        return 0;
       public int getEndOffset() {
        return myContent.length() - 1;
       public int getElementIndex(int offset) {
        return 0;
       public int getElementCount() {
        return 0;
       public Element getElement(int index) {
        return null;
       public boolean isLeaf() {
        return true;
      return roots;
        public Element getDefaultRootElement() {
         System.out.println("ReadOnlyDocument.getDefaultRootElement()");
      return new Element() {
       public Document getDocument() {
        return refSelf;
       public Element getParentElement() {
        return null;
       public String getName() {
        return "ReadOnlyRoot";
       public AttributeSet getAttributes() {
        return null;
       public int getStartOffset() {
        return 0;
       public int getEndOffset() {
        return myContent.length() - 1;
       public int getElementIndex(int offset) {
        return 0;
       public int getElementCount() {
        return 0;
       public Element getElement(int index) {
        return null;
       public boolean isLeaf() {
        return true;
        public void render(Runnable r) {
            // not sure what to put here
         System.out.println("ReadOnlyDocument.render(" + r + ")");
    }and here's a simple class to display the document/generate the error:
    import java.awt.event.*;
    import javax.swing.*;
    public class ReadOnlyFrame extends JFrame {
    public ReadOnlyFrame() {
      super();
      setTitle("Read Only Document");
      addWindowListener(new WindowAdapter() {
       public void windowClosed(WindowEvent e) {
        System.exit(0);
      getContentPane().add(new JTextArea(new ReadOnlyDocument()));
      setSize(200, 200);
    public static void main(String[] args) {
      ReadOnlyFrame rof = new ReadOnlyFrame();
      rof.setVisible(true);
    Headed for the second star to the right and straight on till morning...
    Eric Schultz
    aka: Storkman
    http://community.webshots.com/user/storky1
    mailto:EricSchultzATcanadaDOTcom

    if you are getting that print before the timer
    starts, then I'd expect it's not blocking. The
    problem with these small snippets of code is that we
    can't really tell what might be going on elsewhere.Yes, I realize that. AAMOF, there isn't anything going on elsewhere, i.e.
    the GestureController object spawns another thread when it gets
    created. That other thread blocks until a 'Mover' object is delivered to
    the GestureController object. The mutex/synchronizing stuff works
    like the textbook version, i.e. no deadlock, no deadly embrace, no
    nothing. When the timer is started, the Mover is supposed to
    call back the 'animate' method, just a method in the GestureController
    object.
    All the System.out.prints show that it gets there. The task (an ActionListener)
    dispatched by that timer doesn't start. As you can see above, I've
    used System.out.prints for that too. It is as if that Timer doesn't start.
    I still haven't found anything ... This is what the 'auto.move' thing is
    supposed to do:     static class DragMover implements Mover {
              DrawableStack from;
              DrawableStack to;
              int position;
              DragMover(DrawableStack from, int position, DrawableStack to) {
                   this.from= from;
                   this.to  = to;
                   this.position= position;
              public void move() {
                   System.out.println("moving the stuff...");
                   GestureController.getGestureController().animate(from, position, to);
              public void undo() { }          
         }... the line "moving stuff ..." isn't displayed either, i.e. the actionPerformed
    method is never called and then ... there's nothing in between there, i.e.
    the Timer is supposed to call that method.
    Thank you for your reply, much appreciated and,
    kind regards,
    Jos
    by that timer (an ActionListener)

  • Importing  javax.swing.plaf.basic.BasicListUI.MouseInputHandler

    Hi!!
    I have totally no idea why I cannot import javax.swing.plaf.basic.BasicListUI.MouseInputHandler. The compiler says BasicListUI interface is expected.

    Agreed (maybe even so for 1.4.1 that I've just wiped out so I can't cehck my old rt.jar :o).
    For the moment I use my old translation of the basic.properties (and windods.properties) packed in a jar-file placed in
    jreXX/lib/ext/myLanguage.jar
    So far it works for the dialogs in my applications ...
    However, I don't find this a clean solution. I now find basic.class in rt.jar. Juged from all the other basic_xx.class files in rt.jar I guess this is where basic.properties went ... My next move will be to get hands on the source code of JAVA and check out how basic.java looks like ... perhaps this is a class filled with static fields and a simple method that sets properties in memeory or ? or ? ... In particular I need find out if some 'fields' have been added or removed compared to the old basic.properties. If so, the old translation would only be parial and my apps would be a mix of danish and english.
    I'm not really that much of a JAVA programmer and this is just to share some thoughts. Does anyone out there know a central reference on how those of us that speak minority languges easily get translations of core JAVA stuff (meaning Yes, No, Cancel and the like) take effect the easy way? Are there national boards that take care of such business?
    Maybe I haven't searched enough for information - my apologies if you found it waste of time reading this reply.
    With kind regards and thanks in advance, MJTJ

  • Exception at javax.swing.UIManager.setLookAndFeel(UIManager.java:435)

    Only in one machine (AIX 5.2 with J2RE 1.3.1 IBM) I got the following exception:
    "main" (TID:0x300C19D8, sys_thread_t:0x3003EF58, state:R, native ID:0x1) prio=5
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.java2d.SunGraphicsEnvironment.<init>(SunGraphicsEnvironment.java:105)
         at sun.awt.X11GraphicsEnvironment.<init>(X11GraphicsEnvironment.java:82)
         at java.lang.Class.newInstance0(Native Method)
         at java.lang.Class.newInstance(Class.java:262)
         at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:72)
         at java.awt.Font.initializeFont(Font.java:285)
         at java.awt.Font.<init>(Font.java:319)
         at javax.swing.plaf.FontUIResource.<init>(FontUIResource.java:51)
         at javax.swing.plaf.basic.BasicLookAndFeel.getFont(BasicLookAndFeel.java:252)
         at javax.swing.plaf.basic.BasicLookAndFeel.initComponentDefaults(BasicLookAndFeel.java:271)
         at javax.swing.plaf.metal.MetalLookAndFeel.initComponentDefaults(MetalLookAndFeel.java:210)
         at javax.swing.plaf.basic.BasicLookAndFeel.getDefaults(BasicLookAndFeel.java:80)
         at javax.swing.plaf.metal.MetalLookAndFeel.getDefaults(MetalLookAndFeel.java:1088)
         at javax.swing.UIManager.setLookAndFeel(UIManager.java:408)
         at javax.swing.UIManager.setLookAndFeel(UIManager.java:435)
    Other machine works fine.
    Any suggestion?
    Grazie

    So I can only assume that I have the the necessary resources installed correctly. Any thoughts on what might be causing my problem?
    com.sun.java.plat.windows.WindowsClassicLookAndFeel // the class you're trying to set
    com.sun.java.plaf.windows.WindowsClassicLookAndFeel // the class that is actually availableSee the difference?
    ~

  • WARNING: No saved state for javax.swing.JTable

    Hi All,
    I have a JTable component in my code and I used Netbeans to add swing components. However, I get this warning after I run my app:
    WARNING: No saved state for javax.swing.JTable[jTable1,0,0,329x80,alignmentX=0.0,alignmentY=0.0,border=,
            flags=251658568,maximumSize=,minimumSize=,preferredSize=,autoCreateColumnsFromModel=true,
            autoResizeMode=AUTO_RESIZE_SUBSEQUENT_COLUMNS,cellSelectionEnabled=false,editingColumn=-1,
            editingRow=-1,gridColor=javax.swing.plaf.ColorUIResource[r=128,g=128,b=128],
            preferredViewportSize=java.awt.Dimension[width=450,height=400],rowHeight=16,rowMargin=1,
            rowSelectionAllowed=true,selectionBackground=javax.swing.plaf.ColorUIResource[r=51,g=153,b=255],
            selectionForeground=javax.swing.plaf.ColorUIResource[r=255,g=255,b=255],showHorizontalLines=true,
            showVerticalLines=true]What is the reason of this? If I need to catch this exception, how can I add it with netbeans?
    Edited by: Darryl Burke -- broke a long line into several lines

    Set the name property of your JTable, it's a Netbeans thing, rather than a Java problem. table.setName("MyTable");Have a look at this thread for details: SessionStorage warning while program is running
    Please only post Java related questions here and post Netbeans questions to a netbeans forum/mailing list, thanks.

  • Javax.swing.text.TableView bug in 1.4 beta 2 ?

    Hi,
    I derived a class from TableView, which worked fine with 1.3, but now causes the following exception as soon as being layouted:
    java.lang.Error: should not happen: class com.lexetius.swing.text.LexTableView
    at javax.swing.text.BoxView.baselineLayout(Unknown Source)
    at javax.swing.text.ParagraphView$Row.layoutMinorAxis(Unknown Source)
    at javax.swing.text.BoxView.setSpanOnAxis(Unknown Source)
    at javax.swing.text.BoxView.layout(Unknown Source)
    at javax.swing.text.BoxView.setSize(Unknown Source)
    at javax.swing.text.BoxView.updateChildSizes(Unknown Source)
    at javax.swing.text.BoxView.setSpanOnAxis(Unknown Source)
    at javax.swing.text.BoxView.layout(Unknown Source)
    at javax.swing.text.FlowView.layout(Unknown Source)
    at javax.swing.text.BoxView.setSize(Unknown Source)
    at javax.swing.text.BoxView.updateChildSizes(Unknown Source)
    at javax.swing.text.BoxView.setSpanOnAxis(Unknown Source)
    at javax.swing.text.BoxView.layout(Unknown Source)
    at javax.swing.text.BoxView.setSize(Unknown Source)
    at javax.swing.plaf.basic.BasicTextUI$RootView.setSize(Unknown Source)
    at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(Unknown Source)
    at javax.swing.JComponent.getPreferredSize(Unknown Source)
    at javax.swing.JEditorPane.getPreferredSize(Unknown Source)
    at javax.swing.ScrollPaneLayout.layoutContainer(Unknown Source)
    at java.awt.Container.layout(Unknown Source)
    at java.awt.Container.doLayout(Unknown Source)
    at java.awt.Container.validateTree(Unknown Source)
    at java.awt.Container.validate(Unknown Source)
    at javax.swing.RepaintManager.validateInvalidComponents(Unknown Source)
    at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknow
    n Source)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    any ideas???

    I wrote the com.lexetius.swing.text.LexTableView component myself. It is derived directly from javax.swing.text.TableView and it adds virtually no functionality. I'm quite sure, the problem comes from the TableView class, but I can't verify that directly, since this class is abstract (why is that, anyway??).
    It would certainly help me very much, if anybody had a component, which is also derived from javax.swing.text.TableView and works with the 1.4 beta.

  • [HELP! ] why my program thows a javax.swing.text.ChangedCharSetException?

    there's the source:
    import java.io.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    import javax.swing.text.html.*;
    import javax.swing.border.*;
    class HTMLMagician extends JFrame
         protected static final String APP_NAME="HTML Magician V1.0 Produced By V Studio";
         protected JTextPane hm_textPane;
         protected StyleSheet hm_styleSheet;
         protected HTMLEditorKit html_kit;
         protected HTMLDocument html_document;
         protected JMenuBar hm_menuBar;
         protected JToolBar hm_toolBar;
         protected JFileChooser hm_fileChooser;
         protected File current_file;
         protected boolean text_changed=false;
         public HTMLMagician()
              super(APP_NAME);
              setSize(800,600);
              getContentPane().setLayout(new BorderLayout());
              produceMenuBar();
              hm_textPane=new JTextPane();
              html_kit=new HTMLEditorKit();
              hm_textPane.setEditorKit(html_kit);
              JScrollPane textPane_scrollPane=new JScrollPane();
              textPane_scrollPane.getViewport().add(hm_textPane);
              getContentPane().add(textPane_scrollPane,BorderLayout.CENTER);
              hm_fileChooser=new JFileChooser();
              javax.swing.filechooser.FileFilter hm_filter=new javax.swing.filechooser.FileFilter()
                   public boolean accept(File pathname)
                        if(pathname.isDirectory())
                             return true;
                        String ext_name=pathname.getName().toLowerCase();
                        if(ext_name.endsWith(".htm"))
                             return true;
                        if(ext_name.endsWith(".html"))
                             return true;
                        if(ext_name.endsWith(".asp"))
                             return true;
                        if(ext_name.endsWith(".jsp"))
                             return true;
                        if(ext_name.endsWith(".css"))
                             return true;
                        if(ext_name.endsWith(".php"))
                             return true;
                        if(ext_name.endsWith(".aspx"))
                             return true;
                        if(ext_name.endsWith(".xml"))
                             return true;
                        if(ext_name.endsWith(".txt"))
                             return true;
                        return false;
                   public String getDescription()
                        return "HTML files(*.htm,*.html,*.asp,*.jsp,*.css,*.php,*.aspx,*.xml)";
              hm_fileChooser.setAcceptAllFileFilterUsed(false);
              hm_fileChooser.setFileFilter(hm_filter);
              try
                   File dir=(new File(".")).getCanonicalFile();
                   hm_fileChooser.setCurrentDirectory(dir);
              }catch(IOException ex)
                   showError(ex,"Error openning current directory");
              newDocument();
              WindowListener action_winClose=new WindowAdapter()
                   public void windowClosing(WindowEvent evt)
                        if(!promptToSave())
                             return;
                        System.exit(0);
              addWindowListener(action_winClose);
              setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
              setVisible(true);
         protected void produceMenuBar()
              hm_menuBar=new JMenuBar();
              hm_toolBar=new JToolBar();
              JMenu menu_file=new JMenu("File");
              menu_file.setMnemonic('f');
              ImageIcon icon_new=new ImageIcon("imgs/file.gif");
              Action action_new=new AbstractAction("New",icon_new)
                   public void actionPerformed(ActionEvent evt)
                        if(!promptToSave())
                             return;
                        newDocument();
              JMenuItem item_new=new JMenuItem(action_new);
              item_new.setMnemonic('n');
              item_new.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,InputEvent.CTRL_MASK));
              menu_file.add(item_new);
              JButton button_new=hm_toolBar.add(action_new);
              ImageIcon icon_open=new ImageIcon("imgs/folder_open.gif");
              Action action_open=new AbstractAction("Open...",icon_open)
                   public void actionPerformed(ActionEvent evt)
                        if(!promptToSave())
                             return;
                        openDocument();
              JMenuItem item_open=new JMenuItem(action_open);
              item_open.setMnemonic('o');
              item_open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,InputEvent.CTRL_MASK));
              menu_file.add(item_open);
              JButton button_open=hm_toolBar.add(action_open);
              ImageIcon icon_save=new ImageIcon("imgs/floppy.gif");
              Action action_save=new AbstractAction("Save",icon_save)
                   public void actionPerformed(ActionEvent evt)
                        saveAs(false);
              JMenuItem item_save=new JMenuItem(action_save);
              item_save.setMnemonic('s');
              item_save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,InputEvent.CTRL_MASK));
              menu_file.add(item_save);
              JButton button_save=hm_toolBar.add(action_save);
              Action action_saveAs=new AbstractAction("Save As...")
                   public void actionPerformed(ActionEvent evt)
                        saveAs(true);
              JMenuItem item_saveAs=new JMenuItem(action_saveAs);
              item_saveAs.setMnemonic('a');
              item_saveAs.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,InputEvent.CTRL_MASK));
              menu_file.add(item_saveAs);
              menu_file.addSeparator();
              Action action_close=new AbstractAction("Quit")
                   public void actionPerformed(ActionEvent evt)
                        if(!promptToSave())
                             return;
                        System.exit(0);
              JMenuItem item_exit=new JMenuItem(action_close);
              item_exit.setMnemonic('q');
              item_exit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,InputEvent.CTRL_MASK));
              menu_file.add(item_exit);
              hm_menuBar.add(menu_file);
              setJMenuBar(hm_menuBar);
              getContentPane().add(hm_toolBar,BorderLayout.NORTH);
         protected String getDocumentName()
              return current_file==null ? "Untitled" : current_file.getName();
         protected void newDocument()
              html_document=(HTMLDocument)html_kit.createDefaultDocument();
              hm_styleSheet=html_document.getStyleSheet();
              hm_textPane.setDocument(html_document);
              current_file=null;
              setTitle(getDocumentName()+" - "+APP_NAME);
              Runnable runner=new Runnable()
                   public void run()
                        text_changed=false;
                        html_document.addDocumentListener(new action_textChanged());
              SwingUtilities.invokeLater(runner);
         protected void openDocument()
              if(hm_fileChooser.showOpenDialog(HTMLMagician.this)!=JFileChooser.APPROVE_OPTION)
                   return;
              File f=hm_fileChooser.getSelectedFile();
              if(f==null || !f.isFile())
                   return;
              current_file=f;
              setTitle(getDocumentName()+" - "+APP_NAME);
              HTMLMagician.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
              try
                   InputStream in=new FileInputStream(current_file);
                   html_document=(HTMLDocument)html_kit.createDefaultDocument();
                   html_kit.read(in,html_document,0);
                   hm_styleSheet=html_document.getStyleSheet();
                   hm_textPane.setDocument(html_document);
                   in.close();
              }catch(Exception ex)
                   showError(ex,"Error openning file "+current_file);
              HTMLMagician.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
              Runnable runner=new Runnable()
                   public void run()
                        text_changed=false;
                        html_document.addDocumentListener(new action_textChanged());
              SwingUtilities.invokeLater(runner);
         protected boolean saveAs(boolean as)
              if(!as && !text_changed)
                   return true;
              if(as || current_file==null)
                   if(hm_fileChooser.showSaveDialog(HTMLMagician.this)!=JFileChooser.APPROVE_OPTION)
                        return false;
                   File f=hm_fileChooser.getSelectedFile();
                   if(f==null || !f.isFile())
                        return false;
                   current_file=f;
                   setTitle(getDocumentName()+" - "+APP_NAME);
              HTMLMagician.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
              try
                   OutputStream out=new FileOutputStream(current_file);
                   html_kit.write(out,html_document,0,html_document.getLength());
                   out.close();
              }catch(Exception ex)
                   showError(ex,"Error saving file "+current_file);
              HTMLMagician.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
              return true;
         protected boolean promptToSave()
              if(!text_changed)
                   return true;
              int result=JOptionPane.showConfirmDialog(this,"Save change to "+getDocumentName(),APP_NAME,JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.INFORMATION_MESSAGE);
              switch(result)
                   case JOptionPane.YES_OPTION:
                        if(!saveAs(false))
                             return false;
                        return true;
                   case JOptionPane.NO_OPTION:
                        return true;
                   case JOptionPane.CANCEL_OPTION:
                        return false;
              return true;
         protected void showError(Exception ex,String message)
              ex.printStackTrace();
              JOptionPane.showMessageDialog(this,message,APP_NAME,JOptionPane.WARNING_MESSAGE);
         public static void main(String[] args)
              new HTMLMagician();
         class action_textChanged implements DocumentListener
              public void changedUpdate(DocumentEvent evt)
                   text_changed=true;
              public void insertUpdate(DocumentEvent evt)
                   text_changed=true;
              public void removeUpdate(DocumentEvent evt)
                   text_changed=true;
    when i open a .html file,the command output :
    javax.swing.text.ChangedCharSetException
         at javax.swing.text.html.parser.DocumentParser.handleEmptyTag(Unknown Source)
         at javax.swing.text.html.parser.Parser.startTag(Unknown Source)
         at javax.swing.text.html.parser.Parser.parseTag(Unknown Source)
         at javax.swing.text.html.parser.Parser.parseContent(Unknown Source)
         at javax.swing.text.html.parser.Parser.parse(Unknown Source)
         at javax.swing.text.html.parser.DocumentParser.parse(Unknown Source)
         at javax.swing.text.html.parser.ParserDelegator.parse(Unknown Source)
         at javax.swing.text.html.HTMLEditorKit.read(Unknown Source)
         at javax.swing.text.DefaultEditorKit.read(Unknown Source)
         at HTMLMagician.openDocument(HTMLMagician.java:222)
         at HTMLMagician$4.actionPerformed(HTMLMagician.java:128)
         at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
         at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at javax.swing.JComponent.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Window.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    why? what's wrong? thanks

    The DocumentParser seems to throw a ChangedCharSetException if it finds a "http-equiv" meta tag for "content-type" or "charset" and if the parser's "ignoreCharSet" property is set to false on creation.

  • Exception problems utilizing javax.swing.UIManager

    I am in the process of creating a simple console environment for a certain application that runs in windows mainly but programmed in Java. Am trying to set the LookAndFeel to windows but it keeps throwing a java.lang.ClassNotFoundException_.
    try {
            javax.swing.UIManager.setLookAndFeel("com.sun.java.plat.windows.WindowsClassicLookAndFeel");
    } catch (Exception e) { System.err.println("Error: "+e); }After thinking I just simply didn't have the package installed correctly I wrote a simple app to check...
    public static void main(String[] args) {
         javax.swing.UIManager.LookAndFeelInfo[] info = javax.swing.UIManager.getInstalledLookAndFeels();
         for(int i=0; i<info.length;i++){
              String LFname = info.getName();
              String className = info[i].getClassName();
              System.out.println(LFname+" : "+className);
    }This gave me the output...Metal : javax.swing.plaf.metal.MetalLookAndFeel
    CDE/Motif : com.sun.java.swing.plaf.motif.MotifLookAndFeel
    Windows : com.sun.java.swing.plaf.windows.WindowsLookAndFeel
    Windows Classic : com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeelSo I can only assume that I have the the necessary resources installed correctly. Any thoughts on what might be causing my problem?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    So I can only assume that I have the the necessary resources installed correctly. Any thoughts on what might be causing my problem?
    com.sun.java.plat.windows.WindowsClassicLookAndFeel // the class you're trying to set
    com.sun.java.plaf.windows.WindowsClassicLookAndFeel // the class that is actually availableSee the difference?
    ~

  • Javax.swing.KeyStroke

    When i use Swing with PJ i get some errors about javax.swing.KeyStroke:
    java.lang.NoSuchFieldException
    at java.lang.Class.getField()
    at javax.swing.KeyStroke.getKeyStroke()
    at javax.swing.plaf.metal.MetalLookAndFeel.initComponentDefaults()
    at javax.swing.plaf.basic.BasicLookAndFeel.getDefaults()
    at javax.swing.plaf.metal.MetalLookAndFeel.getDefaults()
    at javax.swing.UIManager.setLookAndFeel()
    at javax.swing.UIManager.setLookAndFeel()
    at javax.swing.UIManager.initializeDefaultLAF()
    at javax.swing.UIManager.initialize()
    at javax.swing.UIManager.maybeInitialize()
    at javax.swing.UIManager.getUI()
    at javax.swing.JPanel.updateUI()
    at javax.swing.JPanel.<init>()
    at javax.swing.JPanel.<init>()
    at javax.swing.JRootPane.createGlassPane()
    at javax.swing.JRootPane.<init>()
    at javax.swing.JFrame.createRootPane()
    at javax.swing.JFrame.frameInit()
    at javax.swing.JFrame.<init>()
    java.lang.Error: Unrecognized keycode name: VK_KP_LEFT
    at javax.swing.KeyStroke.getKeyStroke()
    at javax.swing.plaf.metal.MetalLookAndFeel.initComponentDefaults()
    at javax.swing.plaf.basic.BasicLookAndFeel.getDefaults()
    at javax.swing.plaf.metal.MetalLookAndFeel.getDefaults()
    at javax.swing.UIManager.setLookAndFeel()
    at javax.swing.UIManager.setLookAndFeel()
    at javax.swing.UIManager.initializeDefaultLAF()
    at javax.swing.UIManager.initialize()
    at javax.swing.UIManager.maybeInitialize()
    at javax.swing.UIManager.getUI()
    at javax.swing.JPanel.updateUI()
    at javax.swing.JPanel.<init>()
    at javax.swing.JPanel.<init>()
    at javax.swing.JRootPane.createGlassPane()
    at javax.swing.JRootPane.<init>()
    at javax.swing.JFrame.createRootPane()
    at javax.swing.JFrame.frameInit()
    at javax.swing.JFrame.<init>()
    Could someone help me?

    Refer to the bug database (bugid = 4309057)
    http://developer.java.sun.com/developer/bugParade/bugs/4309057.html
    Here the workaround:
    Fix the problem yourself by changing SwingUtilites to test for "Class.getPackage" which is 1.2 specific and has not been introduced to pJava:
    Method m = Class.class.getMethod("getPackage", null);Re-Jar the swingclasses and enjoy your Swing application running on PersonalJava....
    Herbie

  • Question on code in swing?

    Hey guys, I'm really new to Java. I was working on a bit of code to simply put up an oval and a rectangle in swing/awt. I was wondering if you guys could explain the concept of getContentPane().add(new MyComp()); I really don't get it. I will give you guys the code, and in it I put comments where i dont get stuff. Also, another question is, is the Paint Method called implicitly at run time? How is paint called? Does AWT simply call it? Thanks guys, heres the code;
    import javax.swing.*;
    import java.awt.*;
    class Rect {
         public static void main(String[] args) {
              Rect draw = new Rect(); /*This simply instantiates the object, so that the constructor comes in, right? *\
         public Rect() {  //here we set up the constructor to make our window
              JFrame frame = new JFrame("Drawing with Alph!");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.getContentPane().add(new MyComp()); //What does get Contentpane() do? I know it's a method, but what's its use?
              frame.setSize(500, 500);
              frame.setVisible(true);
         public class MyComp extends JComponent { /*This is what I don't understand; the JComponent part. I understand the code block within it, however. *\ What does JComponent do?
              public void paint(Graphics mw) { /*Why is the Graphics class within the parameter here? Is this an object? Super confused on this *\
                   int length = 200;
                   int width = 130;
                   mw.setColor(Color.red);
                   mw.drawRect(20, 30, length, width);
                   mw.fillRect(20, 30, length, width);
                   mw.setColor(Color.red);
                   mw.drawOval(250, 100, length, width);
                   mw.setColor(Color.cyan);
                   mw.fillOval(249, 99, length, width);
    If you guys can help me out with those questions, I will be one of the happiest people ever. Thank you so much, and have a great day!

    another question is, is the Paint Method called implicitly at run time? How is paint called? Does AWT simply call it?I've already answered that question in a previous thread of yours. If you didn't understand, you should have said so in that thread, rather than just repeating yourself ad nauseam.
    You are just wasting your own time and that of other people by this piecemeal approach to learning, forum question by forum question, and I've already told you so in another prior thread. I cannot imagine anything more inefficient. I also recommended you to get a book, and to read the Java Language Tutorial. When you've done that, you should read the Java Swing Tutorial.
    Locking this thread.

  • Variable textArea not found in class javax.swing.JFrame...

    Making progress on this issue -- but still stuck. Again trying to get the text from a JTextArea on exit:
            frame.addWindowListener
           (new WindowAdapter() {
             public void windowClosing(WindowEvent e)
                System.out.println("Why me???" + frame.textArea.getText());
            });User MARSIAN helped me understand the scope fo the variables and now that has been fixed. Unfortunately I cannot access my variable textArea in the above code. If get this error:
    Error: variable textArea not found in class javax.swing.JFrame
    What am I doing wrong?
    import  java.net.*;
    import  javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import FragImpl.*;
    public class Framework extends WindowAdapter {
        public int numWindows = 0;
        private Point lastLocation = null;
        private int maxX = 500;
        private int maxY = 500;
        JFrame frame;
        public Framework() {
            newFrag();
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            maxX = screenSize.width - 50;
            maxY = screenSize.height - 50;
            makeNewWindow();
        public void makeNewWindow() {
            frame = new MyFrame(this);  //*
            numWindows++;
            System.out.println("Number of windows: " + numWindows);
            if (lastLocation != null) {
                //Move the window over and down 40 pixels.
                lastLocation.translate(40, 40);
                if ((lastLocation.x > maxX) || (lastLocation.y > maxY)) {
                    lastLocation.setLocation(0, 0);
                frame.setLocation(lastLocation);
            } else {
                lastLocation = frame.getLocation();
            System.out.println("Frame location: " + lastLocation);
            frame.setVisible(true);
            frame.addWindowListener
           (new WindowAdapter() {
             public void windowClosing(WindowEvent e)
                System.out.println("Why me???" + frame.textArea.getText());
        //This method must be evoked from the event-dispatching thread.
        public void quit(JFrame frame) {
            if (quitConfirmed(frame)) {
                System.exit(0);
            System.out.println("Quit operation not confirmed; staying alive.");
        private boolean quitConfirmed(JFrame frame) {
            String s1 = "Quit";
            String s2 = "Cancel";
            Object[] options = {s1, s2};
            int n = JOptionPane.showOptionDialog(frame,
                    "Windows are still open.\nDo you really want to quit?",
                    "Quit Confirmation",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE,
                    null,
                    options,
                    s1);
            if (n == JOptionPane.YES_OPTION) {
                return true;
            } else {
                return false;
         private void newFrag()
              Frag frag = new FragImpl();
        public static void main(String[] args) {
            Framework framework = new Framework();
    class MyFrame extends JFrame {
        protected Dimension defaultSize = new Dimension(200, 200);
        protected Framework framework = null;
        private Color color = Color.yellow;
        private Container c;
        JTextArea textArea;
        public MyFrame(Framework controller) {
            super("New Frame");
            framework = controller;
            setDefaultCloseOperation(DISPOSE_ON_CLOSE);
            setSize(defaultSize);
            //Create a text area.
            textArea = new JTextArea(
                    "This is an editable JTextArea " +
                    "that has been initialized with the setText method. " +
                    "A text area is a \"plain\" text component, " +
                    "which means that although it can display text " +
                    "in any font, all of the text is in the same font."
            textArea.setFont(new Font("Serif", Font.ITALIC, 16));
            textArea.setLineWrap(true);
            textArea.setWrapStyleWord(true);
            textArea.setBackground ( Color.yellow );
            JScrollPane areaScrollPane = new JScrollPane(textArea);
            //Create the status area.
            JPanel statusPane = new JPanel(new GridLayout(1, 1));
            ImageIcon icoOpen = null;
            URL url = null;
            try
                icoOpen = new ImageIcon("post_it0a.gif"); //("doc04d.gif");
            catch(Exception ex)
                ex.printStackTrace();
                System.exit(1);
            setIconImage(icoOpen.getImage());
            c = getContentPane();
            c.setBackground ( Color.yellow );
            c.add ( areaScrollPane, BorderLayout.CENTER )  ;
            c.add ( statusPane, BorderLayout.SOUTH );
            c.repaint ();
    }

    Yeah!!! It works. Turned out to be a combination of DrKlap's and Martisan's suggestions -- had to change var frame's declaration from JFrame to MyFrame:
        MyFrame frame;Next, created the external class -- but again changed JFrame references to MyFrame:
    public class ShowOnExit extends WindowAdapter {
    //   JFrame aFrame;
       MyFrame aFrame;
       public ShowOnExit(MyFrame f) {
          aFrame = f;
       public void windowClosing(WindowEvent e)
          System.out.println("Why me???" + aFrame.textArea.getText()); // aFrame here not frame !!!
    }This worked. So looks like even though the original code added a WindowListener to 'frame', the listener didn't couldn't access frame's methods unless it was explicitly passed in as a parameter. Let me know if that's wrong.
    Thanks again, all.

  • Import javax.swing problems

    hey
    I am new to java and have recently downloaded j2sdk1.4.2_04. I am trying to create a simple graphical application. However, It doesnt seem to import the javax.swing.* libraries. I understand that there is the src.zip in the directory, so I unzipped it but it still doesn't read the package. I read elsewhere on this forum that you should set the path to src.zip. I have tried that and it also doesnt work. My current path is:
    PATH=C:\j2sdk1.4.2_04\lib\src.zip;C:\j2sdk1.4.2_04\bin
    Is there an error in this, or what else should I try? All suggestions greatly appreciated.

    There's no need to set your classpath when importing any of the standard packages that are provided by the JDK. Perhaps you could post a (small) code sample and the compiler error you are getting.

  • Import javax.swing.* error

    Heya. I decided to learn java and i've been doing the tutorials, recently i started the swing tutorials and the learn by example page. However, whenever I try to import javax.swing.* it gives me an error. SO you know, i am using the J2SDK 1.4.2 and netbeans IDE 5.0. Here's the error text and what i type.
    import javax.swing.* ;
    the error is:
    illegal start of expression and then sometimes i get <identifier> expected.
    can anyone help me?

    To update. I figured out how to do this with a blank start file in netbeans, however it's awful to have to delete main and then make a new class file. So, is there anyway to get a blank template project or to import javax.swing.* without having to delete main and start with a blank file? SO, i guess my question has changed, but it's still about an import javax.swing.* error.
    thanks.

  • NullPointerException  at javax.help.plaf.basic.BasicTOCNavigatorUI.reloadDa

    I tried to call a JavaHelp file from my JavaWebStart application.
    My class and the .hs,.jhm,.xml files are in the directory as shown below
    /HelpDocAppClass/docs/
    Help.hs
    mapl.jhm
    MyHelpTOC.xml
    HelpIndex.xml
    My code is as follows.
    ClassLoader loader =getClass().getClassLoader();
    hs = (HelpSet)Class.forName("javax.help.HelpSet").newInstance();
    if(hs != null)
    URL url = HelpSet.findHelpSet(loader, "docs/Help.hs");
    if(url != null)
    hs = new HelpSet(null, url);
    bs = hs.createHelpBroker();
    While running the above code, i got the following exception. Please help me to get around this problem.
    Java.lang.NullPointerException
         at javax.help.plaf.basic.BasicTOCNavigatorUI.reloadData(BasicTOCNavigatorUI.java:185)
         at javax.help.plaf.basic.BasicTOCNavigatorUI.installUI(BasicTOCNavigatorUI.java:105)
         at javax.swing.JComponent.setUI(JComponent.java:449)
         at javax.help.JHelpNavigator.setUI(JHelpNavigator.java:231)
         at javax.help.JHelpNavigator.updateUI(JHelpNavigator.java:250)
         at javax.help.JHelpNavigator.<init>(JHelpNavigator.java:97)
         at javax.help.JHelpTOCNavigator.<init>(JHelpTOCNavigator.java:60)
         at javax.help.TOCView.createNavigator(TOCView.java:91)
         at javax.help.JHelp.setupNavigators(JHelp.java:113)
         at javax.help.JHelp.<init>(JHelp.java:91)
         at javax.help.JHelp.<init>(JHelp.java:63)
         at javax.help.DefaultHelpBroker.createJHelp(DefaultHelpBroker.java:733)
         at javax.help.DefaultHelpBroker.createHelpWindow(DefaultHelpBroker.java:752)
         at javax.help.DefaultHelpBroker.setDisplayed(DefaultHelpBroker.java:231)
         at com.sodexho.doc.HelpDoc.show(HelpDoc.java:87)

    Hi,
    hard to tell from your example. Possibly the help set is not found, possibly the help set itself has a problem.
    The error occurs at com.sodexho.doc.HelpDoc.show(HelpDoc.java:87)
    How does method show in class HelpDoc look and what is on line 87 of that method?
    Ulrich

Maybe you are looking for

  • Value in input field of Hier.Node variable displays tech.name of the IO

    Dear all, we are facing an issue with Hierarchy node variable(auth.) in the selection screen of webReports. After selecting a hierarchy node value,it is displayed along with + sign and tech.name of the Infobject in input field . example: lets say we

  • Usage of ALE - idocs generated for BAPIs

    Hi   I need to use - the std idocs generated for BUS2032 object - CREATEFROMDAT2 method to store the BAPI call  ( BAPI_SALESORDER_CREATEFROMDAT2 )data for those sales orders that could not be created. If I want to use the SAP delivered BAPI ( BAPI_SA

  • Lookup server address

    I enter the vCenter Server's IP address into the Lookup service address:  https://10.10.15.40:7444 It re displays as https://10.10.15.40:7444/lookupservice/sdk When I click Show Details I get this: Certificate details Issued to Common Name vCenter51.

  • Apple keyboard with numberpad problem

    I have been using the usb keyboard (http://liss-mug.org.uk/sites/default/files/images/apple-qwerty_red_570.png) for my macbook pro for around 10-11 months and today keys 0 p P ; / are not working (but using the macbook pro keyboard is fine). I want t

  • Playback on 32rv600a

    Hi can anyone help I am trying to play AVI files from a external HD through USB on this tv without success any help would be appreciated I can play them okay through my PC.