A simple problem but complicated for me........
import java.awt.*;
import java.applet.*;
/*<applet code="First" width=100 height=100>
</applet>*/
public class First extends Applet {
/*public void init()
public void paint(Graphics g)
setBackground(Color.black);
setForeground(Color.green);
g.drawString("annn",1,10);
g.setColor(Color.red);
g.drawString("annn",10,20);
setForeground(Color.orange);
g.drawString("annn",1,30);
The problem is that when i run the above applet the output keeps fluctuating as if the paint method is being called again and again..
why is the same text being painted again and again.......
It's an issue of double buffering, it sounds like... (flickering?)
See:
[http://javaboutique.internet.com/tutorials/Step/Chapter4/DoubleBuffering.html]
You can probably most easily solve this by using swing instead of awt. Use JApplet, JPanels, etc. from javax.swing
import javax.swing.*;
/*<applet code="First" width=100 height=100>
</applet>*/
public class First extends JApplet {
/*public void init()
public void paint(Graphics g)
setBackground(Color.black);
setForeground(Color.green);
g.drawString("annn",1,10);
g.setColor(Color.red);
g.drawString("annn",10,20);
setForeground(Color.orange);
g.drawString("annn",1,30);
}Edited by: MichaelDGagnon on Dec 16, 2008 12:55 PM
Similar Messages
-
WHat I'm sure is a simple problem but not for me...
Greetings all,
I am putting together a simple applet that accesses a MYSQL database, reads all the records out and writes them to the "graphic" screen via the paint method.
Everything works fine when I run the applet in a player (Eclipse) but when I move everything over to the web server, the html page (static part) displays but the applet fails with an error. The Java Console tells me the following:
java.lang.NoClassDefFoundError: jdbctest01$Database
at jdbctest01.init(jdbctest01.java:41)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
The applet code it is referencing is:
40 ...
41 db = new Database(url, user, pass);
42 ...
and the "Database" method being invoked is:
public class Database {
public Database(String url, String user, String pass){
try{
connection = DriverManager.getConnection(url, user, pass);
catch(SQLException e) {
As I said, nothing to it...but I can't figure out why its not working (but I am sure its obvious). I have tried it on IE & Firefox; same result. Both have java enabled, the class file and the html files all have open permissions (machine is not on the net) so I doubt anything as simple as security is at work. I have been staring at this for a while and I am losing feeling to my lower extremities. I hope someone out there can offer some ideas as to what I should be checking for or what else to do diagnostic wise.
Many thanks,
PeteAxel,
Many thanks for the lead (Incidentally, it's not my code; they use it for "education" (of who I'm not sure) and they just discovered there are no compiled copies anywhere so, no examples, screen shots etc.). I "volunteered" to try and get it working and...
Anyway, I added the jdbctest01$Database.class and I got "different" results. Now, it gets into the database class and when it executes the connection = DriverManager.getConnection(url, user, pass); it returns a SQLException error. I have confirmed that the url, user and pass values ARE correct so I am not sure where this error is coming from. The "connection" value is typed Connection. There really isn't anything else that I can see could be wrong. One other thing; the exception is caught in the Database instance but it still manages to return to the statement following the invocation of the Database class. The connection value it returns looks like it might be right (the returned value is: jdbctest01$Database@adb1d4 which I think is "like" it should be but no luck). The first statement on return is: stmt = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); and stmt is typed Statement) And at this point,it dies with a null pointer error.
Any other ideas will be greatly appreciated.
Thanks,
Pete -
Please a simple problem but I don't know how to solve it. After installing 16 gb of ram all is good but when I turn on the computer it is a window signaling that all is correct. How is possible to delete once and for all that window? Thank you
Well then maybe you could take a screenshot because the appearance of such a window is news to me.
Also post your OS X version and what model Mac you have. The more detail, the better. Thanks.
To take a screenshot hold ⌘ Shift 4 to create a selection crosshair. Click and hold while you drag the crosshair over the area you wish to capture and then release the mouse or trackpad. You will hear a "camera shutter" sound. This will deposit a screenshot on your Desktop.
If you can't find it on your Desktop look in your Documents or Downloads folder.
When you post your response, click the "camera" icon above the text field:
This will display a dialog box which enables you to choose the screenshot file (remember it's on your Desktop) and click the Insert Image button.
⌘ Shift 4 and then pressing the space bar captures the frontmost window.
⌘ Shift 3 captures the entire screen.
Drag the screenshot to the Trash after you post your reply. -
Please give me hand !!it looks like simple problem but!!
something happened to my machine so now
when I run the following command :
c:>java mydir/myclass I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: mydir/myclass
Do you know how I solve this problem?
By the way it was working fine.
ThanxThanks alot for your suggestion but it does not work
I used to run it as follow for many months
java mydir/myclass
and it was working fine. Well, what do you know...you're right.
java has some syntactic sugar to deal with being called wrong.
The problem happened after I
try to set path in may machine using
setpath command
Do you think I have to update system variables and so
onPossibly. Who knows what new and pointless hurdles you have to jump through on a Microsoft box.
Has the class changed at all?
Are you executing it from the same directory you always were?
What else could have changed on your system? Install any new software lately? -
A simple question but difficute for me
I'm trying to write a simple java applet that is able to repond actions from "mouse" and "key board". But surprisingly, it can only repond actions from "mouse". I know that the functions "KeyDown" and "MouseDown" are depreicated methods, but they should still work though. If "MouseDown" can work, why "keyDown" is not working?
import java.awt.*;
import java.applet.Applet;
public class Key extends Applet {
public void paint(Graphics g){
g.drawString("Hello", 50, 50);
public boolean keyDown (Event e, int key){
System.out.println("key down");
return true;
public boolean mouseDown (Event e, int x, int y){
System.out.println("mouse pressed");
return true;
}then you need ActionListener
for example
addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton1_actionPerformed(e);
}); -
when I run tomcat , the tomcat page show this error:
Error creating bean with name 'springappController' defined in ServletContext resource [WEB-INF/springapp-servlet.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'productManager' of bean class [SpringappController]: Bean property 'productManager' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1058)...................................
It says that there is wrong property defined inside springapp-servlet. xml due to my setter() and getter() has problem,
the springapp-servlet. xml file where I defined this controller bean is like follows, the error warning place is highlighted :
<bean id="springappController" class="SpringappController">
<!-- add this part after we create ProductManager and modify the controller and hello.jsp-->
<property name="productManager"> <ref bean="prodMan"/>
</property>
</bean>
<bean id="prodMan" class="bus.ProductManager">
<property name="products">
<list>
<ref bean="product1"/>
<ref bean="product2"/>
<ref bean="product3"/>
</list>
</property>
</bean>
the place I define my setter() and getter() is appspringController class, which is:
package web;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.IOException;
import java.util.*;
import java.util.Map;
import java.util.HashMap;
import bus.Product;
import bus.ProductManager;
public class SpringappController implements Controller {
//logger for this class and subclass
protected Log logger=LogFactory.getLog(getClass());
private ProductManager productManager;
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String now=(new java.util.Date()).toString();
logger.info("returning hello view with"+now);
Map myModel=new HashMap();
myModel.put("now",now);
myModel.put("Products", productManager.getProducts());
return new ModelAndView("hello","model",myModel);
}//end of HandleRequest
public void setProductManager(ProductManager pm){
productManager=pm;
public ProductManager getProductManager(){
return productManager;
}//end of controller
I do not see any error of my setter() and getter() method in the SpringappController, and I do not know where is wrong inside the springapp-servlet. xml file. could any one help me?
Message was edited by:
Mellon
Message was edited by:
Mellon
Message was edited by:
Mellon
Message was edited by:
Mellonhi vibhaa
Can you please explicitly put what you meant by lost a class,I think he miss typed the path of the class. e.g.
if the class name is Product.java in the package com -> src -> packs ->
he must have typed as
com.src.Product in stead of
com.src.packs.Product
I am having a similar problem and would like to know the solution. Just check you path as I mentioned earlier, if the path is alright, then make sure you have declared your class as "public".
let me what is happening with it. -
Simple problem but help needed
how do I accept a character y or n from the user? otherthan readLine()used for String console input. which function should I use to accept y or n and proceed based on y or n , same is the case with boolean. If I would want to accept a boolean value from the console
from the user and would want to proceed according to what boolean value(true or false) has been entered by the user
import java.io.*;
public class acceptUsersChoice{
public static void main(String args[])throws IOException{
InputStreamReader hi=new InputStreamReader(System.in);
BufferedReader hey=new BufferedReader(hi);
//accepting user's choice and acting accordingly
System.out.println("Enter Your choice 'y' or 'n' ");
char s=
/* here how do I accept a character y or n ? which function should I use to accept y or n and proceed based on y or n , same is the case with boolean. If I would want to accept a boolean value
from the user and would want to proceed according to what boolean(true or false) has been entered by the user, how do I do it?*/
System.out.println("This is it"+s);
}}Crossposted. Here's one of them:
http://forum.java.sun.com/thread.jspa?threadID=597733 -
Simple simple problem but can't find answer
Hi everyone,
To all java people out there.
Can anyone tell me the MAIN difference between C functions and Java Class?
Java better than C for the garbage collection and the better pointers right?These articles say much more than I'm willing to write.
http://www.google.com/search?q=c+vs+java
A search will often get you faster, more and better results -
Is there a "real fix" to get iMessage and FaceTime working? Tried the 8.8.8.8 and time,rest thing. Passwords and Apple ID are ok. At log in the message says it's a network connection.
Any ideas? Is here a fix coming from Apple?Apps are on my iPad and worked fine with iOS 6. When iOS7 was loaded, I can no longer sign in to these two apps using my Apple ID. These apps are on my phone and work fine. This problem is on on my iPad.
-
Query Help. Seems easy but complicated for me
Hey guys im trying to setup my application to check weather or not a user has an account made in my database.
The login uses a different authentication method then the application. As the login pulls from our intranet office database and the app uses users in a local apex db.
I need a query that will check after auth if the user has a account stored in apex db if so then the user will be redirected to page 4, if not then the user will be directed to page 7.
QUERY IM ATTEMPTING WITH NO RESULT
select count(*) from odf_user where login_name = :APP_USER.
if count(*) > 0 then (
wwv_flow_custom_auth_std.login( P_FLOW_PAGE => :APP_ID||':4');
else
www_flow_custom_auth_std.login( P_FLOW_PAGE => :APP_ID||':7');
endif;Heres the code
declare
l_count NUMBER;
begin
select count(*) into l_count from odf_user where upper(login_name) = upper(:P101_USERNAME);
if l_count > 0 then
wwv_flow_custom_auth_std.login(
P_UNAME => v('P101_USERNAME'),
P_PASSWORD => :P101_PASSWORD,
P_SESSION_ID => v('APP_SESSION'),
P_FLOW_PAGE => :APP_ID||':4'
else
wwv_flow_custom_auth_std.login(
P_UNAME => v('P101_USERNAME'),
P_PASSWORD => :P101_PASSWORD,
P_SESSION_ID => v('APP_SESSION'),
P_FLOW_PAGE => :APP_ID||':7'
end if;
end; -
Looks like a simple query but need your help
Hello everyone,
I have a simple problem but I can't get over it. Actually, it looks like a simple problem, but I can't do it. So,it's probably not... Anyone can help me with this?
Imagine the following data:
ALTER SESSION SET NLS_DATE_FORMAT = 'DD/MM/YYYY HH24:MI:SS';
SELECT TRUNC(SYSDATE) - TO_DATE('01/01/11', 'DD/MM/RR') FROM dual; -- 564
DROP TABLE runs;
CREATE TABLE runs
start_date DATE,
end_date DATE
-- generate some random data
INSERT INTO runs(start_date)
SELECT TO_DATE('01/01/11', 'DD/MM/RR') + trunc(dbms_random.value(0,564))
FROM dual
CONNECT BY LEVEL <= 10000;
-- still generating sample data
UPDATE runs
SET end_date = start_date + dbms_random.value(0,20000) / 86400; -- 20000 sec is the max
COMMIT; If you execute the previous "script", you'll end up with a table called RUNS with 10.000 records. Each record contains a start date and an end date which is max 20.000 second after the start date.
What I would like to do is a report based on these data.
I need something like this:
(first week of 2011 started on sunday. So I go back to the last monday of 2010)
WEEK_NUMBER AVG_FOR_MONDAY_BY_WEEK CUMULATIVE_AVERAGE_FOR_MONDAYS
Week 1: 26/12/2010 - 01/01/2011 9999 88888
Week 2: 02/01/2011 - 08/01/2011 1111 22222
....For each week, I would like to have the average duration (which is the difference in seconds between end_date and start_date) by day (monday needs to have its average, tuesday, wednesday...too)
And I also need a cumulative average by week and by days (mondays, tuesdays...). This cumulative average needs to be based on all the preceding rows.
Can anyone help me with this query? I'm using Oracle 10g
ThanksHi,
Something along these lines :
alter session set nls_date_language = "english";
with all_data as (
select to_char(start_date, 'IYYYIW') as wk
, to_char(start_date, 'dy') as dy
, (end_date - start_date)*86400 as duration
from runs
week_data as (
select wk
, round(avg(case when dy = 'mon' then duration end)) as avg_mon
, round(avg(case when dy = 'tue' then duration end)) as avg_tue
, round(avg(case when dy = 'wed' then duration end)) as avg_wed
, round(avg(case when dy = 'thu' then duration end)) as avg_thu
, round(avg(case when dy = 'fri' then duration end)) as avg_fri
, round(avg(case when dy = 'sat' then duration end)) as avg_sat
, round(avg(case when dy = 'sun' then duration end)) as avg_sun
from all_data
group by wk
select wk
, avg_mon
, sum(avg_mon) over(order by wk) as cum_avg_mon
, avg_tue
, sum(avg_tue) over(order by wk) as cum_avg_tue
, avg_wed
, sum(avg_wed) over(order by wk) as cum_avg_wed
, avg_thu
, sum(avg_thu) over(order by wk) as cum_avg_thu
from week_data
order by wk;
WK AVG_MON CUM_AVG_MON AVG_TUE CUM_AVG_TUE AVG_WED CUM_AVG_WED AVG_THU CUM_AVG_THU
201052
201101 9836 9836 8737 8737 9088 9088 12167 12167
201102 7639 17475 10319 19056 7391 16479 8036 20203
201103 8275 25750 8883 27939 8525 25004 11682 31885
201104 7029 32779 10850 38789 7360 32364 7617 39502
201105 10292 43071 11421 50210 11141 43505 9469 48971
201106 11612 54683 9762 59972 11464 54969 9517 58488
201107 8645 63328 10206 70178 10124 65093 11917 70405
201108 11466 74794 11678 81856 10839 75932 9587 79992
201109 8745 83539 6803 88659 8963 84895 9496 89488
201110 10443 93982 8104 96763 10314 95209 10908 100396
201111 8183 102165 9467 106230 11495 106704 12040 112436
201112 8575 110740 9207 115437 10338 117042 9561 121997
201113 10273 121013 6268 121705 11288 128330 12335 134332
201114 10176 131189 8561 130266 10367 138697 7983 142315
201115 10587 141776 12073 142339 8528 147225 12271 154586
201116 9393 151169 10761 153100 7901 155126 10020 164606
201117 11459 162628 9471 162571 10136 165262 8188 172794
201118 11946 174574 9997 172568 9367 174629 10475 183269
201119 12869 187443 9848 182416 7692 182321 9632 192901
201120 9675 197118 7408 189824 11646 193967 9614 202515
201121 10742 207860 10302 200126 9208 203175 7543 210058
201122 8083 215943 8323 208449 10045 213220 9498 219556
201123 11838 227781 8820 217269 8804 222024 10485 230041
201124 8748 236529 12143 229412 9684 231708 8402 238443
201125 11504 248033 10586 239998 10073 241781 9573 248016
201126 7289 255322 14241 254239 10100 251881 11843 259859
201127 10855 266177 9980 264219 10320 262201 11023 270882
201128 11004 277181 9975 274194 11609 273810 8945 279827
201129 10488 287669 9402 283596 11985 285795 9481 289308
201130 7338 295007 8963 292559 11982 297777 8177 297485
201131 9778 304785 10024 302583 10732 308509 10749 308234
201132 10360 315145 12577 315160 8643 317152 10001 318235
201133 9845 324990 10416 325576 9996 327148 10548 328783
201134 9540 334530 8138 333714 9401 336549 9093 337876
201135 7000 341530 9920 343634 10370 346919 10937 348813
201136 11307 352837 8889 352523 12339 359258 8491 357304
201137 11785 364622 9146 361669 9232 368490 11023 368327
201138 7857 372479 6784 368453 8502 376992 12558 380885
201139 9842 382321 10616 379069 10435 387427 7848 388733
201140 10578 392899 9402 388471 8806 396233 9927 398660
201141 6711 399610 13015 401486 9934 406167 10011 408671
201142 10088 409698 10380 411866 7836 414003 9205 417876
201143 8132 417830 11772 423638 10792 424795 10834 428710
201144 9921 427751 7454 431092 9551 434346 10754 439464
201145 13196 440947 11600 442692 11303 445649 10455 449919
201146 12022 452969 8996 451688 10221 455870 12567 462486
201147 8965 461934 10068 461756 10607 466477 13486 475972
201148 9483 471417 9264 471020 9601 476078 8685 484657
201149 11738 483155 9000 480020 10284 486362 11263 495920
201150 10338 493493 10237 490257 10357 496719 10984 506904
201151 10777 504270 11138 501395 10543 507262 9840 516744
201152 9881 514151 10692 512087 11432 518694 10122 526866
201201 11089 525240 8077 520164 12391 531085 9649 536515
201202 9871 535111 8326 528490 9449 540534 10551 547066
201203 10625 545736 11609 540099 9626 550160 5795 552861
201204 8856 554592 9679 549778 10722 560882 11064 563925
201205 9379 563971 9943 559721 8409 569291 11656 575581
201206 10843 574814 10070 569791 12162 581453 10764 586345
201207 8424 583238 8484 578275 8382 589835 8716 595061
201208 11159 594397 10415 588690 11459 601294 11317 606378
201209 11264 605661 8244 596934 9682 610976 10192 616570
201210 11514 617175 9322 606256 9101 620077 10571 627141
201211 9348 626523 7501 613757 12297 632374 11170 638311
201212 10523 637046 7605 621362 10348 642722 10068 648379
201213 10411 647457 11686 633048 10212 652934 9574 657953
201214 9394 656851 10526 643574 8521 661455 9829 667782
201215 8994 665845 12256 655830 8243 669698 10592 678374
201216 11491 677336 10939 666769 12846 682544 9708 688082
201217 9737 687073 9611 676380 7244 689788 10943 699025
201218 9024 696097 11286 687666 10033 699821 10314 709339
201219 9851 705948 9851 697517 9159 708980 9917 719256
201220 7785 713733 10490 708007 8534 717514 8528 727784
201221 11107 724840 8197 716204 8926 726440 10834 738618
201222 8093 732933 11853 728057 11697 738137 10081 748699
201223 9371 742304 10796 738853 11068 749205 9904 758603
201224 10600 752904 8487 747340 10838 760043 8009 766612
201225 11090 763994 9595 756935 10736 770779 9387 775999
201226 8234 772228 12759 769694 9119 779898 8422 784421
201227 9738 781966 9383 779077 8978 788876 11635 796056
201228 11687 793653 10302 789379 9459 798335 10608 806664
201229 9245 802898 11290 800669 798335 806664
82 rows selected -
My iphone 4s cannot join a public unsecured network, but my ipad and macbook can with no problems. I have reset the network settings on the iphone twice. Both times that fixed the problem but only for a few minutes, then I get the "cannot join network" message again. Please help! What can I do?
Anyone have any ideas or information to help with this? Any help and consideration is MUCH appreciated.
-
When i want to send sms to my friend who has a imessage also, but the problem is when i have no internet in my phone it should be automaticaly send as a simple sms but in my phone even if i have no internet my sms will send as a imessage.
Iphone 5c, ios 8.0.2And this is how iMessage works (as gdgmacguy tried to explain):
Messages lets you exchange text messages with other SMS/MMS devices using your cellular connection, and with other iOS devices using iMessage.
iMessage is an Apple service that lets you send unlimited messages over an active Wi-Fi (or cellular data*) connection to other iOS devices using iOS 5 or later or Macs using OS X Mountain Lion or later. With iMessage you can see when other people are typing and let them know when you've read their messages. iMessages are displayed on all your iOS devices logged in to the same account, so you can start a conversation on one of your devices, and continue it on another device. For security, iMessages are encrypted before they're sent
* Cellular data connectivity requires iPhone or iPad (Cellular Models).
If you are sending an iMessage to another iOS device that is registered to Messages, then it will send it as an iMessage unless iMessage is not available.
GB -
pls i need help for this simple problem of my palm os zire 72. pls share your ideas with me.... i tried to connect my palm os zire72 in my desktop computer using my usb cable but i can't see it in my computer.. my palm has no problem and it works well. the only problem is that, my desktop computer can't find my palm when i tried to connect it using usb cable. is thier any certain driver or installer needed for it so that i can view my files in my palm using the computer. where i can download its driver? is there somebody can help me for this problem? just email me pls at [email protected] i really accept any suggestions for this problem. thanks for your help...
If you are using Windows Vista go to All Programs/Palm and click on the folder and select Hot Sync Manager and then try to sync with the USB cable. If you are using the Windows XP go to Start/Programs/Palm/Hot Sync Manager and then try to sync. If you don’t have the palm folder at all on your PC you have to install it. Here is the link http://kb.palm.com/wps/portal/kb/common/article/33219_en.html that version 4.2.1 will be working for your device Zire 72.
-
i have problem with fonts for my site, i have used "Lucida sans unicode " family for certain texts. it shows perfect in mozilla 3.5 and mozilla 4. But the font not supporting in mozilla 5.0? please help me
i have problem with fonts for my site, i have used "Lucida sans unicode " family for certain texts. it shows perfect in mozilla 3.5 and mozilla 4. But the font not supporting in mozilla 5.0? please help me
Maybe you are looking for
-
Problem viewing video-content folders in Adobe Bridge
Hi there. I have problem browsing folders inside Adobe Bridge CS6. When I get into a folder that contains files that are not just images, Adobe Bridge would not responding and would have to be closed. With the folders contains only images I have no f
-
How many users have been logged on by this month
I need to do a list of the users have been logged on by this month in the central instance and in the application servers. Someone can help me? I will apreciate your answers. Best Regards.
-
Sharing iTunes account is confusing my storage settings.
I share the same iTunes library as my dad. He's really into his music and so in the library has 1332 songs that cover around 5000 minutes. Of course, I don't really like his music but I have my own music within that library too. When I sync my phone
-
Junk mail filter and feedback email address
What's the feedback email address because I want to suggest Apple adds a spam filter to the phone already. Can you believe they don't have one.
-
Purchase Info record Datasource / Infosource (URGENT!!!)
BW GURUS! My client has an urgent need to extract their Purchase infor record in R/3 to the BW Environment. I am still new to BW Application - My solution is creating a custom Datasource in R/3 using the Purchase infor record Master table in R/3, the