Image repainting problem!! plz HELP!!
I'm facing a little problem with repaint. I have a moving ball on my JPanel (canvas). Ball (which is a circle) is leaving 2 lines behind it. I don't know why it happens, the code inside my paintComponent() method is as follows:
public void paintComponent(Graphics comp)
super.paintComponent(comp);
g = (Graphics2D)comp;
g.drawLine(0,250, 500, 500/2); //draw horizontal line from north
g.drawLine(500/2, 0, 500/2, 500); //draw vertical line on the equator
g.setColor(Color.blue);
g.fillArc(width, height, ballSize, ballSize, 0, 360);
}The above "paint" event has been written for JPanel class. On fillArc() line, only width and height are changes through a thread class. Actually, my ball is bouncing against the walls (edges) of Jframe. Bouncing is fine, but it is printing 2 lines just behind the ball (arc).
Any expert commetns would be greatly appreciated.
Raheel.
Hi.
I think you should clean up your background at the beginnig of paintComponent:
public void paintComponent(Graphics comp) {
super.paintComponent(comp);
g = (Graphics2D)comp;
//comp cleaning
g.setColor(Color.WHITE); //the color of your background
comp.fillRect(0, 0, getWidth(), getHeight());
//end of cleaning
g.fillRect(0, 0, get
g.drawLine(0,250, 500, 500/2); //draw horizontal line from north
g.drawLine(500/2, 0, 500/2, 500); //draw vertical line on the equator g.setColor(Color.blue);
g.fillArc(width, height, ballSize, ballSize, 0, 360);
}Hope this help.
Similar Messages
-
Audio Clip problem plz help..
There is some problem with my code. It is actually for simply playing a wav file.
It gives errors on two lines....
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
public class MediaPlayerDemo extends JFrame
AudioClip clip; //Error Here
public MediaPlayerDemo(String title)
super(title);
clip = getAudioClip(getCodeBase(),"access.wav"); //Error Here
clip.loop();
public static void main(String args[])
MediaPlayerDemo m = new MediaPlayerDemo("Title");
m.setSize(400,400);
m.setVisible(true);
}"Audio Clip problem plz help"
You have to learn to help yourself.
Have you done anything to try to fix the errors yourself?
AudioClip clip; //Error Here
the error generated here is self-explanatory.
if you can't fix this, you should get a good book on java basics and start again.
the other error is also easy to fix. -
hi!
i am unable to run my RMI server program .Name of My server class is SumServer.java,it implements SumInterface.java all the files(.class,.java and stub) are at location c:\javaprog\rmi\sum.
I have not put them in any package.
value of classpath is
classpath=c:\jdk1.4\lib;.;c:\javaprog\rmi\sum
i go in sum folder and run the program
c:\javaprog\rmi\sum > SumServer
it gives me following exception.plz help me out.
Thx in advance.
Exception occur.Unable to register serverjava.rmi.ServerException: RemoteExcepti
on occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
tion is:
java.lang.ClassNotFoundException: SumServer_StubDeepa lakshmi wrote:
Hi,
Am new to weblogic.
Am using the tools are,
Weblogic8.1 version
MySql5.0,mysql-connector-java-3.1.12-bin.jar file
While test configuration of connection pooling am getting the error is "JDBC Driver is not on the classpath".
How can i solve this problem
plz help me
regards
DeepaEdit the start-weblogic script. Near the bottom, you will see
lines that create a CLASSPATH for the weblogic server. Add a
script line that adds the mysql driver to the classpath there.
Joe -
ps4 can ON got sound can control but no image and also the color on the top is white...
Sry for my bad english.... I have try other HDMI but still the same problem. The problem is when I turn on the ps4 the LED on top of the ps4 turn from blue to white. Then when it's started there no image the screen is black, but have sound and I can control it with my controller. I also try to plug in my HDMI from my laptop to the TV and there no problem what so ever.. Plz help :<
-
Problem: codebase, jar and image reloading problem please help!
Hi Java Gurus,
I have written an applet that extends JApplet for viewing webcam. In order to reduce the download time I put my classes into a doorcam.jar file. The following is my <applet> tag in my html file.
<applet code="CameraApplet.class"
archive="doorcam.jar"
codebase = "webcam/classes"
width="375" height="475">
<param name="imagePath" value="http://judge/webcam/images">
<param name="webCamImage" value="door.jpg">
<param name="COMPort" value="COM2">
<param name="frameRate" value="10"> <!-- could not exceed more than 10-->
<param name="host" value="judge">
</applet>
The fist problem is that my class file does not get loaded from the jar file if i provide the "codebase" attribute as above. Instead the browser load every single class file from the webserver. This has some problem too. Coz the browser sometimes just thorough NullPointerException or ClassNotFoundException. After much of debugging I found out that the problem is the IE browser which seldom fails to load classes or image file from the server. If i referesh the browser the applet and all its classes loaded successfully and runs smoothly. This behaviour never occurs when running with "appletviewer".
I wanted all my classes to be loaded from my jar file. After much of trial and error I found out that if i remove "codebase" attribute the browser loads the classes from my jar file and applet loads very fast. This is where the second problem comes in. The browser does not reload my webcam image file so that the webcam become alive with live images, like before.
If I run on "appletviewer" everything works fine my web cam is displayed properly. But in IE browser the image does not get reloaded when I refresh my image to give live to my webcam display. The refresh method is given below.
private void refresh(final URL url) {
Image webCamImage =getImage(url);
webCamImage.flush(); // flush out the previous image
webCamImage = getImage(url); // get a new image
webCamImageIcon.setImage(webCamImage); webCamImageIcon.paintIcon(webCamLabel, webCamLabel.getGraphics(), 15, 15);
When I add the "codebase" attribute back, the image gets reloaded for every refresh() and everything works fine. But the classes are also loaded from the server. And occasionally also suffers Class loading and image loading problem. As I presented earlier, when I do refreshing in the browser everything gets loaded and the applet function correctly with web cam displaying very well.
The problem is so strange that I could not find any way to solve it.
It would be a great help to me if somebody provide me some work around to the problem.
I tested on Windows 2000, Windows XP, IE 5.5, IE 6 with J2SDK 1.4.0.
Thank you all very much in advance.
best regards,
JudgeThank you so much for the suggestions. I did tried the way u suggested. The problem still the same.
I think its the problem between IE browser and Java Plug-in.
I which SUN would find these incompatibilities and solve these problems.
I even tried using java SDK and plug-in 1.4.1 it even worst. It can't even load an applet. And it does not show any loading messages nor any error messages. It just show a cross sign on the upper left coner.
I would be so glad, if Sun would try to eliminate the inconsistancies such as caching, loading, initializing etc between browser and its Java plug-In. For example, applets behave well in appletviewer and behave unpredictably in browser environment.
I have seen so many people in the forums with all sorts of problems because of this.
Right now I m desperately looking for work around to my problem.
If somebody would provide me with the solution to my problem it would be a great help to me.
thank you all so much.
best regards,
Judge -
Hi Guys,
I have a problem to make a developer application Client/Server.
When i install forms Runtime on the Client`s computer and i open the application, i get the error that he can`t find the menu and the libraries.
The menu path is for example on my computer F:\s3\Salesmenu
But on the client it can be a different path an then he can`t find the menu.
Now the properties for the main form are:
Menu module f:\s3\Salesmenu
Initial menu Salemenu
Does anyone know how to fix this problem for example:
1) by let the program search for the menu.
2) .....
Plz Help
Vincentset your FORMS60_PATH on the client to Formspath;libpath;menupath so it looks in every dir named in the path.
-
So, when i click on the itunes shortcut, which has the same icon as the Apple Software Updater, I get a box that says that iTunes has encountered a problem and needs to close. We are sorry for the inconvenience. I hit send once and sent the error report, and then restarted my computer to see if that would help. It didnt, so, now i cant access itunes this is a major problem cause i have all my songs on this computer. I also tried to plug in my ipod and see if that would make it load.
I installed iTunes 7.0 on my laptop, the exact same way, and i works on my laptop, but not on my computer.
PLZ HELP MEok this is what i did when that happened to me. i uninstalled quicktime then went here: http://www.apple.com/quicktime/win.html and reinstalled the latest version :0)
-
Nokia n79 problem Plz Help!
Hello!My nokia just stuck,or hang in(i dont now english good) but i cant do enything.Evry button just dont work only at start when i write my pi(and somethimes then too).Works only power button.Its weard.Plz help.Somethimes a whole day are no problems somhetimes a whol day.
hey ivee n everyone else .. i'm facing the same problem.. n i need to fix this problem myself..
my n79 gets hang constantly nowadays.. i've used this phone for 1 year plus now so warranty's no more..... none of the buttons on the keypad works when it gets hang.. onli the power button is functioning.. now it's gettin worse .. it even hangs before i insert my pincode... i cant sms, call , or anything.. it hangs after i pressed a few buttons..
so ivee u've fixed ur n79 youself right..? umm.. can u explain to me wat a smallboard is? is that the board at the lower part of the keypad where u can see buttons underneath the white layer? and is that board expensive?
pls reply asap anyone.. urgent -
N79 hanging problem plz help....
while unlocking the keypad of my n79 sometimes the phone gets hanged then i have to take the battery out and then again switch on the phone........plz help me how to get rid of this problem???
I have also same problem with my Nokia N79, I just cancelled sensor for automatic themes from cover. Just open back cover & stick some paper or plastic cello tape on four hole marks of covers wich r sensor for automatic themes to change colour of back cover same as theme colour. From 2 days I feel my mobile working fine without hanging ! so try it, all the best.
-
Bluetooth connection problem plz help...
hi everyone, just bought a new pearl 9105. everything works fine and even bluetooth... through which i can transfer data from blackberry to other mobiles(samsung,sony ericsson)... but the problem is i could not recieve data from other mobiles.i should get contacts list from the other mobiles... but due to this problem i couldnt. plz help me out..
The best way to receive a file from another device via bluetooth is to go to Media, then press Menu, choose Receive Using Bluetooth, waiting for connection will be display, then send from the other device. It should work without hassle.
-
JTable problem plz help me urgent
sir
i carefully read the swing tutorial for JTable for the purpose
of rendring specially header rendring.
first u see the code
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import javax.swing.border.*;
import java.util.*;
import javax.swing.table.*;
public class Myscrollpane extends JScrollPane
ImageIcon icon=new ImageIcon("images/beach1.jpg");
Image img;
int w,h,wi,hi;
TableColumn column = null;
/*Vector cols=new Vector();
cols.addElement("Company Code");
cols.addElement("Company Name");
String[] names = {"Company Code", "Company Name"};
DefaultTableModel model=new DefaultTableModel(names,0);
JTable table=new JTable(model);
LogoViewport vp;//custom class extends with JViewport
Myscrollpane(int width,int height)
vp= new LogoViewport(width,height);
setOpaque(false);
setMinimumSize(new Dimension(width,height));
setPreferredSize(new Dimension(width,height));
setSize(350,125);
///////////here r the table methods to control /////////////////////
table.setPreferredScrollableViewportSize(new Dimension(width,height));
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF );
table.getTableHeader().setReorderingAllowed(false);
table.setBackground(new Color(245,235,237));
table.setForeground(Color.black);
table.setOpaque(true);
table.setEnabled(false);
table.setFont(new java.awt.Font("Dialog", Font.ITALIC, 12));
table.setGridColor(Color.pink);
table.setRowHeight(22);
table.setSelectionBackground(Color.lightGray);
DefaultTableCellRenderer renderer=new DefaultTableCellRenderer();
TableColumn code=table.getColumnModel().getColumn(0);
renderer.setBackground(Color.red);
????//if i use the setIcon method then the data comes from the database
????//is not shown because the icon paint above the data.
code.setCellRenderer(renderer);
TableCellRenderer headerRenderer = table.getTableHeade.().getDefaultRenderer();
TableColumn column1=null;
???//i use this to change the color of header column but it is not work
for (int j = 0; j < 2; j++) {
column1 = table.getColumnModel().getColumn(j);
Component comp = headerRenderer.getTableCellRendererComponent(
null, column1.getHeaderValue(),
false, false, 0, 0);
comp.setBackground(Color.red);
???//if i use following it also not work
TableCellRenderer headerRenderer = table.getTableHeader().
getDefaultRenderer();
if (headerRenderer instanceof DefaultTableCellRenderer) {
((DefaultTableCellRenderer)headerRenderer).setBackground(Color.red);}
for (int i = 0; i <=1; i++)
column = table.getColumnModel().getColumn(i);
if (i == 0) {
column.setPreferredWidth(100);
else
column.setPreferredWidth(225);
vp.setView(table);
this.setViewport(vp);
plz help me with the code.
i also want to draw the image on the table with the use of DefaultTabel
Model and data set from the data base.Initally no row is shown.
plz help me
shown(???) are the quesstion which i am unable to solve.
thanks in advance.Formatting the code makes it easier to read, which means more people may attempt to read your code and answer your questions. Click on the "Help" link at the top of the page.
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
public class TableHeader extends JFrame
public TableHeader()
JTable table = new JTable(5, 5);
table.setPreferredScrollableViewportSize(table.getPreferredSize());
JScrollPane scrollPane = new JScrollPane( table );
getContentPane().add( scrollPane );
table.getTableHeader().setBackground( Color.red );
public static void main(String[] args)
TableHeader frame = new TableHeader();
frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
frame.pack();
frame.setLocationRelativeTo( null );
frame.setVisible(true);
} -
JTable problem plz help me urgent withDefault TableModel
sir
i carefully read the swing tutorial for JTable for the purpose
of rendring specially header rendring.
first u see the code
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import javax.swing.border.*;
import java.util.*;
import javax.swing.table.*;
public class Myscrollpane extends JScrollPane {
ImageIcon icon=new ImageIcon("images/beach1.jpg");
Image img;
int w,h,wi,hi;
TableColumn column = null;
String[] names = {"Company Code", "Company Name"};
DefaultTableModel model=new DefaultTableModel(names,0);
JTable table=new JTable(model);
LogoViewport vp;//user class extends with JViewport
Myscrollpane(int width,int height){
vp= new LogoViewport(width,height);
setOpaque(false);
setMinimumSize(new Dimension(width,height));
setPreferredSize(new Dimension(width,height));
setSize(350,125);
///////////here r the table methods tocontrol /////////////////////
table.setPreferredScrollableViewportSize(new Dimension width,height));
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF );
table.getTableHeader().setReorderingAllowed(false);
table.setBackground(new Color(245,235,237));
table.setForeground(Color.black);
table.setOpaque(true);
table.setEnabled(false);
table.setFont(new java.awt.Font("Dialog", Font.ITALIC, 12));
table.setGridColor(Color.pink);
table.setRowHeight(22);
table.setSelectionBackground(Color.lightGray);
DefaultTableCellRenderer renderer=new DefaultTableCellRenderer();
TableColumn code=table.getColumnModel().getColumn(0);
renderer.setBackground(Color.red);
//if i use the setIcon method then the data comes from the database is
//not shown because the icon paint above the data.Iwant to paint the
//image on the table dynamically means as table populated the image is
//paint on the table means no fix no of rows.How can i
//do.
code.setCellRenderer(renderer);
TableCellRenderer headerRenderer = table.getTableHeade.().getDefaultRenderer();
TableColumn column1=null;
//i use this to change the color and paste icon of header column
//but it is not work
for (int j = 0; j < 2; j++) {
column1 = table.getColumnModel().getColumn(j);
Component comp = headerRenderer.getTableCellRendererComponent(null, column1.getHeaderValue(), false, false, 0, 0);
comp.setBackground(Color.red);
comp.setIcon(new ImageIcon("myimage.gif")); }
//if i use following it also not work
TableCellRenderer headerRenderer = table.getTableHeader().getDefaultRenderer();
if (headerRenderer instanceof DefaultTableCellRenderer) {((DefaultTableCellRenderer)headerRenderer).setBackground(Color.red);} vp.setView(table);
this.setViewport(vp);
}plz help me with the code.
stated as above i also want to draw the image on the table with the use of DefaultTabel
Model and data set from the data base.Initally no row is shown.
plz help me
thanks in advanceimport java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
public class TableHeader extends JFrame
public TableHeader()
Object[] columnNames =
new ImageIcon("copy16.gif"),
"Some Text",
new ImageIcon("add16.gif")
// Columns headings are cast to a String when created automatically.
// We want Icons, so use a special renderer and create the columns manually
JTable table = new JTable();
table.getTableHeader().setDefaultRenderer( new HeaderRenderer() );
for (int i = 0; i < columnNames.length; i++)
TableColumn newColumn = new TableColumn(i);
newColumn.setHeaderValue( columnNames[i] );
table.addColumn(newColumn);
table.setPreferredScrollableViewportSize(table.getPreferredSize());
JScrollPane scrollPane = new JScrollPane( table );
getContentPane().add( scrollPane );
class HeaderRenderer extends DefaultTableCellRenderer
public Component getTableCellRendererComponent(
JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col)
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
setHorizontalAlignment(CENTER);
// color each cell
if (col == 1)
setBackground( Color.yellow );
else
setBackground( Color.green );
// display text or icon
if (value instanceof Icon)
setIcon( (Icon)value );
setText( "" );
else
setIcon( null );
setText((value == null) ? "" : value.toString());
return this;
public static void main(String[] args)
TableHeader frame = new TableHeader();
frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
frame.pack();
frame.setLocationRelativeTo( null );
frame.setVisible(true);
} -
Hi all,
I have a problem when I am trying to run a jar file from an applet. The jar is for remote desktop application. Jrdp.jar.
And the Exception is���.
Exception in thread "Thread-6" java.security.AccessControlException: access denied (java.util.PropertyPermission gnu.posixly_correct read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
at java.lang.System.getProperty(Unknown Source)
at gnu.getopt.Getopt.<init>(Getopt.java:617)
at gnu.getopt.Getopt.<init>(Getopt.java:581)
at net.propero.rdp.Rdesktop.main(Rdesktop.java:290)
at net.propero.rdp.applet.RdpThread.run(RdpApplet.java:190)
can any one suggest me what I have to do???? Plz give your valuable suggestion in that matter. Should I have to do any thing in java.policy file. In that case what would be the syntax and what have allow. If possible plz help me out.
Thanking you,
With regards
Shibaji SabyalTry googling on how to sign your applet. The error you're getting can usually be solved by signing it.
-
Package Problem : Plz help
I've make two classes named First.java and Second.java in e:\javafiles\test\vg folder
package vg;
public class First
public int m = 100;
public int n = 200;
package vg;
public class Second
public static void me0()
System.out.println("Stupid cant u see the value of m is zero");
public static void mgrn()
System.out.println("Yaar m is greater than n");
public static void neven()
System.out.println("The value of n is Even");
and a Third class
import vg.*;
public class Last
public static void main(String robert[])
Second d = new Second();
First f = new First();
if(f.m==0)
d.me0();
if(f.m>f.n)
d.mgrn();
if((f.n%2)==0)
d.neven();
else
System.out.println("The value of n is Odd");
Now the problem is that if I put the Last.java at e:\javafiles\test and compile it , it works fine but if I put the Last.java anywhere else e.g at e:\javafiles and try to compile it it does not works and gives error
E:\JavaFiles>javac Last.java
Last.java:1: package vg does not exist
import vg.*;
even if I change classapth variable as E:\javafiles\test or even E:\javafiles\test\vg
plz help me in this regardYou need to change where it is trying to find the 'vg' package. So, if your Last.java is in e:\javafiles, then you need to
import test.vg.*
e.g.
import test.vg.*; // Change this line
public class Last
public static void main(String robert[])
Second d = new Second();
First f = new First();
if(f.m==0)
d.me0();
if(f.m>f.n)
d.mgrn();
if((f.n%2)==0)
d.neven();
else
System.out.println("The value of n is Odd");
Alan -
please any body can solve my problem?
i have n95
when i open gps application
then on the screen globe is not showning and no maps are showing on screen
only city names are showed
and after the closing of map application in apst there are type on screen
saving maps and data
but now nothing typed
plz help mei am using latest firm ware
and using old maps application bcoz new beta 2.0 not showing my accurate position in pakistan
if i am in my city
the maps application shows u r 10 km from your city
but old version give me accurate position... -
hi to all
Using form6i and run in client server. i cant solve this problem please help to all master :
I have a text item in forms and button. When i type the Customer_Name in text item then all names appears in reports, i want that when i type the name, only that name will appear .
Please check what is wrong with my code and steps.
In report wizard, query statement i put "Select * from S_customer"
then i call the report in forms..
Report Property pallette:
Other Parameters=Customer_Name
Query names=Select * from s_Customer where Customer_Name=:rep(the text item)
then in forms the button trigger is when button pressed.below is the code:
declare
v_Rep varchar2(100);
repid report_object;
Begin
repid := find_report_object('report');
SET_REPORT_OBJECT_PROPERTY(repid,REPORT_OTHER,’s_customer=’||:Dept.rep);
v_rep := run_report_object(repid);
end;
advance tnx to allHi,
You need to bulid a parameter list.
This is a code sample to run a report from Forms:
(Place it on a button when-button-pressed trigger, to run the report).
DECLARE
repid REPORT_OBJECT;
v_rep VARCHAR2(100);
rep_status VARCHAR2(20);
-- this is the parameter list
pl_id ParamList;
pl_name VARCHAR2(10) := 'tempdata';
BEGIN
-- try to find the parameter list
pl_id := Get_Parameter_List(pl_name);
IF Id_Null(pl_id) THEN
-- if parameter lsit does not exist
-- create it
pl_id := Create_Parameter_List(pl_name);
IF Id_Null(pl_id) THEN
Message('Error creating parameter list '||pl_name);
RAISE Form_Trigger_Failure;
END IF;
ELSE
Message('Parameter list '||pl_name||' already exists!');
-- destroy it to clear old parameters
-- and create it again;
destroy_parameter_list(pl_id);
pl_id := Create_Parameter_List(pl_name);
END IF;
Add_Parameter(pl_id,'p_customer_name',TEXT_PARAMETER,:customer.cust_name);
-- add as many parameters as needed
-- finally run the report passing your parameter list
repid := FIND_REPORT_OBJECT('report4');
v_rep := RUN_REPORT_OBJECT(repid, pl_id);
Exception
when others then
Message('Error running report. '||sqlerrm, acknowledge);
END;
Also, you need to create the parameter in your report:
1.- Open your report on reports builder.
2.- Find the "Data Model" node, and the "User parameters" node.
3.- Create a parameter: p_customer_name
4.- Modify your sql from:
Select * from S_customer
TO:
Select * from S_customer
where Customer_Name=:p_customer_name;
If you want this parameter to be optional, check the reports online help on "Lexical References".
Have fun,
Hugo
Maybe you are looking for
-
I have tested existing interactive pdfs that function perfectly in Acrobat XI and Adobe acrobat Reader but open the same files in Acrobat DC and Acrobat DC Reader and most of the documents i have designed and produces over last few years have been re
-
How can i install flash player for window 8.1(64 bit) on my laptop
how can i install flash player for window 8.1(64 bit) on my laptop?
-
Installing Lion and formatting my Mac (with Snow Leopard)
Hey everybody! I have a MacBook Pro with Snow Leopard. I want to install Lion from the App Store and format my Mac. How should I do it? Thanks!
-
How can i remove all of the purchased songs from my phone?
I want to remove all of the purchased songs from my phone, but I'm not having any success. I've transferred the purchases to iTunes, and turned off the cloud on my phone, but they are still there. They will not let me delete them...
-
Replication Link Analyzer Unusual Error
Just finished upgrading my Heirarchy to SCCM 2012 R2, everything is fine after migration and the environment has been stable for several weeks. One site however, is showing warnings for Replication. The replication isn't failing, its been up to date