What is wrong with my variables....I really need help soon

I need help. I know I need to add in repaint and change methods, but how come, when I put the starting values of my sliders for R: 0 G: 50 B: 0, the square is not green when it loads? IT is just black. What should happen, at least what I think[i] should happen, is that the rectangle would load green. And should the line:
JPanel = new Rectglbe
JPanel = new JPanel
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class Slider extends JFrame {
        int red, blue, green;
        public Slider() {
                super("ColorChanger");
                setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                //Info
                String Run = "Running, Close Program For Prompt\n";
                System.out.println(Run);
                //Labels
                JLabel RedLabel = new JLabel("                                             Red:");
                JLabel GreenLabel = new JLabel("               Green:");
                JLabel BlueLabel = new JLabel("               Blue:");
                //Red Slider
                JSlider pickR = new JSlider(JSlider.VERTICAL, 0, 255, 0);
                pickR.setMajorTickSpacing(50);
                pickR.setMinorTickSpacing(5);
                pickR.setPaintTicks(true);
                pickR.setPaintLabels(true);
                //Green Slider
                JSlider pickG = new JSlider(JSlider.VERTICAL, 0, 255, 50);
                pickG.setMajorTickSpacing(50);
                pickG.setMinorTickSpacing(5);
                pickG.setPaintTicks(true);
                pickG.setPaintLabels(true);
                //Blue Slider
                JSlider pickB = new JSlider(JSlider.VERTICAL, 0, 255, 0);
                pickB.setMajorTickSpacing(50);
                pickB.setMinorTickSpacing(5);
                pickB.setPaintTicks(true);
                pickB.setPaintLabels(true);
                JPanel pane = new Rectgl();
                pane.add(RedLabel);
                pane.add(pickR);
                pane.add(GreenLabel);
                pane.add(pickG);
                pane.add(BlueLabel);
                pane.add(pickB);
                setContentPane(pane);
                public int getValueR(int color){
                        return red;
                public int getValueG(int color){
                        return green;
                public int getValueB(int color){
                        return blue;
                public void paintComponent(Graphics comp) {
                        Graphics2D comp2D = (Graphics2D)comp;
                        comp2D.fillRect(0,0, 100, 210);
                        Color JL = new Color(red,green,blue);
                        comp2D.setColor(JL);
        public static void main(String[] args) {
                Slider frame = new Slider();
                frame.pack();
                frame.setVisible(true);
                frame.show();
  /*      class Rectgl extends JPanel {
                public void paintComponent(Graphics comp) {
                        Graphics2D comp2D = (Graphics2D)comp;
                        comp2D.fillRect(0,0, 100, 210);
                        Color JL = new Color(red,green,blue);
                        comp2D.setColor(JL);

Thank you, sorry forgot that message. Could you please put it here again, extensively commented, explain why you changed position of Rectgl.class, what other methods you added do?
Thanks.

Similar Messages

  • FileFilter????What's wrong with this code???HELP!!

    I want to limit the JFileChooser to display only txt and java file. But the code I wrote has error and I don't know what's wrong with it. can anyone help me to check it out? Thank you.
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class FileFilterTest extends JPanel
         public static void main(String[] args)
              new FileFilterTest();
         public class fFilter implements FileFilter
              public boolean accept(File file)
                   String name = file.getName();
                   if(name.toLowerCase().endsWith(".java") || name.toLowerCase().endsWith(".txt"))
                        return true;
                   else
                        return false;
         public FileFilterTest()
              JFileChooser fc = new JFileChooser();
              fc.setFileFilter(new fFilter());
              fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
              fc.setCurrentDirectory(new File(System.getProperty("user.dir")));
              //fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
              //fc.setMultiSelectionEnabled(true);
              int returnVal = fc.showDialog(FileFilterTest.this, "Open File");
              if(returnVal == JFileChooser.APPROVE_OPTION)
                   String file = fc.getSelectedFile().getPath();
                   if(file == null)
                        return;
              else if(returnVal == JFileChooser.CANCEL_OPTION)
                   System.exit(0);
              else
                   System.exit(0);
              JFrame f = new JFrame();
              FileFilterTest ff = new FileFilterTest();
              f.setTitle("FileFilterTest");
              f.setBackground(Color.lightGray);
              f.getContentPane().add(ff, BorderLayout.CENTER);
              f.setSize(800, 500);
              f.setVisible(true);
    }

    There are two file filters
    class javax.swing.filechooser.FileFilter
    interface java.io.FileFilter
    In Swing you need to make a class which extends the first one and implements the second. Sometimes you may not need to implement the second, but it is more versitle to do so and requires no extra work.

  • 'Easy Set-up' Option - Problem with edit canvas/windows - really need help!

    Hello Everyone. . .
    Have a problem that i really need help with, i have tried so many different things to sort this - but with no sucess.
    I usually work in High Definition and i have recently done a small project for someone in DV. When changing to work in DV, i selected the DV setup from the 'Easy Setup' menu. I have now changed back to HD and there are a few things different with Final Cut that i can't shift!
    When i move a clip from the capture bin into the edit window, the clip no longer fills that window like it always used to and there are lines at the top and the bottom of the clip - almost like it is in widescreen.
    Editing like this wasn't too much of a problem, but when i came to compress and do a final render of the whole film - there was the same black lines on the top and bottom of the film.
    I can't figure out how to get the setting back to how they were, and have the clips fill the edit windows and fix the end render/compress.
    Any ideas from anyone on what i am experiancing with all this? And. . . how to fix this problem?
    Any help on all this will be very much appreciated!

    Hello Everyone. . .
    Have a problem that i really need help with, i have tried so many different things to sort this - but with no sucess.
    I usually work in High Definition and i have recently done a small project for someone in DV. When changing to work in DV, i selected the DV setup from the 'Easy Setup' menu. I have now changed back to HD and there are a few things different with Final Cut that i can't shift!
    When i move a clip from the capture bin into the edit window, the clip no longer fills that window like it always used to and there are lines at the top and the bottom of the clip - almost like it is in widescreen.
    Editing like this wasn't too much of a problem, but when i came to compress and do a final render of the whole film - there was the same black lines on the top and bottom of the film.
    I can't figure out how to get the setting back to how they were, and have the clips fill the edit windows and fix the end render/compress.
    Any ideas from anyone on what i am experiancing with all this? And. . . how to fix this problem?
    Any help on all this will be very much appreciated!

  • What is wrong with my Curve 8520? Please help!

    I am having problems with my BB Curve 8520. v5.0.0.592
    First the phone started freezing all the time and I had to do a battery pull to unfreeze it, and everytime after it restarted it got the Uncaught Exception: java.lang.error.
    I uninstalled my BBM V6.1beta and my appworld 3 beta and installed the lastest official releases for them but it didn't fix the problem.
    I then deleted all the apps that I installed recently and after installing Photo Editor Ultimate the java error stopped.
    Right now the freezing is gone but now when I download pictures or songs, they don't show up anywhere on the phone. Not in the gallery and not in the file explorer. They only show up after I reboot my phone. Also when right now when I press the menue button, the menu at the left doesn't show, it only appears after I scrolled over every item in the menu, so basically it was invisible until I went up and down on the trackpad.
    What can be the problem?

    Hi MarcC8520,
    Welcome to the BlackBerry Support Community.
    Try backing up your device via the BlackBerry Desktop Software and performing a clean reload of your device software. http://bbry.lv/bpv7DT Make sure to test for the issue before restoring any data from your backup file.
    Hope this helps.
    -FS
    Come follow your BlackBerry Technical Team on Twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.
    Click Solution? for posts that have solved your issue(s)!

  • What is wrong with my tiny jdbc program? Help!!!

    Hi,
    Would anyone diagnose the problem of my simple jdbc program?
    The situation is :
    a) local machine oracle thin driver connection; "lsnrctl" is running.
    b) I can query the statement "select id from gameUser" from SQLPLUS logged in as "scott", with desirable result.
    c) There are two code lines commented out in the code, if I uncomment them and instead comment out their counterparts and run the program, the "rset" would contain the result I want. But if I run the program unchanged, the output is only "hi".
    d) If I change the query statement to a wrong column name or a wrong table name, there would be a sql exception. So I surmise that the connection with the database is successful. But how come there is no query result???
    The follow is my coding.
    import java.sql.*;
    class dbAccess {
    public static void main (String args []) throws SQLException
    DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
    try{
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:thin:orcl", "scott", "tiger");
    // ("jdbc:oracle:thin:orcl", "system", "manager");
    Statement stmt = conn.createStatement();
    ResultSet rset = stmt.executeQuery("select ID from scott.gameUser");
    // ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
    while (rset.next())
    System.out.println (rset.getString(1)); stmt.close();
    System.out.println("hi");
    }catch (Exception e)
    System.out.println(e.toString());
    Thanks for help!

    "local machine oracle thin driver connection;" means that my jdbc application uses Oracle thin driver to connect to a Oracle database. The database and the application are both on the same local machine.
    "lsnrctl" is the command line program running to accept incomming request to connect to the database, it listens on the default 1521 port.
    I inserted two rows into the table and I could query these two rows in SQLPLUS.
    And I tried "select ID from gameUser", "select id from scott.gameUser" and various combination, it just won't retrieve the rows I inserted in the table.

  • What's Wrong With Safari 4? I Need An Answer...

    The menu bar (file, edit...etc) except for Develop all say 'localized string not found'. Everytime a page loads it says the same thing. I just removed the menu bar, cause I didn't know what everything is.
    Is it just my computer or is everyone else who's using Safari for Windows having the same problem?

    I'm having the same problem. I have reinstalled Safari. I have 8 different "menu items" that say "localized string not found" instead of it saying "file, edit, view, favorites, tools & help" that IE says. Some of these "menus" do have options underneath but mainly all the items in the drop down menu all state "localized string not found", as well.

  • What is wrong with this???? HELP

    I am trying to poll a inbox for a new mail. It is polling at a regular interval but not picking up any new mail and not throwing any exception.
    Please help
    try
    // Get session
    Session session = Session.getInstance(new Properties(), null);
    // Get the store
    Store store = session.getStore(strMailProtocol);
    store.connect(strHost, strUser, strPassword);
    // Get folder
    kgDebugger.trace("Getting the mail Inbox");
    Folder folder = store.getFolder("INBOX");
    folder.open(Folder.READ_WRITE);
    kgDebugger.trace(" the message folder is " + folder);
    //add messageCountListener for new Messages only
    folder.addMessageCountListener( new MessageCountAdapter()
    public void messageAdded(MessageCountEvent ev)
    // Get directory
    Message[] message = ev.getMessages();
    Object content;
    MimeMultipart multipart = null;
    System.out.println("the message is" + message);
    // start looking in to messages
    int n = message.length;
    System.out.println(" The message length is " + n );
    for (int i = 0; i < n; i++)
    try
    javax.activation.DataHandler dh = message.getDataHandler();
    InputStream is = dh.getInputStream();
    int c;
    while ((c= is.read())!= -1)
    System.out.write(c);
    }catch(IOException iox)
    catch(MessagingException mex)
    }//for
    });//inner class
    //get the frequncy to poll
    //int freq = kgMail.getFrequency();
    for(; ;)
    Thread.sleep(10000);
    //folder.getMessageCount();
    // I ALWAYS GET THE SAME RECORD COUNT
    // even though I keep sending mail to this account
    System.out.println("I am here sleeping" + folder.getMessageCount());
    catch(Exception ex)
    {System.out.println(ex.toString());

    I finally figured it out. It was combination of things.

  • What's wrong with the code?

    public void run()
    try
    {     for(;;)
         mgr = (RTPManager)RTPManager.newInstance();
         mgr.addSessionListener(this);
         mgr.addReceiveStreamListener(this);
         try{  /*****port1 = port2 = 29261, which port is only used in here
         localAddr = new SessionAddress(InetAddress.getLocalHost(), port1);
         destAddr = new SessionAddress(ipAddr, port2);
         }catch(Exception e)
              System.out.println(e + " 4");
         try{
         mgr.initialize(localAddr);
         }catch(Exception e)
         System.out.println(e + " 5");
         //set buffer
         bc = (BufferControl)mgr.getControl("javax.media.control.BufferControl");
         if (bc != null)
         bc.setBufferLength(20);
         try{
              mgr.addTarget(destAddr);
         }catch(Exception e)
         System.out.println(e + " 2");
    catch(Exception e)
         System.out.println(e+ " 3");
    the error when i run the code is like that:
    javax.media.rtp.InvalidSessionAddressException: Can't open local data port: 29261
    5
    java.io.IOException: Address already in use: Cannot bind 2
    which means there is error in :
    mgr.initialize(localAddr);
    mgr.addTarget(destAddr);
    But i don't know what's wrong with the code,
    can any one help me?

    I do not find any problem using the same ports for local and destination address with several unicasts. My problems are others.
    But note that the error is even at constructing the localAddress, I mean before trying the destinationAddress. Thus the reason cannot be the former is already in use. In fact I think the later belongs to a remote hosts. Likely, it is trying to access the destinationAddress through the localAddress, but this has not been constructed properly.

  • What's wrong with my flash tags?

    I'm writing my own software to generate SWF files (very simple ones that just display a single image). The order the SWF entries are written in are:
    SWF Header (the main file header)
    Tags:
         FileAttributes (required for version 8 or higher)
         DefineBitsJPEG2 (contains JPEG format image)
         PlaceObject2 (places it into Display List)
         ShowFrame (displays to the screen everything in the DisplayList)
         End (tag that ends the SWF file)
    When I load the resulting SWF file into a web browser (or the standalone Flash viewer) what I find is that it just has a white screen. The image isn't being displayed. Is there something wrong with the order of the tags in my SWF file? I can't find any debugger software that will analyze the tags in the SWF file and tell me what's wrong with them.
    Can anybody here help me with this?

    And, occasionally it will boot into open firmware.
    Seems odd to me. All by itself? Did you press any keys?
    I don't know what to do from here. I can still boot into os 8.6 with extensions off.
    Most likely, you have a bad extension. They are in a folder called extensions What you need to do is create a new folder and move extensions to this folder. Move extensions to the folder in groups. try 1/2 first. Move back & forth between folders. See which extension is causing the problem. command + n to create a new folder
    verify that you have the correct firmware.
    Figuring out what level of firmware you have?
    1) Mac OS 9.x or 8.x, you need to use the Apple System Profiler.
    Apple -> Apple System Profiler
    2) Mac OS X, use the System Profiler.
    Apple -> About This Mac
    click on the More Info... tab
    click on Hardware
    read the Boot ROM Version
    3) Open Firmware, boot into Open Firmware.
    Power on your iMac while holding down commandoption+of
    The first output line contains the firmware level. Mine reads:
    Apple PowerMac4,1 4.1.9f1 BootRom built on 09/14/01 at 13.18.04
    Copyright 1994-2001 Apple Computer Inc.
    The 4.1.9f1 will be different on a 333 machine.
    What firmware do you need?
    http://docs.info.apple.com/article.html?artnum=86117

  • On my Ipod touch 4g all of a sudden all my music sounds as if they were slowed down. What's wrong with my audio?

    On my Ipod touch 4g all of a sudden all my music sounds as if they were slowed down. What's wrong with my audio?

    You need to turn off the Zoom accessibility feature.  Tap the screen twice with three fingers to get to normal screen. Then go to Settings>General>Accessibility and turn Zoom off.  You can also do that by connect the computer to iTunes and going to the Summary pane for the iPod and go to Configure Universal Access.
    For more info see:
    iPhone and iPod touch: Home screen icons are magnified or large

  • When on the phone to someone the phone crackles and hangs up so the other person can't hear what is wrong with it? :(

    When on the phone to someone the phone crackles and hangs up so the other person can't hear what is wrong with it? :(

    That iPhone needs to be tested by the techs at an Apple store genius bar to see what is faulty in the hardware.

  • I did`t saw any content of the menu button, what is wrong with my system Indesign

    I did`t saw any content of the menu button, what is wrong with my system Indesign

    more information will help.
    Try to select a frame and on the bottom of Buttons and Forms dailog box click on Covert to Button

  • Nano 6th turns on for a few seconds then screen goes black and nothing. what is wrong with it....

    My 6th gen nano turns on for a few seconds, then screen goes black and nano goes off. what is wrong with it? can any one help me out? do I need new battery? do I need a full repair? or is there something I can do myself to fix it.  Thanks for your help. 

    At the moment I say as I've fixed, momentarily:
    I made a downgrade to 1.0
    The problem, gentlemen, is the upgrade from 1.1 and 1.2
    It is a pity that I lost all the new features offered by the new firmware , just because Apple staff could not think to try this new update, on ipods with some airtime.
    I hope Apple pull out a version 1.3 with the ability to choose the feature detection, and the user can disable it at will.

  • Hey my air's screen is mess when it comes back from sleep. It is full of horizontal  colorful lines. However, it becomes ok when I restart it. What's wrong with it?

    Hey my air's screen is mess when it comes back from sleep. It is full of horizontal  colorful lines. However, it becomes ok when I restart it. What's wrong with it?

    Resetting PRAM may help.
    Reset PRAM.  http://support.apple.com/kb/PH4405

  • I just bought my MacBook Pro 13" and I tried to install an anti virus but then it went into a grey folder with a question mark I need help with restoring the iOS please

    I need help taking out the grey folder with the question mark and I've try everything except the CD thing because my MacBook didn't come with one so I really need help please

    What anti-virus software did you install? Although there's a lot of bad anti-virus software out there, no anti-virus software should cause such a problem. A gray screen with a flashing question mark on a folder means that no bootable system could be found, which means that the system was badly damaged or corrupt. Even installing bad software would not normally cause that, so either there was something badly wrong with the system already or the anti-virus software you tried to install was really, really bad!
    As mende1 says, you need to reinstall the system at this point. After your system is back up and running, read my Mac Malware Guide. If, after reading that, you want anti-virus software, use one of the programms recommended in that guide.

Maybe you are looking for

  • Windows 7 and 8 are sorting Arabic Characters wrong

    The Arabic character A is comming on many differient shapes A without hamza A with hamza on top A with hamza under A with hamza on waw A with hamza on nabra A with hamza on alef mqsoora A With madda But all of them are considered as "A" and always on

  • "no signal" message on monitor

    A friend gave me her lenovo 3000 h series desktop.  I am attempting to set it up.  I have hooked up all of the wires that I know of.  (we took it apart and I brought it home and am now attempting to connect it).  The monitor when turned on displays "

  • Is there a way to track a stolen ipad

    i am trying to track my missing ipad 2

  • Camera White balance vs Lightroom White balance

    I have nikon d90 and I have cloudy balance set by default. When I import to lightroom 4, the WB value is 4950 and lightroom cloudy is 6500. Attached is the example of original vs lightroom WB.(the whibal card was not used to set WB) Why both same WB

  • CS3 & Camera RAW 5

    I want to make sure I have this correct. -CS3 is uncompatiable with camera RAW 5 -There are no undates that will make it compatiable -Converting my camera RAW 5 files to DNG files is the only why to make them work in CS3 -If I was wish to aviod conve