Problem in viewing the swing components added to the applet.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   abhinav_karhu
Posted On:   Tuesday, September 4, 2007 11:06 AM

Hello all I am creating an applet using the biojava library for watching DNA traces. I am using a JSrollPane object in which I am putting the sequencepanel(that I create using the biojava library) and then adding this scrollpane to the JFrame. If i go about it this way then there is no error is execution but the only thing is I get a new Frame which is very much obvious. If I use the javax.swing.JApplet then I can directly set the Layout of the applet and then I add the JScrollPane to it. The trouble here is that I am not able to view the contents that I can see when I use the frame. The code is as follows: import java.awt.RenderingHints; import java.io.IOException; import org.bi   More>>


Hello all I am creating an applet using the biojava library for watching DNA traces.
I am using a JSrollPane object in which I am putting the sequencepanel(that I create using the biojava library) and then adding this scrollpane to the JFrame.
If i go about it this way then there is no error is execution but the only thing is I get a new Frame which is very much obvious.



If I use the javax.swing.JApplet then I can directly set the Layout of the applet and then I add the JScrollPane to it.
The trouble here is that I am not able to view the contents that I can see when I use the frame.


The code is as follows:
import java.awt.RenderingHints;
import java.io.IOException;
import org.biojava.bio.chromatogram.Chromatogram;
import org.biojava.bio.chromatogram.ChromatogramFactory;
import org.biojava.bio.chromatogram.UnsupportedChromatogramFormatException;
import org.biojava.bio.chromatogram.graphic.ChromatogramGraphic;
import org.biojava.bio.program.abi.ABIFChromatogram;
import javax.swing.JApplet;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Image;
import java.io.File;
import java.awt.image.BufferedImage;
import java.awt.Graphics2D;
import org.biojava.bio.*;
import org.biojava.bio.symbol.*;
import org.biojava.bio.seq.*;
import org.biojava.bio.gui.sequence.*;
import org.biojava.bio.program.abi.*;
import javax.swing.JFrame;
import javax.swing.JScrollPane ;
import java.awt.BorderLayout;

public class Trace extends javax.swing.JApplet {

public void paint(Graphics g)
{

File ft = new File("C:/Documents and Settings/akarhu3/Traceviewer/src/3422_A01.ab1");
try{
ABITrace trace = new ABITrace(ft);
AbiTraceRenderer renderer = new AbiTraceRenderer();
renderer.setTrace(trace);
renderer.setDepth(190.0);

MultiLineRenderer mlr = new MultiLineRenderer();

mlr.addRenderer(new SymbolSequenceRenderer());
mlr.addRenderer(renderer);
mlr.addRenderer(new RulerRenderer());

SequencePanel sp = new SequencePanel();
Sequence seq = SequenceTools.createSequence(
trace.getSequence(),
ft.toString(),
ft.toString(),
Annotation.EMPTY_ANNOTATION
);
sp.setSequence(SequenceTools.createSequence(
trace.getSequence(),
ft.toString(),
ft.toString(),
Annotation.EMPTY_ANNOTATION
));


sp.setDirection(SequencePanel.HORIZONTAL);
sp.setScale(8.0);

sp.setRange(new RangeLocation(0,200));
sp.setRenderer(mlr);

Sequence rev = SequenceTools.reverseComplement(seq);

***************************************************************
--------The frame part is commented out----------------
/*JFrame frame = new JFrame("Trace: " + ft);
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(new JScrollPane(sp), BorderLayout.CENTER);
frame.getContentPane().setBackground(Color.WHITE);
frame.setSize(800,300);
frame.setVisible(true);*/
------------------------------------------------------------------------------
***************************************************************************
BorderLayout br = new BorderLayout();
this.getContentPane().setLayout(br);
JScrollPane pane = new JScrollPane();
this.getContentPane().add(new JScrollPane(sp));
this.repaint();
//this.getContentPane().add(new JScrollPane(sp));
}


the main part is this much.
Also sometimes when i resize the applet window after sometimes the scrollpane is visible but not completely and also I get java.lang.OutOfMemoryError when I go on resizing the window?

Somebody please help me on this topic.

   <<Less

Re: Problem in viewing the swing components added to the applet.

Posted By:   Anonymous  
Posted On:   Saturday, September 8, 2007 03:16 PM

Hi Abhinav

Do you know about services provided by http://www.techhelpformarketers.com they are an assembled team of Tech Professional with Extensive Experience in taking down IT task or IT technical problems giving you the Shortest Turnaround Time possible.
Hope its helpful to you all.

Please check it out & reply me your suggestions.

[wilkin]
About | Sitemap | Contact