Why does the parameter of the paintComponent method have....?

Why does the parameter of the paintComponent method have type Graphics and not Graphics2D?

masijade. wrote:
Additionally, it is, however, normally, a Graphics2D object's reference value that is passed around....which means most painting code starts out by casting the Graphics object to Graphics2D. You know what they say: death, taxes, and cruft... :P

Similar Messages

  • If I have money on my account why does it ask for a payment method in order to buy the song?

    If I already have money on my account from an itunes card, why does it ask for a payment method when I try to buy a song?

    Most likely because your credit card is expired.
    Either repklace the credit card with a valid card or remove the credit card completely.

  • Why does is not show the radio buttons

    I want to display the buttons in a row then radio button in a row under the button and then log scroll pane under the radio buttons. This is my code:
            //Add the buttons and the log to this panel.
            add(buttonPanel, BorderLayout.PAGE_START);
            add(radioPanel, BorderLayout.CENTER);
            add(logScrollPane, BorderLayout.CENTER);When i run it it display the buttons and the logsrollpane. Why does it not display the radio buttons?

    Thanks guys.
    This is my problem. We have a big system that produce lots of log files and the software testers have to manually have to go through the logs file and look for a certain XML tags in the log file.
    What I want to do is help the software testers my developing a small tool that will allow them to open a log file and then click on a radio button corresponding to a xml tags that they are looking for and automatically highlight the tags in the file in yellow color .
    I am not sure how feasible this is and I am stuck.
    This is what I have done so far.
    Can you please guys help me go forward.
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.filechooser.*;
    public class FileChooserDemo extends JPanel
                                 implements ActionListener {
        static private final String newline = "\n";
        JButton openButton;
        JButton clearButton;
        JTextArea log;
        JFileChooser fc;
        // Radio Buttons
        static String em01 = "EM01";
        static String em07 = "EM07";
        /*static String dogString = "Dog";
        static String rabbitString = "Rabbit";
        static String pigString = "Pig";*/
        public FileChooserDemo() {
            super(new BorderLayout());
            //Create the radio buttons.
            JRadioButton em01Button = new JRadioButton(em01);
            em01Button.setMnemonic(KeyEvent.VK_B);
            em01Button.setActionCommand(em01);
            em01Button.setSelected(true);
            JRadioButton em07Button = new JRadioButton(em07);
            em07Button.setMnemonic(KeyEvent.VK_C);
            em07Button.setActionCommand(em07);
            //Group the radio buttons.
            ButtonGroup group = new ButtonGroup();
            group.add(em01Button);
            group.add(em07Button);
            //Register a listener for the radio buttons.
            em01Button.addActionListener(this);
            em07Button.addActionListener(this);
            //Put the radio buttons in a column in a panel.
            JPanel radioPanel = new JPanel(new GridLayout(0, 1));
            radioPanel.add(em01Button);
            radioPanel.add(em07Button);       
            //Create the log first, because the action listeners
            //need to refer to it.
            log = new JTextArea(40,60);
            log.setMargin(new Insets(5,5,5,5));
            log.setEditable(false);
            JScrollPane logScrollPane = new JScrollPane(log);
            //Create a file chooser
            fc = new JFileChooser();
            //Uncomment one of the following lines to try a different
            //file selection mode.  The first allows just directories
            //to be selected (and, at least in the Java look and feel,
            //shown).  The second allows both files and directories
            //to be selected.  If you leave these lines commented out,
            //then the default mode (FILES_ONLY) will be used.
            //fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            //fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
            //Create the open button.  We use the image from the JLF
            //Graphics Repository (but we extracted it from the jar).
            openButton = new JButton("Open File");
            openButton.addActionListener(this);
            //Create the save button.  We use the image from the JLF
            //Graphics Repository (but we extracted it from the jar).
            clearButton = new JButton("Clear Text Area");
            clearButton.addActionListener(this);
            //For layout purposes, put the buttons in a separate panel
            JPanel buttonPanel = new JPanel(); //use FlowLayout
            buttonPanel.add(openButton);
            buttonPanel.add(clearButton);
            //Add the buttons and the log to this panel.
            add(buttonPanel, BorderLayout.PAGE_START);
            add(radioPanel, BorderLayout.LINE_START);
            add(logScrollPane, BorderLayout.CENTER);
        public void actionPerformed(ActionEvent e) {
            //Handle open button action.
            if (e.getSource() == openButton) {
                int returnVal = fc.showOpenDialog(FileChooserDemo.this);
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                     log.setText("");
                    File file = fc.getSelectedFile();
                    try{
                         BufferedReader in = new BufferedReader(new FileReader(file));
                             String data;
                             while ((data = in.readLine()) != null) {
                                  log.append(data + newline);
                    }catch(IOException ioe){
                log.setCaretPosition(log.getDocument().getLength());
            //Handle save button action.
            }else if (e.getSource() == clearButton) {
                  log.setText("");
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event-dispatching thread.
        private static void createAndShowGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("PROGRESS Message Viewer");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            JComponent newContentPane = new FileChooserDemo();
            newContentPane.setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }

  • In the attached VI why does one loop coerce the data type while the other doesn't?

    In the attached VI why does one loop coerce  the data type while the other doesn't?
    Solved!
    Go to Solution.
    Attachments:
    AAA.vi ‏8 KB

    I'm guessing you created the Enum on the front panel.  If you right-click it and create an indicator, it will match the type, and be an enum.  LabVIEW represents enums as U16, but because the types aren't identical (for example, your enum has 3 values, but a U16 has 65,536 values), LabVIEW automatically coerces (or converts) the smaller (enum) representation into the larger (U16) value.

  • Just purchased a office jet 6500A Plus so that I can print from my iPhone and iPad. I can print form my iPhone but my iPad 2 tells me there is no air printer available.  Why does one device recognize the air printer but the other device does not?

    Just purchased a office jet 6500A Plus so that I can print from my iPhone and iPad. I can print form my iPhone but my iPad 2 tells me there is no air printer available.  Why does one device recognize the air printer but the other device does not?

    I have the 6500A without plus and it is with a LAN cable connected with my Router.
    First make sure you have the latest printer firmware installed.
    Next restart the printer and the Router.
    I had the same. Problem but it went away after rebooting the Router.

  • Why does it say that the updated version of Firefox (which I am trying to download) is not compatible with my operating system when I have Mac OS X 10.5.8?

    Why does it say that the updated version of Firefox (which I am trying to download) is not compatible with my operating system when I have Mac OS X 10.5.8? I had an older version of Firefox and it said I needed to update it but that was the message that appeared.

    Sorry, it's because Firefox 4+ are only compiled for the Intel processors.
    There is a separate project for PPC Macs called Ten Four Fox. You might give it a spin when you're tired of 3.6.
    http://www.floodgap.com/software/tenfourfox/

  • Why does iCal automatically change the date of the entry i am making to the day before??

    why does iCal automatically change the date of the entry i am making to the day before??
    for example, when i am attempting to make a 'all-day' appointment on october 2nd 2011, it automatically shifts it to october 1st.
    but if i am doing a timed appointment for only a few hours, it will allow me to put it on that day.
    i am trying to put in travel dates so any help on how to fix this, would be greatly appreciated.

    alsdman,
    Quit iCal, and try removing the com.apple.iCal.plist file from your Macintosh HD/Users/yourusername/Library/Preferences Folder. Since that Library is now hidden, you have to use the Finder>Go Menu>Depress the "Option" key>Library. Drag the .plist file to your desktop, and log out/in or restart and check iCal for functionality.
    Also go to System Preferences...>Language & Text>Formats>Region: and set/re-set the appropriate "Region."

  • Why does Preview automatically resize the text box to cut off the last character of added text? How do I fix it?

    Why does Preview automatically resize the text box to cut off the last character of added text? How do I fix it?
    I use the Tools > Annotate > Add Text feature, and when I click away after adding text, it automatically changes the text box size such that the last letter -- or last word -- gets bumped off into an invisible line below it, forcing me to manually adjust every single text box. It is highly annoying when trying to complete PDF forms (e.g. job applications).
    It appears to be a glitch, quite honestly, an error resulting from Apple's product design. Has it been fixed in the new operating system (for which they want $30)?
    I would very much appreciate any help you can provide! Thank you for your time.

    * "Clear the Cache": Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    * "Remove the Cookies" from sites that cause problems: Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    * Don't make any changes on the Safe mode start window.
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]

  • HT204406 I have subscribed to match on iTunes and organized my music on my Mac Book.  Why does it not appear the same way on my iPad

    I would like my music to appear organized in the same way on my iPad as I have done it on my Mac Book.  (and on my iPhone as well)  Since it is in the cloud, why does it not appear the same way in all devices?

    The purpose of iTunes match is to make your music library available to all of your devices anywhere. It will sync Playlists, but no other type of organization you may have made.
    If you're having trouble, be sure you are logged into the same Apple ID on all devices but be sure to read this article and pay special attention to associating your devices with an Apple ID. There are important restrictions you should know about.

  • When I send an email from Mac Mail, why does Mail go to the background and the Finder comes to the front? I want it to stay in Mail.

    When I send an email from Mac Mail, why does Mail go to the background and the Finder comes to the front? I want it to stay in Mail.

    Did you check your user name and password in Settings>Mail,Contacts,Calendars...tap your email account, tap SMTP, then tap the primary server name.  Make sure the settings there are correct.

  • Why does my facetime say "The server encountered an error prossessing registration"? it happens everytime i try to verify my email

    why does my facetime say "The server encountered an error prossessing registration"? it happens everytime i try to verify my email.

    While we all have MacBooks in this forum not all of us use FaceTime. There's a FaceTime Support Community where everybody uses FaceTime. You should also post this question there to increase your chances of getting an answer. https://discussions.apple.com/community/mac_app_store/facetime_for_mac

  • Why does my 7.0 iDVD theme not have sound playing in the menu?

    Why does my 7.0 iDVD theme not have sound playing in the menu?  When I click to get menu info, the "TravelAudio" audio is listed, but it won't play.  The volume is not the issue, it just isn't there. 

    Hi
    First of all - I would try to trash the iDVD pref file (or rather start a new User-account and log into this and re-try).
    Yours Bengt W

  • Why does say"To play the selected item, you must install a later version of the Adobe Flash Player. To download the Adobe Flash Player, go to the Adobe website." when I have the latest Version of it and it's just Black screen with no audio and Video?

    Why does say"To play the selected item, you must install a later version of the Adobe Flash Player. To download the Adobe Flash Player, go to the Adobe website." when I have the latest Version of it and it's just Black screen with no audio and Video? (Powerpoint Presentation 2013)

    You asked your question on the wrong forum. Try one for the Flash Player

  • Why does Safari crash in the middle of a movie or show from the internet?

    Why does Safari crashes in the middle of a movie or show from the internet?

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad and start typing the name.
    Step 1
    For this step, the title of the Console window should be All Messages. If it isn't, select
              SYSTEM LOG QUERIES ▹ All Messages
    from the log list on the left. If you don't see that list, select
              View ▹ Show Log List
    from the menu bar at the top of the screen.
    In the top right corner of the Console window, there's a search box labeled Filter. Initially the words "String Matching" are shown in that box. Enter the name of the crashed application or process. For example, if Safari crashed, you would enter "Safari" (without the quotes.)
    Each message in the log begins with the date and time when it was entered. Select the messages from the time of the last crash, if any. Copy them to the Clipboard by pressing the key combination command-C. Paste into a reply to this message by pressing command-V.
    ☞ The log contains a vast amount of information, almost all of which is irrelevant to solving any particular problem. When posting a log extract, be selective. A few dozen lines are almost always more than enough.
    Please don't indiscriminately dump thousands of lines from the log into this discussion.
    Please don't post screenshots of log messages—post the text.
    ☞ Some private information, such as your name, may appear in the log. Anonymize before posting.
    Step 2
    In the Console window, select
              DIAGNOSTIC AND USAGE INFORMATION ▹ User Diagnostic Reports
    (not Diagnostic and Usage Messages) from the log list on the left. There is a disclosure triangle to the left of the list item. If the triangle is pointing to the right, click it so that it points down. You'll see a list of crash reports. The name of each report starts with the name of the process, and ends with ".crash". Select the most recent report related to the process in question. The contents of the report will appear on the right. Use copy and paste to post the entire contents—the text, not a screenshot.
    I know the report is long, maybe several hundred lines. Please post all of it anyway.
    If you don't see any reports listed, but you know there was a crash, you may have chosen Diagnostic and Usage Messages from the log list. Choose DIAGNOSTIC AND USAGE INFORMATION instead.
    In the interest of privacy, I suggest that, before posting, you edit out the “Anonymous UUID,” a long string of letters, numbers, and dashes in the header of the report, if it’s present (it may not be.)
    Please don’t post other kinds of diagnostic report—they're very long and rarely helpful.

  • Why does it say in the Firefox Safe Mode article that all of the changes are temporary while in Safe Mode, then later it says "Note: The following changes cannot be undone."?

    Why does it say in the Firefox Safe Mode article that all of the changes are temporary while in Safe Mode, then later it says "Note: The following changes cannot be undone."?

    When you open Firefox in Safe Mode, it automatically disables your custom settings, themes, and add-ons. THOSE changes are temporary.
    However, if you click any of the boxes underneath the line, "You can make some or all of these changes permanent", and then choose "Make Changes and Restart", everything you checked will be forever changed, even when you start Firefox again in 'normal' mode. [See attached image for a preview of the Safe Mode options].
    To be clear:
    1. If you check any of the boxes but do NOT select "Make changes and restart", those things will not be changed at all in safe mode.
    2. If you select any of the boxes and you DO select "Make changes and restart", you will permanently lose any of the items you checked (bookmarks (except for backups), user preferences, etc.).
    If you performed the action in step 2 above, you will only be able to restore those things if you have a previously created back-up of your Mozilla Profiles folder (not the same as the Firefox program folder).
    Hope this helps.

Maybe you are looking for