Adding java 2d graphices to a JScrollPane

How can I use the graphics 2d in a Java Applet JScrollPane?
here is me code. I have a a ImageOps.java file that does a bunch of Java 2d, but I need it to fit into my applet's JScrollPane. Can anyone help me?
package louis.tutorial;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JApplet;
import java.awt.Dimension;
import javax.swing.JInternalFrame;
import javax.swing.JButton;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.Rectangle;
import java.awt.Point;
import javax.swing.JComboBox;
import javax.swing.JList;
import javax.swing.JTextArea;
import javax.imageio.ImageIO;
import javax.swing.Icon;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.ImageIcon;
import javax.swing.KeyStroke;
import java.awt.FileDialog;
import java.awt.Toolkit;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import javax.swing.JScrollPane;
* Place class description here
* @version 1.0
* @author llakser
public class ImageApplet extends JApplet {
private JPanel jContentPane = null;
private JPanel jpLower = null;
private JButton JBFirst = null;
private JButton JBPrevious = null;
private JButton JBNext = null;
private JButton JBLast = null;
private JButton JBZoonIn = null;
private JButton JBZoomOut = null;
private JButton JBAnimate = null;
private JButton JBPause = null;
private JButton JBAutoRepeat = null;
private JComboBox jcbFrameDelay = null;
private BufferedImage image; // the rasterized image
private Image[] numbers = new Image[10];
private Thread animate;
private MediaTracker tracker;
private int frame = 0;
private ImageIcon[] icon = null;
private JFrame f = new JFrame("ImageOps");
* This is the xxx default constructor
public ImageApplet() {
     super();
* This method initializes this
* @return void
public void init() {
     this.setSize(600, 600);
     this.setContentPane(getJContentPane());
     this.setName("");
     this.setMinimumSize(new Dimension(600, 600));
     this.setPreferredSize(new Dimension(600, 600));
// f.addWindowListener(new WindowAdapter() {
// public void windowClosing(WindowEvent e) {System.exit(0);}
ImageOps applet = new ImageOps();
//getJContentPane().add("Center", f);
getJContentPane().add("Center", applet);
//applet.add(f);
applet.init();
f.pack();
f.setSize(new Dimension(550,550));
f.setVisible(true);
public void load() {
     tracker = new MediaTracker(this);
     for (int i = 1; i < 10; i++) {
     numbers[i] = getImage (getCodeBase (), i+".jpeg");//getImage(getDocumentBase(), "Res/" + i + ".gif");
     //Image img;
     //ico[i] = new ImageIcon(getCodeBase (), i+".jpeg");
     /* if (fInBrowser)
     img = getImage (getCodeBase (), "1.jpeg");
     else
     img = Toolkit.getDefaultToolkit ().getImage (
     "1.jpeg");*/
     tracker.addImage(numbers, i);
     try {
     tracker.waitForAll();
     } catch (InterruptedException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
     int i = 1;
     // for (int i = 1; i < 10; i++)
          icon[0] = new ImageIcon ("C:/images2/1.jpeg");//getImage(getDocumentBase(), "Res/" + i + ".gif");
          //icon[0] = new ImageIcon("C:/images2/1.jpg");
          //System.out.println("Made it after icon " + ico.toString());
          //ImageIcon ii = new ImageIcon("1.jpg");
          //jLabel = new JLabel(icon);
          //jLabel.setText("JLabel");
          //jLabel.setIcon(icon[0]);
     Graphics g = null;
          //g.drawImage(numbers[1],0,0,1500,1400,jScrollPane);
     //ImageIcon ii = new ImageIcon(numbers[2]);
     //this.jScrollPane.add(new JLabel(ii));// = new JScrollPane(new JLabel(ii));
     // System.out.println("Gee I made it..");
          //scroll.paintComponents(g);
          //paintComponents(g);
public void paintComponents(Graphics g) {
super.paintComponents(g);
// Retrieve the graphics context; this object is used to paint shapes
Graphics2D g2d = (Graphics2D)g;
// Draw an oval that fills the window
int width = this.getBounds().width;
int height = this.getBounds().height;
Icon icon = new ImageIcon("C:/images2/1.jpg");
//jLabel.setIcon(icon);
//g2d.drawImage(0,0,1500,1400);
g2d.drawOval(10,20, 300,400);
// and Draw a diagonal line that fills MyPanel
g2d.drawLine(0,0,width,height);
* This method initializes jContentPane
* @return javax.swing.JPanel
private JPanel getJContentPane() {
     if (jContentPane == null) {
     jContentPane = new JPanel();
     jContentPane.setLayout(new BorderLayout());
     jContentPane.setPreferredSize(new Dimension(768, 576));
     jContentPane.setMinimumSize(new Dimension(768, 576));
     jContentPane.setName("");
     jContentPane.add(getJpLower(), BorderLayout.SOUTH);
     return jContentPane;
* This method initializes jpLower     
* @return javax.swing.JPanel     
private JPanel getJpLower() {
if (jpLower == null) {
     try {
     jpLower = new JPanel();
     jpLower.setLayout(null);
     jpLower.setPreferredSize(new Dimension(500, 100));
     jpLower.setMinimumSize(new Dimension(500, 160));
     jpLower.add(getJBFirst(), null);
     jpLower.add(getJBPrevious(), null);
     jpLower.add(getJBNext(), null);
     jpLower.add(getJBLast(), null);
     jpLower.add(getJBZoonIn(), null);
     jpLower.add(getJBZoomOut(), null);
     jpLower.add(getJBAnimate(), null);
     jpLower.add(getJBPause(), null);
     jpLower.add(getJBAutoRepeat(), null);
     jpLower.add(getJcbFrameDelay(), null);
     } catch (java.lang.Throwable e) {
     // TODO: Something
return jpLower;
* This method initializes JBFirst     
* @return javax.swing.JButton     
private JButton getJBFirst() {
if (JBFirst == null) {
     try {
     JBFirst = new JButton();
     JBFirst.setText("First");
     JBFirst.setLocation(new Point(7, 7));
     JBFirst.setSize(new Dimension(59, 26));
     JBFirst.addActionListener(new java.awt.event.ActionListener() {
     public void actionPerformed(java.awt.event.ActionEvent e) {
          System.out.println("First Button Clicked()");
     load();
          // TODO Auto-generated Event stub actionPerformed()
     } catch (java.lang.Throwable e) {
     // TODO: Something
return JBFirst;
* This method initializes JBPrevious     
* @return javax.swing.JButton     
private JButton getJBPrevious() {
if (JBPrevious == null) {
     try {
     JBPrevious = new JButton();
     JBPrevious.setText("Previous");
     JBPrevious.setLocation(new Point(69, 7));
     JBPrevious.setSize(new Dimension(94, 26));
     } catch (java.lang.Throwable e) {
     // TODO: Something
return JBPrevious;
* This method initializes JBNext     
* @return javax.swing.JButton     
private JButton getJBNext() {
if (JBNext == null) {
     try {
     JBNext = new JButton();
     JBNext.setText("Next");
     JBNext.setLocation(new Point(166, 7));
     JBNext.setSize(new Dimension(66, 26));
     } catch (java.lang.Throwable e) {
     // TODO: Something
return JBNext;
* This method initializes JBLast     
* @return javax.swing.JButton     
private JButton getJBLast() {
if (JBLast == null) {
     try {
     JBLast = new JButton();
     JBLast.setText("Last");
     JBLast.setLocation(new Point(235, 7));
     JBLast.setSize(new Dimension(59, 26));
     } catch (java.lang.Throwable e) {
     // TODO: Something
return JBLast;
* This method initializes JBZoonIn     
* @return javax.swing.JButton     
private JButton getJBZoonIn() {
if (JBZoonIn == null) {
     try {
     JBZoonIn = new JButton();
     JBZoonIn.setText("Zoom In");
     JBZoonIn.setLocation(new Point(408, 7));
     JBZoonIn.setPreferredSize(new Dimension(90, 26));
     JBZoonIn.setSize(new Dimension(90, 26));
     } catch (java.lang.Throwable e) {
     // TODO: Something
return JBZoonIn;
* This method initializes JBZoomOut     
* @return javax.swing.JButton     
private JButton getJBZoomOut() {
if (JBZoomOut == null) {
     try {
     JBZoomOut = new JButton();
     JBZoomOut.setBounds(new Rectangle(503, 7, 90, 26));
     JBZoomOut.setPreferredSize(new Dimension(90, 26));
     JBZoomOut.setText("Zoom Out");
     } catch (java.lang.Throwable e) {
     // TODO: Something
return JBZoomOut;
* This method initializes JBAnimate     
* @return javax.swing.JButton     
private JButton getJBAnimate() {
if (JBAnimate == null) {
     try {
     JBAnimate = new JButton();
     JBAnimate.setText("Animate");
     JBAnimate.setSize(new Dimension(90, 26));
     JBAnimate.setPreferredSize(new Dimension(90, 26));
     JBAnimate.setLocation(new Point(408, 36));
     } catch (java.lang.Throwable e) {
     // TODO: Something
return JBAnimate;
* This method initializes JBPause     
* @return javax.swing.JButton     
private JButton getJBPause() {
if (JBPause == null) {
     try {
     JBPause = new JButton();
     JBPause.setPreferredSize(new Dimension(90, 26));
     JBPause.setLocation(new Point(503, 36));
     JBPause.setSize(new Dimension(90, 26));
     JBPause.setText("Pause");
     } catch (java.lang.Throwable e) {
     // TODO: Something
return JBPause;
* This method initializes JBAutoRepeat     
* @return javax.swing.JButton     
private JButton getJBAutoRepeat() {
if (JBAutoRepeat == null) {
     try {
     JBAutoRepeat = new JButton();
     JBAutoRepeat.setBounds(new Rectangle(446, 65, 106, 26));
     JBAutoRepeat.setText("Auto Repeat");
     } catch (java.lang.Throwable e) {
     // TODO: Something
return JBAutoRepeat;
* This method initializes jcbFrameDelay     
* @return javax.swing.JComboBox     
private JComboBox getJcbFrameDelay() {
if (jcbFrameDelay == null) {
     try {
     jcbFrameDelay = new JComboBox();
     jcbFrameDelay.setSize(new Dimension(156, 25));
     jcbFrameDelay.setName("Frame Delay");
     jcbFrameDelay.setLocation(new Point(7, 35));
     } catch (java.lang.Throwable e) {
     // TODO: Something
return jcbFrameDelay;
} // @jve:decl-index=0:visual-constraint="10,10"

I think you've got it:
public class ImageComponent extends JPanel { //or JComponent
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        //do your rendering here
}The fact that ImageComponent sits inside JScrollPane is accidental, right?
It should be able to function on its own, without a JScrollPane present, just as JTextArea can.
So I'm not sure what your question is. Can you post a small (<1 page)
example program demonstrating your problem.
For example, here are a very few lines demonstrating what I am trying to say:
import java.awt.*;
import javax.swing.*;
class CustomExample extends JPanel {
    public CustomExample() {
        setPreferredSize(new Dimension(800,800));
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.fillOval(0, 0, getWidth(), getHeight());
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable(){
            public void run() {
                JFrame f = new JFrame("CustomExample");
                f.getContentPane().add(new JScrollPane(new CustomExample()));
                f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                f.setSize(400,400);
                f.setLocationRelativeTo(null);
                f.setVisible(true);
}Now you post your problem in a program that is just as short.

Similar Messages

  • JAVA Drawing Graphics Save as JPEG?

    My problem is this, I am trying to save my g2 graphic image to a jpg. This is how I have things setup, I will show code and my thoughts. What I need is help to figure out how I could save seperate .java files graphics g to the jpg format from a JFileChooser in a different .java file.
    HERE IS THE CODE FOR HOW GRAPH IS CREATED. graph.java
    I have a graph I am drawing in a seperate .java file and it is created like this:
    public class graph extends JPanel {
        public static Graphics2D g2;
        final int HPAD = 60, VPAD = 40;
        int[] data;
        Font font;
        public test() {
            data = new int[] {120, 190, 211, 75, 30, 290, 182, 65, 85, 120, 100, 101};
            font = new Font("lucida sans regular", Font.PLAIN, 8);       
            setBackground(Color.white);
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setFont(font);
            FontRenderContext frc = g2.getFontRenderContext();
            int w = getWidth();
            int h = getHeight();
            // scales
            float xInc = (w - HPAD - HPAD) / 10f;
            float yInc = (h - 2*VPAD) / 10f;
            int[] dataVals = getDataVals();
            float yScale = dataVals[2] / 10f;
    //        etc... (the rest is just drawing...blah...blah)
    }HERE IS THE CODE FOR HOW MY GRAPH IS DISPLAYED AND TRYING TO BE SAVED. results.java
    The graph I created is then displayed in a JPanel and there is a button in the results window to save the graph results. This is where I am having difficulty as I am trying to save the g2 from graph.java (declared public static...not sure if this a good idea) but anyway I want to save this as a jpg heres the code:
            resultPanel = new JPanel(new PercentLayout());
            graph drawing = new graph();
            resultPanel.add (
                drawing,
                new PercentLayout.Constraint(1,41,49,50));
            resultPanel.add (
                saveButton1,
                new PercentLayout.Constraint(1,94,25,5));
        public void actionPerformed(ActionEvent e) {
            if(e.getSource() == saveButton1) {
                doSaveGraph();
        public void doSaveGraph() {
            JFileChooser fileSaver;
            fileSaver = new JFileChooser(); // The file-opening dialog
            ExampleFileFilter filter = new ExampleFileFilter("jpg");
            filter.setDescription("JPEG Picture File");
            fileSaver.addChoosableFileFilter(filter);
            try {
                if(fileSaver.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
                    File f = fileSaver.getSelectedFile();
                    BufferedImage img = new BufferedImage(672,600, BufferedImage.TYPE_INT_RGB);
          // SOMEWHERE IN HERE IS WHERE I NEED TO GRAB G2?  I AM NOT SURE WHAT TO DO HERE
                    //Graphics g = img.getGraphics();
                    //panel.paint(g);
                    BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(f));
                    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
                    JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(img);
                    param.setQuality(1f, true);
                    encoder.setJPEGEncodeParam(param);
                    encoder.encode(img);
                    System.out.println("It worked");
                else{}
            catch (Exception e) {
                e.printStackTrace();
    ...If you can help me I will be very happy, and give you 10 dukes! LOL and I appreciate the help!

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.font.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    public class SavingGraphics
        public static void main(String[] args)
            GraphicsCreationPanel graphicsPanel = new GraphicsCreationPanel();
            GraphicsSaver saver = new GraphicsSaver(graphicsPanel);
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(saver.getUIPanel(), "North");
            f.getContentPane().add(graphicsPanel);
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
    class GraphicsCreationPanel extends JPanel
        String text;
        Font font;
        public GraphicsCreationPanel()
            text = "hello world";
            font = new Font("lucida bright regular", Font.PLAIN, 36);
            setBackground(Color.white);
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            int w = getWidth();
            int h = getHeight();
            g2.setPaint(Color.blue);
            g2.draw(new Rectangle2D.Double(w/16, h/16, w*7/8, h*7/8));
            g2.setPaint(Color.orange);
            g2.fill(new Ellipse2D.Double(w/12, h/12, w*5/6, h*5/6));
            g2.setPaint(Color.red);
            g2.fill(new Ellipse2D.Double(w/6, h/6, w*2/3, h*2/3));
            g2.setPaint(Color.black);
            g2.setFont(font);
            FontRenderContext frc = g2.getFontRenderContext();
            LineMetrics lm = font.getLineMetrics(text, frc);
            float textWidth = (float)font.getStringBounds(text, frc).getWidth();
            float x = (w - textWidth)/2;
            float y = (h + lm.getHeight())/2 - lm.getDescent();
            g2.drawString(text, x, y);
    class GraphicsSaver
        GraphicsCreationPanel graphicsPanel;
        JFileChooser fileChooser;
        public GraphicsSaver(GraphicsCreationPanel gcp)
            graphicsPanel = gcp;
            fileChooser = new JFileChooser(".");
        private void save()
            if(fileChooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION)
                File file = fileChooser.getSelectedFile();
                String ext = file.getPath().substring(file.getPath().indexOf(".") + 1);
                BufferedImage image = getImage();
                try
                    ImageIO.write(image, ext, file);
                catch(IOException ioe)
                    System.out.println("write: " + ioe.getMessage());
        private BufferedImage getImage()
            int w = graphicsPanel.getWidth();
            int h = graphicsPanel.getHeight();
            BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
            Graphics2D g2 = bi.createGraphics();
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            graphicsPanel.paint(g2);
            g2.dispose();
            return bi;
        public JPanel getUIPanel()
            JButton save = new JButton("save");
            save.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    save();
            JPanel panel = new JPanel();
            panel.add(save);
            return panel;
    }

  • When to Use XSLT,Java or Graphical Mapping

    Hi Friends,
       Could any one please give me a clear picture on when to use Java/XSLT/Graphical Mappings. Which mapping should be used in which case.
    Regards,
    Shyam

    Hi
       Plz check the below links for your answer..
    Java Mapping : http://help.sap.com/saphelp_nw04/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/content.htm
    XSLT mapping : http://help.sap.com/saphelp_nw04/helpdata/en/73/f61eea1741453eb8f794e150067930/content.htm
    Message mapping:
    http://help.sap.com/saphelp_nw04/helpdata/en/ee/bf9640dc522f28e10000000a1550b0/content.htm
    Regards
    Su

  • Adding image to graphic

    Hi,
    I am trying to add an image instead of a red square to the Performing custom painting demo.
    http://java.sun.com/docs/books/tutorial/uiswing/painting/refining.html
    I have loaded the image into the class, but can't work out how to display it in the graphic.
    It is probably something simple (I hope). Any pointers will be greatly appreciated.
    Attached is the code to the class.
    class NorthPoint{
    private int xPos = 150;
    private int yPos = 200;
    private int width = 100;
    private int height = 100;
    public static void main(String[] args) throws IOException
    // load north point image
    BufferedImage img = ImageIO.read(new File("NorthPoint100.png"));
    Icon icon = new ImageIcon(img);
    JComponent nthPnt = new JLabel(icon);
    public void setX(int xPos){
    this.xPos = xPos;
    public int getX(){
    return xPos;
    public void setY(int yPos){
    this.yPos = yPos;
    public int getY(){
    return yPos;
    public int getWidth(){
    return width;
    public int getHeight(){
    return height;
    public void paintNorth(Graphics g){
    // g.setColor(Color.BLUE);
    // g.fillRect(xPos,yPos,width,height);
    g.setColor(Color.BLACK);
    g.drawRect(xPos,yPos,width,height);

    Use the drawImage method in Graphics. [http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Graphics.html]

  • Cannot resolve symbol java.awt.graphics

    // DrawRectangleDemo.java
    import java.awt.*;
    import java.lang.Object;
    import java.applet.Applet;
    public class DrawRectangleDemo extends Applet
         public void paint (Graphics g)
              // Get the height and width of the applet's drawing surface.
              int width = getSize ().width;
              int height = getSize ().height;
              int rectWidth = (width-50)/3;
              int rectHeight = (height-70)/2;
              int x = 5;
              int y = 5;
              g.drawRect (x, y, rectWidth, rectHeight);
              g.drawString ("drawRect", x, rectHeight + 30);
              x += rectWidth + 20;
              g.fillRect (x, y, rectWidth, rectHeight);
              // Calculate a border area with each side equal tp 25% of
              // the rectangle's width.
              int border = (int) (rectWidth * 0.25);
              // Clear 50% of the filled rectangle.
              g.clearRect (x + border, y + border,
                             rectWidth - 2 * border, rectHeight - 2 * border);
              g.drawString ("fillRect/clearRect", x, rectHeight + 30);
              x += rectWidth + 20;
              g.drawRoundRect (x, y, rectWidth, rectHeight, 15, 15);
              g.drawString ("drawRoundRect", x, rectHeight + 30);
              x=5;
              y += rectHeight + 40;
              g.setColor (Color.yellow);
              for (int i = 0; i < 4; i++)
                   g.draw3DRect (x + i * 2, y + i * 2,
                                       rectWidth - i * 4, rectHeight - i * 4, false);
              g.setColor (Color.black);
              g.drawString ("draw3DRect", x, y, + rectHeight + 25);
              x += rectWidth + 20;
              g.setColor (Color.yellow);
              g.fill3DRect (x, y, rectWidth, rectHeight, true);
              g.setColor (Color.black);
              g.drawString ("fill3DRect", x, y, + rectHeight + 25);
    Help me with this codes. I typed correctly but there still errors.
    --------------------Configuration: JDK version 1.3.1 <Default>--------------------
    D:\Program Files\Xinox Software\JCreator LE\MyProjects\DrawRectangleDemo.java:56: cannot resolve symbol
    symbol : method drawString (java.lang.String,int,int,int)
    location: class java.awt.Graphics
              g.drawString ("draw3DRect", x, y, + rectHeight + 25);
    ^
    D:\Program Files\Xinox Software\JCreator LE\MyProjects\DrawRectangleDemo.java:64: cannot resolve symbol
    symbol : method drawString (java.lang.String,int,int,int)
    location: class java.awt.Graphics
              g.drawString ("fill3DRect", x, y, + rectHeight + 25);
    ^
    2 errors
    Process completed.
    -------------------------------------------------------------------------------------------------------------------------------

    cannot resolve symbol
    symbol : method drawString (java.lang.String,int,int,int)
    This is telling you that you are trying to invoke the drawString() method with 4 parameters: String, int, int, int
    If you look at the API the drawString() method need 3 parameters: String, int, int - so you have an extra int
    location: class java.awt.Graphics
    g.drawString ("draw3DRect", x, y, + rectHeight + 25);
    Now is you look at your code you will find that you have 3 ',' in you method call. (I don't think you want the ',' after the y.

  • Adding Java Fact Classes not erroring, but not adding the facts/classes

    I'm attempting to build Rule dictionaries modeled after maven modules of the project I'm working on. First I created a dictionary "common" with common classes added as Java facts. Second I created a dictionary "domain". In the "domain" dictionary I linked the "common" dictionary and added some domain specific classes as java facts. Finally I created a "product" dictionary. The product dictionary links the "domain" dictionary. When I look at the facts in the "product" dictionary I see all the facts from "common" and "domain" linked in. When I attempt to add more facts to the "product" dictionary I can find the classes in the classpath without a problem. However when I select the classes I wanted added as java facts and click "OK" in JDevelopers 'Create Java Fact' Dialog none of the facts are added. I cannot find any error or explanation for why they were not added. I believe I have all class dependencies of these java facts already added in the "common" and "domain" dictionaries I have linked in. Any help in how to resolve this would be appreciated - or even some general guidelines on how to build and maintain dictionaries.
    Thanks,
    Mike

    Hello, I seem to have the same problem as you. Have you found a solution to this?
    See my thread here: Oracle Rules: Adding Java Facts - not showing up in list.

  • CDR-17066 RON cannot find java EWT graphics classes

    Hello,
    I am evaluating Oracle SCM. Everything's going great, except I am unable to use the Version History or Version Events. When I try, I get an error:
    "CDR-17066: RON cannot find java EWT graphics classes"
    The action it recommends is to check the registry or environment variable JVM_CLASSPATH_RON, and make sure it points to the ewt jar.
    I found a jar called ewt3.jar in my oracle/jlib directory. There was no environmental variable called JVM_CLASSPATH_RON, so I created one and set it to that jar. But I'm still getting the same error.
    Any help would be appreciated. Thank you.

    Hi,
    this error message is rather strange: I checked in our knwoledge base, but you seem to be the first one having this issue!
    I had a look to my registry and indeed I couldn't find the variable JVM_CLASSPATH_RON.
    I suspect that this variable was superseded by another one (JVM_CLASSPATH_DEFAULT_THIN_JDBC ?).
    I checked for all variables including ewt and found the following:
    . FORMS90_CLASSPATH (<Home>\jlib\ewt3.jar)
    . FORMS90_BUILDER_CLASSPATH (<Home>\jlib\ewt3.jar)
    . JVM_CLASSPATH_DEFAULT_THIN_JDBC (<Home>\jlib\ewt4.jar)
    FORMS90_... variables are not used by the Version History and Version Event Viewers, but JVM_CLASSPATH_DEFAULT_THIN_JDBC is.
    I removed the entry <Home>\jlib\ewt4.jar from JVM_CLASSPATH_DEFAULT_THIN_JDBC, and then I could reproduce your issue.
    So could you check the content of this variable JVM_CLASSPATH_DEFAULT_THIN_JDBC?
    It's located in HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\HOMEx\REPADM61\DEFAULT_JVM_PARAMS_THIN_JDBC
    Could you also check that file <Home>\jlib\ewt4.jar does exist on your machine?
    Regards,
    Didier.

  • Adding colour and graphics to a j2me form

    hi guys im trying to find info abt adding colour and graphics to a j2me form if anyone can help with any suggested links or info that would be great help thanks .

    [http://developers.sun.com/mobility/apis/articles/3dgraphics/]

  • Java 2D graphics help

    Hi, i need 2 files, Index class file(JFrame) and a Draw.class file
    Basically, i have a button in the index jframe form, and when i clicked on the button, there will be a JPanel/ Applet pop up, with a circle in it. can any1 write me some sample codes? a simple one will do. Thanks

    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.BasicStroke;
    import java.awt.GradientPaint;
    import java.awt.TexturePaint;
    import java.awt.Rectangle;
    import java.awt.Graphics2D;
    import java.awt.geom.Ellipse2D;
    import java.awt.geom.Rectangle2D;
    import java.awt.geom.RoundRectangle2D;
    import java.awt.geom.Arc2D;
    import java.awt.geom.Line2D;
    import java.awt.image.BufferedImage;
    import javax.swing.JPanel;
    public class ShapesJPanel extends JPanel
       // draw shapes with Java 2D API
       public void paintComponent( Graphics g )
          super.paintComponent( g ); // call superclass's paintComponent
          Graphics2D g2d = ( Graphics2D ) g; // cast g to Graphics2D
          // draw 2D ellipse filled with a blue-yellow gradient
          g2d.setPaint( new GradientPaint( 5, 30, Color.BLUE, 35, 100,
             Color.YELLOW, true ) ); 
          g2d.fill( new Ellipse2D.Double( 5, 30, 65, 100 ) );
          // draw 2D rectangle in red
          g2d.setPaint( Color.RED );                 
          g2d.setStroke( new BasicStroke( 10.0f ) );
          g2d.draw( new Rectangle2D.Double( 80, 30, 65, 100 ) );
          // draw 2D rounded rectangle with a buffered background
          BufferedImage buffImage = new BufferedImage( 10, 10,
             BufferedImage.TYPE_INT_RGB );
          // obtain Graphics2D from bufferImage and draw on it
          Graphics2D gg = buffImage.createGraphics();  
          gg.setColor( Color.YELLOW ); // draw in yellow
          gg.fillRect( 0, 0, 10, 10 ); // draw a filled rectangle
          gg.setColor( Color.BLACK );  // draw in black
          gg.drawRect( 1, 1, 6, 6 ); // draw a rectangle
          gg.setColor( Color.BLUE ); // draw in blue
          gg.fillRect( 1, 1, 3, 3 ); // draw a filled rectangle
          gg.setColor( Color.RED ); // draw in red
          gg.fillRect( 4, 4, 3, 3 ); // draw a filled rectangle
          // paint buffImage onto the JFrame
          g2d.setPaint( new TexturePaint( buffImage,
             new Rectangle( 10, 10 ) ) );
          g2d.fill(
             new RoundRectangle2D.Double( 155, 30, 75, 100, 50, 50 ) );
          // draw 2D pie-shaped arc in white
          g2d.setPaint( Color.WHITE );
          g2d.setStroke( new BasicStroke( 6.0f ) );
          g2d.draw(
             new Arc2D.Double( 240, 30, 75, 100, 0, 270, Arc2D.PIE ) );
          // draw 2D lines in green and yellow
          g2d.setPaint( Color.GREEN );
          g2d.draw( new Line2D.Double( 395, 30, 320, 150 ) );
          // draw 2D line using stroke
          float dashes[] = { 10 }; // specify dash pattern
          g2d.setPaint( Color.YELLOW );   
          g2d.setStroke( new BasicStroke( 4, BasicStroke.CAP_ROUND,
             BasicStroke.JOIN_ROUND, 10, dashes, 0 ) );
          g2d.draw( new Line2D.Double( 320, 30, 395, 150 ) );
       } // end method paintComponent
    } // end class ShapesJPanelbasically.. when i click on a button in the index class file, it will call this class file, i do not know to code to call this class file.
    Edited by: slaydragon on Nov 11, 2007 10:55 AM

  • Painting graphics in a JScrollPane

    Hi All,
    I'm writing a graph-drawing application. In my GUI I have a large area for drawing the graphs; this area (drawPanel) is a custom subclass of JPanel.
    So that the graphics persist when the screen is refreshed, I've overridden the paintComponent() method in my drawPanel and put all the drawing code in there (consisting of g.drawLine, g.drawString, etc). I can then call drawPanel.update() when I update the graph, to make sure the graphics appear. Works fine.
    However, if I try to put the drawPanel into a JScrollPane, for example like this:
    JScrollPane scroller = new JScrollPane(drawPanel);
    and add that to the GUI, the program works fine and the scrollbars appear, but nothing at all is drawn in the drawing area.
    I bet this is something really simple, but can anyone point me in the right direction? I've searched the forums, but to no avail. I would post some code, but I'm not sure of the relevant area.
    Many thanks,
    Mike.

    Thanks.
    Although this example works, it's unfortunately too dissimilar to my own program to work out the difference. I'm doing more or less the same thing on a bigger scale - drawing in the paintComponent() method of the JPanel object, and then adding a JScrollPane with the JPanel as the client. I've tried setting preferred size for both (as that was the only obvious difference), but no luck.
    I always thought that the viewport of a scroll pane was supposed to be "transparent" in the sense that the client of the JScrollPane "showed through", and indeed it seems to work for small examples, but I don't know what I'm doing wrong.
    Any other ideas?
    Thanks in advance,
    Mike.

  • Oracle Rules: Adding Java Facts - not showing up in list.

    I am having trouble with adding my own Java classes to the Java Facts. I find the class in the list of classes, tick it, and hit "Ok". When I come back to the list of Java Facts, the class has not been added to the list. And no error message is displayed.
    I am able to add default classes under packages java, javax and org.
    My Java-classes are located here: ...\MyProject\SCA-INF\classes\packageName
    The .rules-file is located here: ...\MyProject\oracle\rules\packageName
    What can be the reason for this?

    I just had a similar issue and I ended having to manually clean up the registry to get Java working again.
    I just got a new computer at work and it had Java 7 installed but it turns out an app we need to use at work doesn't work with Java 7, only Java 6.
    I uninstalled Java 7 and installed Java 6 but Firefox was not showing the Java plugin as installed. I tried all sorts of things, including uninstalling and reinstalling Firefox and none of it worked. Finally I again uninstalled Java and then I searched for "Java" in the registry and found TONS of entries still in there for Java, including for Java 7. I manually deleted all the entries (WARNING: this is extremely risky) rebooted, then installed Java 6 and now it's working fine.
    I really hate it when uninstallers leave stuff behind. It just makes a mess.

  • Java graphics and java 2d graphics

    Hi,
    What are the key difference with graphics and java 2d??
    am i also right in saying,when using just Grpahics, you cannot manipulate shape objects to different colour as and when needed???
    Thanks

    read the api docs on both objects, it explains these two perfectly

  • Adding Java Application Server

    Dear,
    I want to add my EP 6.0 server having only Java stack on my solman 7.0 server.
    Please suggest.
    Shivam

    Dears,
    I added my EP server manually means first added system,then database and then server.
    Now first thing about which I am not sure that server has added correctly means how can I perform any connection test or anything to make sure that connection has been established correctly.
    Second thing I want to know how system monitoring will be configured in this case,means in case of ABAP stack it is peformed by RFC but in case JAVA stack only how system monitoring will configured.
    Please suggest.
    Shivam

  • Adding java projects in eclipse instead of jar files

    I have 2 java projects, one is in C:/test/ProjectA and another is C:/test/ProjectB
    Under projectA and ProjectB i have sub projects.
    I mainly work on ProjectB and import the jar of ProjectA in eclipse.
    Now I have removed jar file of ProjectA reference through eclipse and import projects to workspace, added projects under java build path. clean and build project. no compilation error in eclipse.
    when i do this, one of the class file is not getting loaded while server startup:
    07-Sep-2011 09:28:03 org.apache.catalina.loader.WebappClassLoader validateJarFile
        INFO: validateJarFile(C:\project\europa\NOS-OCT-TEST\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\ESW\WEB-INF\lib\javaee.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
        NOS 0    [main] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/ESW]  - Error configuring application listener of class com.bgc.ecm.core.web.listener.Log4jRemappingListener
        java.lang.ClassNotFoundException: com.bgc.ecm.core.web.listener.Log4jRemappingListener
             at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1386)
             at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1232)
    when i add relevant jar file to the project and do a clean build server is getting started as expected.
    But my changes are not reflecting since it is referring old jar file.
    I am using Tomcat server as development environment.
    What i want is instead of refering jar file in eclipse, add projects so that the new changes should reflect the changes without ant build for creating jar file and instead only with eclipse build with source code of the dependent project and run the application.

    847389 wrote:
    I have 2 java projects, one is in C:/test/ProjectA and another is C:/test/ProjectB
    Under projectA and ProjectB i have sub projects.
    I mainly work on ProjectB and import the jar of ProjectA in eclipse.
    Now I have removed jar file of ProjectA reference through eclipse and import projects to workspace, added projects under java build path. clean and build project. no compilation error in eclipse.If you have imported the depended jar, and if its a java project. the eclipse by default refer these while compiling. I mean before using either of the ant script the or build project option in eclipse. And because of this it is not giving error.
    >
    when i do this, one of the class file is not getting loaded while server startup:
    07-Sep-2011 09:28:03 org.apache.catalina.loader.WebappClassLoader validateJarFile
    INFO: validateJarFile(C:\project\europa\NOS-OCT-TEST\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\ESW\WEB-INF\lib\javaee.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
    NOS 0    [main] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/ESW]  - Error configuring application listener of class com.bgc.ecm.core.web.listener.Log4jRemappingListener
    java.lang.ClassNotFoundException: com.bgc.ecm.core.web.listener.Log4jRemappingListener
         at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1386)
         at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1232)
    And when you deploy the build app in tomcat it looks for the dependent jar/classes in lib or classses folder, and as it is not there the error is thrown.
    If you are using ant script then please specify which jar files to load in lib folder.
    when i add relevant jar file to the project and do a clean build server is getting started as expected.
    But my changes are not reflecting since it is referring old jar file.
    I am using Tomcat server as development environment.
    What i want is instead of refering jar file in eclipse, add projects so that the new changes should reflect the changes without ant build for creating jar file and instead only with eclipse build with source code of the dependent project and run the application.If you want this, then write ant script compatible of loading both the jar's.
    Or you can make the ant to prompt the user which jars to be loaded, while building (I suggest this option, rather than loading all the jar's of project A and project B).

  • (Webdynpro Java)Business Graphics -  Speedometer Color settings

    Hi All,
    I want to implement Speedometer for a Webdynpro(Java) application which should show one value dial(Arrow) and one limit dial.  Limit dial Arrow should be in red color and the Speedometer area after the limit dial area should be in red.    I don't know how to configure this.  Can somebody help me.  
    Thanks in advance.
    Regards
    Lakshmi
    Edited by: lakshminarayanan  j on Sep 22, 2008 7:24 PM

    When you right click on the graphics element and select edit, it should open the properties editor.
    Where in you can set most of the properties.
    I guess you can accomplish your task there.
    If it doesn't satisfy your requirement, then there is a way of setting the xml file which is more tidious.
    If option 1 doesn't work, lemme know, I'll tell you how to set the xml.
    -Aarthi

Maybe you are looking for

  • Error 1704 While Installing iTunes (never mind, I fixed it)

    Edit: OMG, I fixed my own problem! I used the Windows Install Clean Up utility to FINALLY install iTunes 6. YAY Thanks, B, for your help in the past. Hi, I've have been having the WORST time with installing iTunes. I was on this board a couple months

  • Swf loads in preview but doesnt work when published

    I am a newbie to coding and flash but have made a page on my own i went to add a SWF and everyhting works fine in preview I publish the site and all i get is a black box. I cant seem to figure out where it is goin wrong. I have the scripts folder pub

  • Gridbag layout problem on a tabbedpane

    I am not sure whether we can do this or not but, I am trying to have a gridbag layout on a TabbedPane object. I have a JFrame on which I am adding a TabbedPane object called "t" and on this TabbedPane I am adding a tab called "Insert" which is an obj

  • Cisco 4503 "1000BaseLH" SFP light is not coming

    Dear Team, I have Cisco 4503 and I have inserted 1000BaseLH and light is not coming up but for 1000BaseSX its fine. Please suggest. CORE#show int GigabitEthernet1/18 GigabitEthernet1/18 is down, line protocol is down (notconnect)   Hardware is Gigabi

  • Can't start up from Install disk

    I'm using a MacBook purchased 3/07. System 10.4.11 I can't start up from the Install Disk for Leopard. I only get a screen with the apple logo and the spinning thing. I wait 10 minutes. Nothing happens. I've tried both using the Disk for the start up