Best Way to Draw A Simple Isoceles Triangle, and Fill it.

Hi,
What I assume is a relativly simple problem, ive got the coordinates of the bottom two points of an isoceles triangle, and the height, and need to draw it in Java2D. It's base will always be parrellel to the bottom of the screen.
I also need to be able to fill or not fill it very simple, what would be the best way to do this?
Thanks for your time,
atreides7887

Create your triangle as an instance of [java.awt.Polygon|http://java.sun.com/javase/6/docs/api/java/awt/Polygon.html] and call [java.awt.Graphics2D.fill(Shape s)|http://java.sun.com/javase/6/docs/api/java/awt/Graphics2D.html#fill(java.awt.Shape)] to paint the triangle to a BufferedImage or in a paintComponent override.
Read the other methods of Graphics2D for the rest of your answer.
db

Similar Messages

  • Best way to code a simple wait/delay?

    What is the best way to code a simple wait/delay so that my application idles for a few seconds before continuing? I'd rather not use a loop to do this and am looking for a better solution. This code will not be threaded, so I'm not going to use sleep(). TIA

    From the OS level, yes it is a process; from Java's perspective, it's a Thread, at least in Sun's implementation.
    According to the JVM specification, section 2.1.9, "The Java virtual machine initially starts up with a single nondaemon thread, which typically calls the method main of some class. The virtual machine may also create other daemon threads for internal purposes. The Java virtual machine exits when all nondaemon threads have terminated."
    http://java.sun.com/docs/books/vmspec/2nd-edition/html/Concepts.doc.html#33308

  • Best way to extend wireless via airport express and time capsule

    best way to extend wireless via airport express and time capsule
    i live in a two storey house where i use my airport express to create a wireless network in the main floor, and time capsule to extend it in the upper floor, where my room is. i have like 16 mbps in the main floor, and 2-3 mbps in the upper floor after having speediest.
    i used time capsule in the upper floor because i use wireless backup daily and don't want to put internet down while i im doin it and consequently my parent can have internet access in the main floor, am i right? or do i have make just the opposite in order to have a good internet speed?
    secondly, while checking airport express wireless mode on airport utility, there is like 4 different type of radio mode(802 11n bg comp, 802 11n 2.4, 802 11n a comp, 802 11n 5ghz) which i have no idea what they mean
    what do you recommend?
    we have like iphone4, iphone 3g, mbookpro, ipad, ipad 2, samsung tv and a sony vaio laptop in the wireless network
    thank you

    What you have would appear to be working but I can comment how I would redefine your setup.  Note that both Airport Express and Time Capsule can function as wireless base stations so you do have wireless everywhere and at all times — using the Time Capsules for backups doesn’t mean your parents won’t have internet access regardless of the where the base stations are located.
    You appear to have devices to connect to your network that use the 2.4 GHz band with 802.11g such as the iPhone 3G and perhaps the 5 GHz band with 802.11n such as likely the Macbook Pro if it’s a recent model.  The iPhone 4 can use 5 GHz and 802.11n.  Can’t comment on the Sony and Samsung but you can check their specs.
    Now the Time Capsule (if it’s a recent version), can simultaneously supply 2.4 GHz and 5 GHz band signals, but the Airport Express (if it’s recent) can only use one of those bands at one time.  Likely the lowest common denominator for your devices is going to be the 2.4 GHz band since the devices that are capable of using 5 GHZ also support 2.4 GHz.  If you don’t use 5 GHz, you won’t lose much in a two-storey home because likely it’s the 2.4 GHz band is better signal anyway because 5 GHz signals drop off quickly with several walls/floors to penetrate.
    You also didn’t mention if the Airport Express is used to support a printer and/or AirPlay (using iTunes to play on remote speakers via the Airport Express connection) but that might also be a factor in the best location to place the Airport Express.  Although the printer could be switched between the Time Capsule and the Airport Express if needed, only the Airport Express will support your remote speakers.
    Recommend you use the Time Capsule as the Base station.  When using Airport Utility to define the network, after you name your network, etc., select the Wireless tab, check the box “Allow this network to be extended” and set the Radio Mode to "802.11n (802.11b/g compatible)”.
    Using the Airport Utility, click on the Airport Express; after you define the device and network name, select the Wireless tab, define the Wireless Mode as “Extend a Wireless Network” and check the box “Allow wireless clients”. 
    Hope that helps.

  • What is the best way to do a 10.8 reinstall and keep all of my data?

    What is the best way to do a 10.8 reinstall and keep all of my data?

    Boot to the recovery disk and reinstall the os. That said you do have a back up just in case (I trust)?

  • My wife has gave me her old ipad what would be the best way to set up her new ipad and to have my own ID?

    My wife has gave me her old ipad what would be the best way to set up her new ipad and to have my own ID?

    Backup the old iPad first, either to itunes or iCloud.
    Once that is done, setup the new iPad from the backup. Choose the Restore from Backup option when setting up the new iPad.
    iOS: How to back up /  Restore
    http://support.apple.com/kb/ht1766
    When that is done, wipe the old iPad clean and set up as new.
    Settings->General->Reset->Erase all Content and Settings
    You can create a new Apple Id when you set up the iPad again.

  • I am getting pop ups on safari and firefox lately and am worried i may have malware or something now on my computer doing this. What is the best way to check this out for sure and remove it?

    I am getting pop ups on safari and firefox lately and am worried I may have malware or something now on my computer doing this. What is the best way to check this out for sure and remove it?

    Please review the options below to determine which method is best to remove the Adware installed on your computer.
    The Easy, safe, effective method:
    http://www.adwaremedic.com/index.php
    If you are comfortable doing manual file removals use the somewhat more difficult method:
    http://support.apple.com/en-us/HT203987
    Also read the articles below to be more prepared for the next time there is an issue on your computer.
    https://discussions.apple.com/docs/DOC-7471
    https://discussions.apple.com/docs/DOC-8071
    http://www.thesafemac.com/tech-support-scam-pop-ups/

  • Best way to draw a triangle for the web

    I want to draw a triangle using Java for the web and was wondering what would be the best and simplest way to do this. Any guidance and links would be much appreciated.

    The drawLine method of the Graphics class.Or the drawPolygon() method.

  • Best way to draw thousands of graphic objects on the screen

    Hello everybody, I'm wanting to develop a game where at times thousands of graphic objects are displayed on-screen. What better way to do this in terms of performance and speed?
    I have some options below. Do not know if the best way is included in these options.
    1 - Each graphical object is displayed on a MovieClip or Sprite.
    2 - There is a Bitmap that represents the game screen. All graphical objects that are displayed on screen have your images stored in BitmapData. Then the Bitmap that represents the game screen copies for themselves the BitmapData of graphical objects to be screened, using for this bitmapData.copyPixels (...) or BitmapData.draw  (...). The Bitmap that represents the screen is added to the stage via addChild (...).
    3 - The graphical objects that are displayed on screen will have their images drawn directly on stage or in a MovieClip/Sprite added to this stage by addChild (...). These objects are drawn using the methods of the Graphics class, as beginBitmapFill and beginFill.
    Recalling that the best way probably is not one of these 3 above.
    I really need this information to proceed with the creation of my game.
    Please do not be bothered with my English because I'm using Google translator.
    Thank you in advance any help.

    Thanks for the information kglad. =)
    Yes, my game will have many objects similar in appearance.
    Some other objects will use the same image stored, just in time to render these objects is that some effects (such as changing the colors) will be applied in different ways. But the picture for them all is the same.
    Using the second option, ie, BitmapDatas, which of these two methods would be more efficient? copyPixels or draw?
    Thank you in advance any help. =D

  • Best way to implement a simple read of multiple stings from a db

    Hello guys,
    I am trying to read a collection of countries (Strings) into a collection inside a Movie object. The countries reside in a separate DB table with a FK referencing the Movie.
    My questions:
    1) What is the best way to implement this? Do I need a seperate entity 'country' ? Is there a general way to read many strings into a collection?
    2) the countries list does not have to be updated, only read. How do I make sure it is not persistent?
    I have noticed that in my JPA implementation (in netbeans) I do not have something like CollectionOfElements (that is present in hybernate).
    Thank you,
    Marek

    >
    My questions:
    1) What is the best way to implement this? Do I need a seperate entity 'country' ? Is there a general way to read many strings into a collection?
    Probably yes, you need to have one entity for country.for getting the right answer, Post it here - Enterprise Technologies - Java EE SDK (http://forums.sun.com/forum.jspa?forumID=136)

  • What is the best way to double buffer in this case and how to do it....

    currently I have
    public class Frame1 extends JFrame{
    //inside this class I call up circle class, rectangle class, etc.... to draw
    }I am making a "paint" program, and I have individual classes to handle the paint methods heres an example:
    abstract public class Shape {
        public Shape() {
        public abstract void draw(Graphics g, Color c, int x, int y, int width,int height);
    }and then....
    public class Circle extends Shape{
        public Circle() {
        public void draw(Graphics g, Color c, int oldx, int oldy, int newx, int newy) {
            g.setColor(c);
            g.drawOval(Math.min(oldx, newx), Math.min(oldy, newy), Math.abs(oldx - newx), Math.abs(oldy - newy));
    }There is also a Rectangle class, line class.... etc! So my question to you is the following... what is the best way to implement double buffer in the individual classes? And how to do it?? And also.... the drawings should be kept inside a jPanel.
    Any bit of help is much appreciated Thank you!!

    You don't need to do double-buffering. Swing
    components are double-buffered by default. Just make
    sure you override paintComponent() and not paint().
    And even if you had to, why would there be any
    difference in implementation for your classes whether
    they paint to on- or off-screen graphics?I need to override paintComponent()? what if I don't...
    I am using JBuilder2005 and they automate somethings for me. So thats how they did it when they created the application they did this....
    public class Frame1 extends JFrame{
    /*** all my code here***/
    public class Application1 {
        boolean packFrame = false;
         * Construct and show the application.
        public Application1() {
            Frame1 frame = new Frame1();
            // Validate frames that have preset sizes
            // Pack frames that have useful preferred size info, e.g. from their layout
            if (packFrame) {
                frame.pack();
            } else {
                frame.validate();
            // Center the window
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            Dimension frameSize = frame.getSize();
            if (frameSize.height > screenSize.height) {
                frameSize.height = screenSize.height;
            if (frameSize.width > screenSize.width) {
                frameSize.width = screenSize.width;
            frame.setLocation((screenSize.width - frameSize.width) / 2,
                              (screenSize.height - frameSize.height) / 2);
            frame.setVisible(true);
            try {
                jbInit();
            } catch (Exception ex) {
                ex.printStackTrace();
         * Application entry point.
         * @param args String[]
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    try {
                        UIManager.setLookAndFeel(UIManager.
                                                 getSystemLookAndFeelClassName());
                    } catch (Exception exception) {
                        exception.printStackTrace();
                    new Application1();
        private void jbInit() throws Exception {
    }

  • Best way to have an iMac second monitor and Thunderbolt daisy chain?

    I'm getting new iMacs for my school lab & wish to daisy chain with Thunderbolt cables into pods of 6 for backing up. I also want to run a second monitor with each iMac. What is the best way to do this since both Thunderbolt ports will be used? USB 3.0 to HDMI?

    Canadian Tech Teacher wrote:
    By "pods" I had meant creating little LAN's of 6 computers connected to a Thunderbolt drive but I've been doing a lot of reading and now I'm wondering about whether that can actually be done?
    The only Mac to Mac connections that Thunderbolt supports that I know of are target disk mode & target display mode, neither of which supports a daisy chain topology or is suitable for a multi-host LAN. (Only one Mac can be the host in either of these modes.)
    However, if you want to crete six computer LANs for backups, you could use traditional Ethernet or WiFi LANs & (for instance) a large NAS drive array, or Airport Extreme Base Stations with one or more USB drives attached to them. You could also use Time Capsules, but that is more expensive than going with AEBS's & attached drives. Obviously, wired LAN's would be more suitable for multiple "pods" of six Macs, both because of better reliability & elimination of WiFi channel contention that would show down wireless throughput.
    Of course, this isn't as fast as a Thunderbolt drive connected directly to a Mac, but the only way I know of to do that is by connecting to one Mac at a time, which probably would negate any backup copying speed advantage.
    Thunderbolt drives (& cables) are expensive so their use is really only justified where very high speed data transfers are necessary. If you don't need that, you might consider a simpler solution of one (or for redundancy two) USB 3.0 drives per iMac, since they are relatively cheap & still offer high speed data transfers.

  • Best way to save every night a project and  one more

    I have a typical raid setup. E= 2   0 striped drives and F= 2   0 striped drives.
    At the end of a day, what is the best way to offload then bring back in the next morning to keep working?
    I have been just offloading via project manager collect files and copy to new location. Does the preview files automatically understand which drive to go to?
    I am assuming yes on this even though separate drives.
    My next question is this.
    We have another machine that I have editors just cut and trim on. It is a single raid setup  0 striped.
    When I transfer this over to the bigger machine with the raid pairs E and F  it doesn't understand to take files to the preview drive since there was not another drive on the machine it was created on.
    What is the best remedy for this setup bring a simple raid project in to a 2 raid setup for further editing.
    Just trying to clear this up.
    Thank you for your responses. : )
    David

    I dont understand why you feel the need to do this...
    At the end of a day, what is the best way to offload then bring back in the next morning to keep working?
    Apart from the effort involved..I would be worried that errors and corruptions would occur with all the data transfers going on repeatedly.
    If the source files are have back ups and you back up your project file...why does this not work.

  • Best way to create slide shows in PE4 and PSE 6

    What's the best way to create a fancy slide show in PE 4 and PSE 6? I need to create a slide show of about 600 pictures. I'm on Windows XP with 3gb RAM. I've done this a few years ago in earlier versions of PE and PSE. Before i plunge into this again i wanted to get some overall guidance for what to do or not do.
    My ultimate goal is to create a slide show that:
    1. uses pan and zoom on every photo
    2. transitions between every photo
    3. has an audio track
    4. has some nice special effects -- words and graphics that appear on slide at precisely the right moment to match the song, and stay on the screen as one slide transitions to another. i want the text to be able to move and fade in and out.
    My view is that it's easy to accomplish #1-3 in PSE 6; it's quite simple to create a slide show, add pan and zoom, and transitions. However, #4 is not doable because adding text and graphics can only be done on a slide at a time and only when the slide start/stops (i.e., you can't have text appear 2 secs after the slide has started displaying and stay on screen while the next slide appears). Need PE 4 to do that.
    What i'm wondering is:
    -- is it best to create the basic slide show in PSE6 and then export to PE 4 to do the final fancy stuff, or is it best to just create the show in PE4? Seems that doing the pans, zooms, and transitions are easiest in PSE 6.

    eric,
    I am going to offer some reasons NOT to start this slide show in Photoshop Elements. This is despite the fact that I have used the workflow of starting in Photoshop Elements and used the Send Slideshow to Premiere Elements in PSE5 - PE 3 and PSE7 - PE7.
    1- Timing differences between the PSE and PE slide show construction and processing
    There are many differences in timing between the two products. Transitions can start/end slightly offset from their timing in PSE once they arrive and are processed in PE. Same for pan and zoom. Does this matter? Well the more precise your timing, the more potential for a show stopper.
    Example: one person who wanted continual motion using pan and zoom needed to go modify the transition positioning and the keyframing of the pan/zooms on every single slide after sending a slideshow from PSE to PRE.
    2- your requirement to
    "words and graphics that appear on slide at precisely the right moment to match the song, and stay on the screen as one slide transitions to another. i want the text to be able to move and fade in and out."
    You can't really sync the audio to a slide in PSE. The text can't move or fade in/out. I think that it will be more grief to retrofit these functions to a slide show that was created in PSE than it will be to do the all the work in Premiere Elements.
    3- "Add the sound track for the ENTIRE slide show (this will be longer than i currently have slides for because i don't have all the photos"
    I am suspicious that adding the ENTIRE sound track in one PSE slide show will not work.
    I have done multiple sends from PSE slide show editor to Premiere Elements. However, I decided on the approach of using no audio in the PSE slideshow editor and adding Audio in Premiere Elements AFTER sending all the slide shows.
    Again, your objective of syncing specific photos to music points is good artistically - but I am concerned that it will make your PSE to PRE workflow problematic.
    4- "as new photos arrive, do the arrangement/pans/zooms in PSE and move them to PE"
    As Steve mentioned when you do subsequent sends of the slideshow, it appends to the end - does not seem to fit your objective of replacing part of the middle.
    Also if you get new photos in for the second section of the slideshow - but over in Premiere Elements you had already made other changes in the second section. There is no function to combine new changes doen in PSE and changes done in PE for that same "section" of the slideshow.
    5- you did not say whether you will be outputting this slide show in Full Screen or Widescreen format. Will you be burning a DVD? If you will be doing widescreen output, additional problems with specifying pan/zoom in PSE have been identified on various forums because the PSE pan/zoom boxes are not widescreen aspect ratio.
    Conclusion:
    Some of my comments here are definitely subjective - however, it is my overall conclusion that your objectives and work plan are not a good fit for the Photoshop Elements slide show editor to Premiere Elements workflow.
    My perspective on the Photoshop Elements slide show editor is that it is designed to simple, quick and easy. Therefore it has limitations.

  • Best way to completely erase my SSD disk and make fresh install of MacOSX?

    I want a brand new OSX installatetion. What is the best way to completely erase my SSD (to make it brand new) and reinstall MAC OSX (i can use internet WPA secure Wi-Fi to reinstall MACOSX Lion). On macbook air late 2011.

    That's a good question!  It's a trick question too!
    Here's my thoughts on this...
    It's not as obvious as one might think.  You certainly don't want to do a secure erase (heck, you never need to do a secure erase unless maybe you want to sell the machine).  And even a simple reformat is quationable.
    It's not that these things won't work.  It is just that the flash cells are not going to be reused unless there are no unused flash cells available.  So you end up installing in unused flash cells which is not the same as when it was actually new.
    So I don't know the answer here. 
    Note, I do recall the MacPerformanceGuild has some tool for reconditioning ssd's but I have to find it again and if I recall there was something that bothered me about its description.
    Time for some google searches.
    MPG Article on reconditing ssd's: Reconditioning a solid state drive (SSD)
    I think what was bothering me about that article was the info near the end about writing over the entire ssd.
    Another MPG Article: Restoring solid state drive performance with DiskTester ‘recondition’

  • Best way to regularly share files between mac and pc?

    Hi
    I'm starting uni this year and want to get all preppred and ready to go. Just wondering the best way I can go about sharing files between my iMac and the universities library computers (which I assume will be PC)?
    I currently use Word for Mac 2008 but am considering upgrading to Word 2011 or Pages before I start classes and for file sharing I hear Evernote or iCloud are the best options but if all else fails, I'll probably just go with a simple USB.
    Currently Own:
    - iMac
    - iPhone 5
    - Word for Mac 2008
    Considering
    - Word for Mac 2011
    - Pages
    - Evernote
    - iCloud
    - USB
    Let me know if you have any advice,
    Thanks

    Not too sure what you mean, sorry... but I will try and explain a little further.
    I'll be creating documents at school on a library PC computer, then wanting to access them at home on my iMac and vice versa.
    I had the idea that I would be able to save them to a web-based file sharing site but I've since learnt Evernote has to be downloaded to both the public PC and personal iMac and that probably isn't possible.

Maybe you are looking for

  • Oracle apps r12 data is not coming up in form based on org_id specific view

    Hi All, I am new to oracle apps R12. I have to develop a form which is based on views which are org_id specific. My data block is based on view which is org_id specific. Can anyone tell me what all settings i need to do in my form so that i can get t

  • How to protect the class files inside jar file.

    Hi Group, pls help me. my need is i created a executable jar file with certain classes. and i'm supposed to send it to my client. but if the client needs he can extract the class files from the jar and with the help of some decompilers he can convert

  • How to print data in h:dataTable by column wise

    I've Arraylist holding of Item objects, in that again one more Arraylist containing Item parameters My problem is i want to display ItemParams side by side(column wise) not row by row(normal procedure) Table looks like ItemNo          ItemName     It

  • Grabbing Folder size and email info

    Hi all,  I've been working on a script that will get the size of all the users profiles folders on our file server. I then set it up to email the I.T. Dept if the size of the file is over 200MB. So far, when I run the script, it doesn't throw off any

  • MPD + Pulseaudio problem

    Hey guys, I'm having trouble with mpd coupled with pulseaudio when trying to play surround sound (5.1) songs. The issue seems to be that mpd completely ignores my front-right speaker - nothing comes out of it. deadbeef and amarok can play the songs p