HELP!!!!??? Please???? I have ghosts....
for some reason my buttons and everything are repainting themselves offset from eachother....I need to finish by tonight. If anyone can help I'd appreciate it. It's suppose to show a tree and if certain boxes are checked it will draw these items. Once the buyIt button is clicked it's suppose to total the price and put it into input. Here's the code.
import javax.swing.*; // Packages used
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import java.applet.*;
public class DrawingOnPanel extends JFrame
public DrawingOnPanel(){
//super(title);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
TreeStore1 ts = new TreeStore1();//inner class object
getContentPane().add(ts);
setSize(600,600);
setVisible(true);
public class TreeStore1 extends JPanel implements ActionListener
private JLabel prompt1 = new JLabel("Merry Christmas!");
private JLabel prompt2 = new JLabel("What would you like on you tree? ");
private JLabel prompt3 = new JLabel("Your total is: ");
private JButton buyIt = new JButton("Buy It!");
private JPanel myPanel = new JPanel();
private double treePrices=19.95;
private double lights=20;
private double bulbs=15;
private double star=9.99;
private JTextField input = new JTextField(13);
DecimalFormat format=new DecimalFormat("$#,###.00");
Color greenx = new Color(0,17,0);
Color greeny = new Color(0,34,0);
//day tree start
Color green1 = new Color(0,51,0);
Color green2 = new Color(0,68,0);
Color green3 = new Color(0,85,0);
Color green4 = new Color(0,102,0);
Color green5 = new Color(0,119,0);
//night tree end
Color green6 = new Color(0,136,0);
Color green7 = new Color(0,153,0);
Color green8 = new Color(0,170,0);
Color green9 = new Color(0,187,0);
Color green10 = new Color(0,204,0);
Color green11 = new Color(0,221,0);
Color green12 = new Color(0,238,0);
Color green13 = new Color(0,255,0);
//day tree end
Color brown = new Color(102,51,0);
JCheckBox treeBox = new JCheckBox("Christmas Tree", true);
JCheckBox lightsBox = new JCheckBox("Lights", false);
JCheckBox bulbsBox = new JCheckBox("Bulbs", false);
JCheckBox starBox = new JCheckBox("Star", false);
Font bigFont = new Font("ComicSans",Font.BOLD,14);
Font biggerFont = new Font("ComicSans",Font.BOLD,22);
public TreeStore1 () {
add(prompt1);
add(prompt2);
add(prompt3);
add(treeBox);
add(lightsBox);
add(bulbsBox);
add(starBox);
add(buyIt);
treeBox.setFont(bigFont);
lightsBox.setFont(bigFont);
bulbsBox.setFont(bigFont);
starBox.setFont(bigFont);
prompt1.setFont(biggerFont);
input.setEditable( false );
buyIt.addActionListener(this);
public void paintComponent(Graphics tree){
/* prompt1.repaint();
prompt2.repaint();
treeBox.repaint();
lightsBox.repaint();
bulbsBox.repaint();
starBox.repaint();
prompt3.repaint();
buyIt.repaint();
input.repaint();*/
prompt1.setLocation(250,5);
prompt2.setLocation(5,55);
treeBox.setLocation(5,105);
lightsBox.setLocation(5,155);
bulbsBox.setLocation(5,205);
starBox.setLocation(5,255);
prompt3.setLocation(20,355);
buyIt.setLocation(100,600);
input.setLocation(220,600);
tree.setColor(brown);
tree.fillRect(375,450,30,40);
for(int t=230;t<550;t+=1)
if(t<254)
tree.setColor(green1);
else if(t<278)
tree.setColor(green2);
else if(t<302)
tree.setColor(green3);
else if(t<326)
tree.setColor(green4);
else if(t<350)
tree.setColor(green5);
else if(t<374)
tree.setColor(green6);
else if(t<398)
tree.setColor(green7);
else if(t<422)
tree.setColor(green8);
else if(t<447)
tree.setColor(green9);
else if(t<472)
tree.setColor(green10);
else if(t<498)
tree.setColor(green11);
else if(t<522)
tree.setColor(green12);
else
tree.setColor(green13);
tree.drawLine(390,300,t,450);
//second tree
for(int t=250;t<525;t+=1)
if(t<270)
tree.setColor(green1);
else if(t<292)
tree.setColor(green2);
else if(t<314)
tree.setColor(green3);
else if(t<336)
tree.setColor(green4);
else if(t<358)
tree.setColor(green5);
else if(t<380)
tree.setColor(green6);
else if(t<400)
tree.setColor(green7);
else if(t<420)
tree.setColor(green8);
else if(t<440)
tree.setColor(green9);
else if(t<460)
tree.setColor(green10);
else if(t<480)
tree.setColor(green11);
else if(t<500)
tree.setColor(green12);
else
tree.setColor(green13);
tree.drawLine(390,260,t,410);
//third tree
for(int t=265;t<515;t+=1)
if(t<285)
tree.setColor(green1);
else if(t<305)
tree.setColor(green2);
else if(t<325)
tree.setColor(green3);
else if(t<345)
tree.setColor(green4);
else if(t<365)
tree.setColor(green5);
else if(t<385)
tree.setColor(green6);
else if(t<405)
tree.setColor(green7);
else if(t<425)
tree.setColor(green8);
else if(t<445)
tree.setColor(green9);
else if(t<465)
tree.setColor(green10);
else if(t<485)
tree.setColor(green11);
else if(t<505)
tree.setColor(green12);
else
tree.setColor(green13);
tree.drawLine(390,260,t,380);
/* prompt1.repaint();
prompt2.repaint();
treeBox.repaint();
lightsBox.repaint();
bulbsBox.repaint();
starBox.repaint();
prompt3.repaint();
buyIt.repaint();
input.repaint();*/
public void actionPerformed(ActionEvent e) {
// if (e.getSource() == buyIt) {
public static void main(String args[]) {
new DrawingOnPanel();
} // main()
}
Thanks for all the unformatted code it's quite a treat....
Anyway. When you update/repaint/paint etc you need to paint over the old stuff.
- set the graphics color to be whatever you want the background to be
- use fill rect starting from 0 x and 0 y and to the dimensions of your image
Similar Messages
-
I am pulling my hair out! I am using adobe indesign and just want to make a text box 'autofit text' as I change fonts a lot and want the font to automatically re-size as I change it.
Is it not possible to create a text box, fill it with dynamic (data driven) text, but make the font size either scale up or down automatically, so that the entire text box is filled? This is a feature in PrintShop Mail Pro called COPY FIT. but no such feature in Indesign??
help help help please - I have latest version of indesign - thanks, DJlol... it seems to work, but I have another huge problem!
Apparently .CSV files cannot contain page breaks in the data! The data I am trying to merge is a 'letter', with paragraphs, line breaks, etc.,
But, after data merging, it ignores page breaks and only merges the first paragraph of each letter. (sigh)
Solution? Hopefully, an EASY solution. lol as we have thousands of records.
Is there a third party indesign plugin that will allow .xml, or .xls data merge import??
Thx,
DJ -
My ipad keeps crashing and this time it won't come back on it just keeps telling me to connect to itunes which I did and it just keeps telling me it can't restore this ipad because an error has occured! Really need help please?
If it keeps coming up with an unknown error - no error code given - try another computer. If that doesn't work, it's time to take it to an Apple Store or an authorized service center to have the device evaluated.
-
Hello - can someone help me please - I am not really well versed in modern electronics
So, as I mentioned in my heading which is rather long (sorry lol) I have had a bad computer virus, now fixed, which has lost me a lot of information. This includes the content of ,my iTunes Library and my ability to access it.
So, can someone help me by telling me how I can gethte music currently in my iPhone back in to the Music Library in my new version of iTunes. Aslo hiow do I now get Album Artwork in to iTunes as well - iI recall that it was really easy when I set it up but this new version is causing me all sorts of heartache when I tried just now - hence my plea for help.
I hope you can help and that I can hear fromoyuvery soon
Thanks guys
KeithiDevices are not backup devices.
Use the backup of the computer to put the content back on the computer.
If not backup exists and the content was purchased via iTunes, connect the device and select File > Transfer purchases. This will not restore playlists, playcounts or any other library specific data.
If the media was not purchased via iTunes, search google for ways to extract it from the iPhone.
Whatever you do, going forward make sure you back up your media and other important files regularly. -
Help please. Have library- no music on ipod.
The other day I downloaded a bunch of songs and something popped up and said I didn't have any more space for those songs so one of the settings changed and put all of my songs into one playlist. On the actual ipod there weren't any playlists except for one with all of my songs on it. Then I accidentally deleted that playlist on my itunes and now I don't have any music on my ipod at all. I don't know how to change or even find a way to change my itunes settings so I have music again. All of my songs are still in itunes, they just don't sync to my ipod. PLEASE HELP!!!
When your iTunes library exceeds the capacity of your iPod, iTunes will give you an option for it to make a playlist for your iPod, in your case Nano, to sync to, this is the playlist you accidentally deleted. All you have to do is make a couple of playlists in iTunes containing the music that you wish to have on your Nano. Once those playlists are made in iTunes, then dock your Nano & change its preferences to sync only those specific playlist or lists that you have just made.
-
and I am having problems in receiving my emails, it says that I have to reset my password. When I try and log in it says: username/password incorrect.
Have requested the password to be sent to my device, which I have now received but still unable to log in....not sure if I am using the correct username. Have been trying for days to obtain a reply from my provider (virgin) but they are unable to help.
does anyone know how I can retrieve my username? plz plz plz....I am going mad!
thank you.Hi and Welcome to the Forums!
Sadly, the only place to retrieve the information you need is from your carrier. Request escalation from their initial level 1 support up to their dedicated BB support staff.
Good luck!
Occam's Razor nearly always applies when troubleshooting technology issues!
If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
Join our BBM Channels
BSCF General Channel
PIN: C0001B7B4 Display/Scan Bar Code
Knowledge Base Updates
PIN: C0005A9AA Display/Scan Bar Code -
Help please, I have created two document folders???
I have somehow created 2 Document folders, now when I save a document I have to check both folders to find it. How do I fix this please? I have a Mac OS X V 10.6.8
Put all the files into one folder and delete the other. The default folder is the one you should keep. This will be the one in your /Home/ folder.
-
Re: [HELP PLEASE Q_Q]Gs60 Ghost pro - 606 constant ping spike
Hi,
Thank you very much ! about this topic, I was looking for upgrade my computer to Win 10.
Do I have to enable "Windows 8 features" in the bios ?
Thanks for helpQuote from: jkitsjkim on 21-July-15, 04:32:44@runningman
Hi, sorry for the really really late reply.
I read everything that FAQ said about improving my connectivity, but those are about Intel wireless.
I am using Kil... -
Help please, i have a problem with DATA MERGE !
why my coloumns are in one line ? after clicking "select data source" i have this problem, in csv file is everything allright !
hmm, i noticed one thing, when i save file in .CSV, and after i save the same file in .XLSX, in ID it opens .CSV like this
but when i save file in excel as CSV again, and re-open it in ID then it shows me that error -
This issue happened randomly. I was working away and the bluetooth just disappeared. The first time this happened, I reset the SMC and it solved the issue. Now, nothing seems to work including removing the bluetooth plist file. Any ideas on how to fix? Thanks.
To find out if it's system wide or user specific, try this...
Open System Preferences>Users & Groups, unlock the lock, click on the little plus icon, make a new admin account, log out & into the new account.
Does it work in the new account? -
Itunes store wont work HELP PLEASE! HAVE HAD THIS PROBLEM FOR 4 MONTHS!
everytime i go to my itunes store it tells me that something is wrong with the network connetions and i need to check my network setting and i aready ran a diagnostics test for itunes but everything was fine and if i put my firewall on it sti says the error and if i turn it off it still tells me that.
Message was edited by: homeeMake sure Norton has all the most recent updates. Then go into Norton, delete iTunes from the allowed programs, and save the Norton settings and close Norton.
Then go back into Norton and add iTunes like it is a new program, and save the settings.
This has worked for lots of folks. -
My ipad just won't let me sign in with my apple password on FaceTime or iMessage since updating to ios7 it says check my network connection, even though my iPhone works fine with the same password, can anybody help please, I have tried numerous things but nothing works. Will I have to wait for a bug fix to sort this? I hear they are working on one a the minute, I hate ios7
Try a Restart.
Press and hold the Sleep/Wake button for a few seconds until the red "slide to power off" slider appears, and then slide the slider. Press and hold the Sleep/Wake button until the Apple logo appears.
Resetting your settings
You can also try resetting all settings. Settings>General>Reset>Reset All Settings. You will have to enter all of your device settings again.... All of the settings in the settings app will have to be re-entered. You won't lose any data, but it takes time to enter all of the settings again.
Resetting your device
Press and hold the Sleep/Wake button and the Home button together for at least ten seconds, until the Apple logo appears. Apple recommends this only if you are unable to restart it.
Or if this doesn't work and nobody else on the blog doesn't have a better idea you can contact Apple.
Here is a link to their contacts with most of the information below.
http://www.apple.com/contact/ -
i have just upgraded my iphone 4 to a 5. and was trying to back my 4 up on the computure so i could get all my pics and music on to my 5. but its saying i need to update my itunes which i have tried to do and is still not working any help please i have been trying for hours
how is it not working?
what version of itunes?
what ios on iphone4?
does it give an error msg? -
i updated my ipod the other day and since i have been unable to open any apps that connect to the internet, its says "operation could not be completed. invalid argument". anybody help please?
Have yu tried the standard fixes:
- Reset the iPod:
Press and hold the On/Off Sleep/Wake button and the Home
button at the same time for at least ten seconds, until the Apple logo appears.
Restore the iPod via iTunes, First from backup and if problems persist, restore to factory defaults/new iPod. -
Help please I have just got my Ipad Mini and set it up but cant remember the code I put in. I cant access settings or anything else as it has locked me out. Ive treid Icloud but it doesnt recognise tht I have registered. Can anyone give me straightforward instructions on how to start again please
This is the guidance from Apple:
http://support.apple.com/kb/HT1212
Barry -
Why can I not find a miniport to external monitor cable that works? I have bought for different types, two from Apple, cost me $300+ and still have no external monitor. Help, please.
What have you bought?
What model Mac are you running?
What input sources are available on the display you are connecting it to?
Maybe you are looking for
-
Ever since my upgrade to lion 10.7.3, and iCloud, my macbook is running extremely slow. What can I do? It doesn't seem like my contacts are pushing through to the computer from iPhone.
-
Printing - Adding the File Location as a Document Footnote
Re: Acrobat 7.0 Standard Have about 1000 PDF files --- each with a filename that's a specific number, from 1 through 1000 (the number --- aka, the filename --- is the section the document represents... there's 1000 sections in the project) Simply put
-
How do I reboot my machine when it is flashing a question mark folder?
How do I reboot my machine when it is flashing a question mark folder?
-
Hey all, for now I can't afford a drawing tablet so I was wondering if anyone could suggest the best stylus for my MacBook Pro so that I could perform some simple drawings? Thanks, Crayton
-
Default file location for project files
When I create a new project how do I specify an alternate destination for the files rather than my home folder