Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6352243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:09:58+00:00 2026-05-24T22:09:58+00:00

I get this Random Jni error, sometimes the codes works, sometimes it doesn’t import

  • 0

I get this Random Jni error, sometimes the codes works, sometimes it doesn’t

    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.GraphicsEnvironment;

    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTextPane;
    import javax.swing.text.BadLocationException;
    import javax.swing.text.MutableAttributeSet;
    import javax.swing.text.StyleConstants;
    import javax.swing.text.StyledDocument;

    public class Fonts {
        public static void main(String[] args) {
            Fonts fs = new Fonts();
            try {
                fs.initialize();
            } catch (Exception e) {
                e.printStackTrace();
            }
            fs.frm.setVisible(true);
        }

        private String[] fnt;
        private JFrame frm;
        private JScrollPane jsp;
        private JTextPane jta;
        private int width = 450;
        private int height = 300;
        private GraphicsEnvironment ge = GraphicsEnvironment
                .getLocalGraphicsEnvironment();
        private Font[] fnts;
        private StyledDocument doc;
        private MutableAttributeSet mas;
        // private String[] fams;

        private int cp = 0;

        public Fonts() {
        }

        public void dis(String s) {
            try {
                doc.insertString(cp, s, mas);
                doc.insertString(cp, "\n", mas);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        public void initialize() throws BadLocationException {
            frm = new JFrame("awesome");
            frm.setMinimumSize(new Dimension(width, height));
            frm.setBounds(100, 100, width, height);
            frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frm.getContentPane().setLayout(new BorderLayout());

            fnts = ge.getAllFonts();
            jta = new JTextPane();
            doc = jta.getStyledDocument();

            jsp = new JScrollPane(jta);
            frm.getContentPane().add(jsp, BorderLayout.CENTER);

            frm.pack();

            fnt = ge.getAvailableFontFamilyNames();

            mas = jta.getInputAttributes();
            for (int i = 0; i < fnt.length; i++) {
                StyleConstants.setBold(mas, false);
                StyleConstants.setItalic(mas, false);
                StyleConstants.setFontFamily(mas, fnt[i]);
                StyleConstants.setFontSize(mas, 16);
                dis(fnt[i]);
                StyleConstants.setBold(mas, true);
                dis(fnt[i] + " Bold");
                StyleConstants.setItalic(mas, true);
                dis(fnt[i] + " Bold & Italic");
                StyleConstants.setBold(mas, false);
                dis(fnt[i] + " Italic");
            }
        }

    }

And here is the error I get.

    #
    # A fatal error has been detected by the Java Runtime Environment:
    #
    #  SIGSEGV (0xb) at pc=0xb3fdad10, pid=20482, tid=3066784624
    #
    # JRE version: 6.0_26-b03
    # Java VM: Java HotSpot(TM) Client VM (20.1-b02 mixed mode, sharing linux-x86 )
    # Problematic frame:
    # C  [libfontmanager.so+0x2ed10]  float+0x40
    #
    # An error report file with more information is saved as:
    # /home/alex/repos/java-alex.fonts/bin/hs_err_pid20482.log
    #
    # If you would like to submit a bug report, please visit:
    #   http://java.sun.com/webapps/bugreport/crash.jsp
    # The crash happened outside the Java Virtual Machine in native code.
    # See problematic frame for where to report the bug.
    #
    Aborted
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:09:59+00:00Added an answer on May 24, 2026 at 10:09 pm

    added importans / standard Swing rulles

    • changed main method

    • moved all methods for JFrame from the toop to the end of methods,

    • set PrefferedSize to the JScrollPane

    then for example

    import java.awt.*;
    import javax.swing.*;
    import javax.swing.text.*;
    
    public class Fonts {
    
        private String[] fnt;
        private JFrame frm;
        private JScrollPane jsp;
        private JTextPane jta;
        private int width = 450;
        private int height = 300;
        private GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        private Font[] fnts;
        private StyledDocument doc;
        private MutableAttributeSet mas;
        // private String[] fams;
        private int cp = 0;
    
        public Fonts() {
            jta = new JTextPane();
            doc = jta.getStyledDocument();
            jsp = new JScrollPane(jta);
            jsp.setPreferredSize(new Dimension(height, width));
            fnt = ge.getAvailableFontFamilyNames();
            mas = jta.getInputAttributes();
            for (int i = 0; i < fnt.length; i++) {
                StyleConstants.setBold(mas, false);
                StyleConstants.setItalic(mas, false);
                StyleConstants.setFontFamily(mas, fnt[i]);
                StyleConstants.setFontSize(mas, 16);
                dis(fnt[i]);
                StyleConstants.setBold(mas, true);
                dis(fnt[i] + " Bold");
                StyleConstants.setItalic(mas, true);
                dis(fnt[i] + " Bold & Italic");
                StyleConstants.setBold(mas, false);
                dis(fnt[i] + " Italic");
            }
            frm = new JFrame("awesome");
            frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frm.setLayout(new BorderLayout());
            frm.add(jsp, BorderLayout.CENTER);
            frm.setLocation(100, 100);
            frm.pack();
            frm.setVisible(true);
        }
    
        private void dis(String s) {
            try {
                doc.insertString(cp, s, mas);
                doc.insertString(cp, "\n", mas);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
    
                @Override
                public void run() {
                    Fonts fs = new Fonts();
                }
            });
        }
    }
    
    • you have to change logics for adding Font to the JTextPane, there are wrong order from Z - > A (just my helicopter view)

    EDIT: and changed access/visibily (@ by attn trashgod)

    from

    public void dis(String s) {...
    

    to

    private void dis(String s) {...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this random error when I run my app on my iPhone. First,
i get this error in intellij-idea 9 . package cern.jet.random does not exist what
I wrote this function to get a pseudo random float between 0 .. 1
Following up on this question, I need to get exactly n lines at random
I've struggled with this all day, I am trying to get a random number
I get this error: Can't locate Foo.pm in @INC Is there an easier way
I get this error on an update panel within a popupControlExtender which is within
I get this error when I do an svn update : Working copy XXXXXXXX
I get this error:- You have an error in your SQL syntax; check the
We get this error in Visual Studio 2005 and TFS very often. Can anyone

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.