Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 easy graphics in java question
Index -> Programming, Java -> Java Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ify




PostPosted: Thu May 06, 2004 9:02 pm   Post subject: easy graphics in java question

Very Happy Smile Rolling Eyes Twisted Evil Idea Question QuestionLaughing Embarassed Razz Mad Crying or Very sad Wink Rolling Eyes Idea Twisted Evil Evil or Very Mad Evil or Very Mad Arrow

i was wondering if there is a realy simple way to get images into java such as like a .jpeg file cause im sort of bad at java anyone wanna help thanks

Question Question Question Question Question Question Exclamation Very Happy Smile Sad Surprised Shocked Confused 8) Laughing Embarassed Razz Mad Crying or Very sad Wink Rolling Eyes Idea Twisted Evil Evil or Very Mad Evil or Very Mad Arrow
Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: Fri May 07, 2004 12:09 pm   Post subject: (No subject)

There is no need to use that many emoticons in a post and deftly not one asking for help. U do not even use them in any context, just randomly picking them. Overdoing it with emoticons slows down the load time of the page and this may not seem like a big isues to you but it is for poleop wiht slow speed and for this site b/c it uses up more bandwith withc means more $.


Any how now that my rant is done, what do you mean by simple? If by that u mean not using awt or swing, then i do not think there is a way to do graficks in prue java with out them (or at least not easly). If you whont some graficks you are going to have to get in to the awt API stuff, just can not do graficks in the consloe (well at least not easly or have them look or run good).
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
ify




PostPosted: Fri May 07, 2004 1:43 pm   Post subject: nm i figured it out

nevermind[/b]
communismisntdead




PostPosted: Mon May 10, 2004 9:10 am   Post subject: (No subject)

See my post in the 'Image in HSA Console' thread. It might help.

HackerDan, no offense, but lighten up, its just a bunch of emoticons, who cares?...
jono11




PostPosted: Mon May 10, 2004 9:11 am   Post subject: Meh

Hacker Dan, I'm sure he appreciates the help but lighten up on the guy a bit. He's probably some inferior programmer who has no idea about technical terms. Dont let it get under your skin. They are just stupid emoticons. Party on Wayne...


:D :) :( :o :shock: :? 8) :lol: :cry: :oops: :P :x :evil: :twisted: :roll: :wink: :arrow: :idea: :?: :!:
Dan




PostPosted: Mon May 10, 2004 4:54 pm   Post subject: (No subject)

Your school or w/e is starting to realy push it with the spaming, i mean almost all the users who post from your ip seem to be masive spamers...

Plz tell your frends to stop b/c i dont whont to block your ip ragne or delete all the users who post from that ip.


Any how:

communismisntdead wrote:
See my post in the 'Image in HSA Console' thread. It might help.


the HSA console is not real java, it is an unstareted libbray for ready to progame. I whould highly reocmened not using it unless u have to.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
communismisntdead




PostPosted: Tue May 18, 2004 1:35 pm   Post subject: (No subject)

Yeah.. too bad none of these people are from my school.

I said it 'might help', I didn't say it's the answer to life's questions. Just trying to help (remember how to do that?)
Dan




PostPosted: Tue May 18, 2004 4:00 pm   Post subject: (No subject)

communismisntdead wrote:
Just trying to help (remember how to do that?)


That could be interptited as an insulet. Are you trying to impley that i do not help any one on this site?

Also do you go to Centre Dufferin District High School? The logs say your posts and some other poleops like jono11 are coming from the same place. Witch looks like it is from a high school, posably called Centre Dufferin District. If you are not from the same school as them, it inrests me as to why you whould be posting from the same ip.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Sponsor
Sponsor
Sponsor
sponsor
communismisntdead




PostPosted: Wed May 19, 2004 8:38 pm   Post subject: (No subject)

Yes, I suppose that COULD be taken as an insult. I wasn't insinuating that you don't help anyone, just that occasionally you do more harm than good with arrogance. Which is not always a bad thing. No insults intended.

And why would you find out our ip's? Do you have a life?
Dan




PostPosted: Wed May 19, 2004 8:46 pm   Post subject: (No subject)

while there is a system to check ips betwen users so i know if one person is singing up for like 100 user acounts. Also the ip buttion is like right above your post when u are a mod so it is not like it is hard to do (it is stander practices to check ips of users who could be pentaily disroptive to the comunity)

Also i may some times seem arrogant but if no one trys inforce the rules this hole site will turn in to the spam area.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
communismisntdead




PostPosted: Fri May 21, 2004 10:09 am   Post subject: (No subject)

Yes, I know what you mean. It just seemed that you were being jerk, but you are right, order must be kept... In any case lets set aside our differences, help, and be helped. That's what this place is for.
Flashkicks




PostPosted: Wed May 26, 2004 7:48 am   Post subject: (No subject)

Id have to completely agree with HackerDan- Just bcuz he is trying to do whats right and what the site really needs, every ones mad at him.. Just like how EVERYONE [almost] hates cops.. WHY??.. bcuz they are doing thier JOB... im sure you get my point. Either way- i need help with this same topic. My question; just in simple terms- how do you insert a pic [bmp, jpeg] into Java; preferably an applet. I am working on our school website-ish and I am supposed to have an applet and I have pics to put in it- its a Math type thingy. So how can I upload all my graphs and whatnot to the applet? Some sample coding would be REAL nice... Seeing how Iv never done this before...
Dan




PostPosted: Thu May 27, 2004 2:47 pm   Post subject: (No subject)

To load an image file in to the progame u can use this comand:

code:

Image myImage = getToolkit().getImage(filename);


Where filename is a string.

This gets the data in but displaing it is another matter. To display any graficks (like lines, ect) you need a paint method like this:

code:

public void paint(Graphics g)
{
        g.drawImage(myimage, x, y, this);
}
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Flashkicks




PostPosted: Fri May 28, 2004 7:29 am   Post subject: (No subject)

Thanks very much- i messed around with it and came up with this; The image SOMETIMES loads... :S And when it does- it takes YEARS to load... Do you understand Why at all??... Here is my coding; [My teacher helped me with this and said I will be needing all the code that you see.. I personally think it is a Bit too much just for placing a Dang pic on the screen.. Or is it??... Rolling Eyes Is Java really THAT bad?? Laughing ]
code:
import java.awt.*;

public class LoadFrameImage extends Frame
{
    Image img;
    //Constructor loads the pic, sets the frames size and makes the Frame appear.
    public LoadFrameImage ()
    {
        img = getToolkit ().getImage ("building.jpeg");
        System.out.println (img);
        setSize (300, 300);
        show ();
    } //Constructor


    //Called when Frame needs to be repainted
    public void paint (Graphics g)
    {
        g.drawImage (img, 50, 50, null);
    } //Paint method


    //the main method called when proggy is executed.
    //Creates a single copy of the LoadFrameImage window
    public static void main (String [] args)
    {
        new LoadFrameImage ();
    }
} //LoadImage class


~Flashkicks
Dan




PostPosted: Fri May 28, 2004 10:47 pm   Post subject: (No subject)

There are many ways to load pics in java deponding on alot of things, but most are about that long for simple ones, for my RPG FP in java i am working on the buffering system is serveral pages of code.

It is not b/c java is a bad lang, it just gives u alot more contorl over it and it also uses the conspects of OOP witch make some things seem a bit complected.

This is a very very very simplifed verson of the way i do it in my FP:

code:

import java.awt.*;
import javax.swing.*;
import java.awt.image.*;

public class TestingPic
{
        public static void main(String args[])
        {
                JFrame frame = new JFrame();
                MyPanel panel = new MyPanel("test.jpg");
               
        frame.setContentPane(panel);
        frame.setDefaultCloseOperation(3);
        frame.setBounds(new Rectangle(500, 500));
        frame.setVisible(true);

        panel.repaint();
        }
}

class MyPanel extends JComponent
{
        private Image myImage;
       
        public MyPanel(String imageName)
        {
                super();
                setImage(imageName);
        }
       
        public void paint(Graphics g)
        {
                super.paint(g);
                g.drawImage(myImage, 0, 0, this);
        }
       
        public void setImage(String fileName)
        {
                myImage = getToolkit().getImage(fileName);
        }
}


It loads prity fast, alougth it is in the from of an appliaction and not a applet. I think it should be easy to modify it to be an applet.

Honstly i am not the best person to talk about java awt and swing stuff, i have just been geting in to it my self this year. May be you can find our java mod around and ask him about it if u need more info.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: