I can't interact (scroll) my scrollbars in JScrollPane on a JPanel

Hi, I'm having trouble with my textarea with jscrollpane that is on an overidden JPanel to paint a background image. My first problem is that I can't even see the scrollpane but I fixed that through g.setXORMode(true). Now, my problem is even though I can see the component perfectly, when I try to scroll, it won't scroll (unclickable). Is there any way to fix this?
-I heard that I should try to add the jscrollpane to a component (like JLabel) that's always above the image. But it didn't work. I am not sure i did it right though, so I am looking for other options.
Anyways, here is the code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.plaf.*;
import javax.swing.plaf.metal.*;
import java.util.*;
public class SrtfMvtDemo extends JFrame implements ActionListener, Runnable {
     public DemoJPanel demoPanel = new DemoJPanel();
     private     JPanel     buttonPanel = new JPanel();
     private     JButton     buttonOpen = new JButton("Open"),
                         buttonStart = new JButton("Start"),
                         //buttonReset = new JButton("Reset"),
                         buttonPause = new JButton("Pause"),
                         buttonAbout = new JButton("About");
     public ImageIcon imageBg = new ImageIcon("img//logo.jpg");
     public ImageIcon imageDiagram = new ImageIcon("img//diagram.gif");
     private int[] xLocations = {550,522,494,466,438,410,382,354,326,298,272,242,
          214,186,158,130,102,74,46,18};
     private int[] xxLocations = {18,46,74,102,130,158,186,214,242,272,298,326,
          354,382,410,438,466,494,522,550};
     public static JLabel[] jqLabels = new JLabel[20];
     public static JLabel[] rqLabels = new JLabel[20];
     public static JLabel[] ioqLabels = new JLabel[20];
     private boolean isStarted = false;
     private boolean isFinished = false;
     public static final Color foreColor = Color.WHITE;
     public static boolean isPaused = false;
     public static JScrollPane scrollpane1;
     public static JScrollPane scrollpane2;
     public static JScrollPane scrollpane3;
     public static MVT memory = new MVT();
     public static CPU cpu = new CPU();
     public static IO ioDevice = new IO();
     public static JobQueue jQueue = new JobQueue();
     public static ReadyQueue rQueue = new ReadyQueue();
     public static IOQueue ioQueue = new IOQueue();
     public static Vector fQueue = new Vector(0,1);
     public static JTextArea cpuGantt = new JTextArea(3,20);
     public static JTextArea ioGantt = new JTextArea(3,20);
     public static JTextArea statistics = new JTextArea(3,30);
     public static JLabel procCpu = new JLabel();
     public static JLabel procIO = new JLabel();
     public static JPanel nonOver = new JPanel();
     public Thread mainThread = new Thread(this);
     public static int nTimer = -1;
     public SrtfMvtDemo() {
          super("INTROOS: SRTF - MVT Algorithm Demonstrator");
          setSize(800,600);
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          setLocationRelativeTo(null);
          setForeground(Color.white);
          setResizable(false);
          getContentPane().setLayout(null);
          buttonOpen.addActionListener(this);
          buttonStart.addActionListener(this);
          buttonPause.addActionListener(this);
          buttonAbout.addActionListener(this);
          buttonStart.setEnabled(false);
          buttonPause.setEnabled(false);
          demoPanel.setLayout(null);
          demoPanel.setSize(800,525);
          demoPanel.setLocation(0,0);
          buttonPanel.setSize(800,75);
          buttonPanel.setLocation(0,526);
          buttonPanel.setLayout(new FlowLayout());
          buttonPanel.add(buttonOpen);
          buttonPanel.add(buttonStart);
          buttonPanel.add(buttonPause);
          buttonPanel.add(buttonAbout);
          getContentPane().add(demoPanel);
          getContentPane().add(buttonPanel);
     private void showUI() {
          //Job Queue Labels
          for(int i=0; i<20; i++) {
               jqLabels[i] = new JLabel();
               jqLabels.setVerticalTextPosition(JLabel.CENTER);
               jqLabels[i].setHorizontalTextPosition(JLabel.CENTER);
               jqLabels[i].setForeground(Color.white);
               jqLabels[i].setSize(25,25);
               jqLabels[i].setLocation(xLocations[i],28);
               demoPanel.add(jqLabels[i]);
          //Ready Queue Labels
          for(int i=0; i<20; i++) {
               rqLabels[i] = new JLabel();
               rqLabels[i].setVerticalTextPosition(JLabel.CENTER);
               rqLabels[i].setHorizontalTextPosition(JLabel.CENTER);
               rqLabels[i].setForeground(Color.white);
               rqLabels[i].setSize(25,25);
               rqLabels[i].setLocation(xxLocations[i],97);
               demoPanel.add(rqLabels[i]);
          //IO Queue Labels
          for(int i=0; i<20; i++) {
               ioqLabels[i] = new JLabel();
               ioqLabels[i].setVerticalTextPosition(JLabel.CENTER);
               ioqLabels[i].setHorizontalTextPosition(JLabel.CENTER);
               ioqLabels[i].setForeground(Color.white);
               ioqLabels[i].setSize(25,342);
               ioqLabels[i].setLocation(xLocations[i],97);
               demoPanel.add(ioqLabels[i]);
          procCpu.setSize(100,20);
          procCpu.setLocation(450,209);
          procCpu.setForeground(Color.white);
          procCpu.setBackground(Color.black);
          demoPanel.add(procCpu);
          procIO.setSize(100,20);
          procIO.setLocation(450,374);
          procIO.setForeground(Color.white);
          procIO.setBackground(Color.black);
          demoPanel.add(procIO);
          cpuGantt.setBackground(Color.black);
          cpuGantt.setForeground(Color.white);
          cpuGantt.setEditable(false);
          cpuGantt.setLineWrap(true);
          cpuGantt.setWrapStyleWord(true);
          cpuGantt.setSize(557,47);
          cpuGantt.setLocation(15,162);
          cpuGantt.setAutoscrolls(true);
          //demoPanel.add(cpuGantt);
          scrollpane1 = new JScrollPane(cpuGantt,
               JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
               JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
          scrollpane1.setSize(557,47);
          scrollpane1.setLocation(15,162);
          //demoPanel.add(scrollpane1);
          ioGantt.setBackground(Color.black);
          ioGantt.setForeground(Color.white);
          ioGantt.setEditable(false);
          ioGantt.setLineWrap(true);
          ioGantt.setWrapStyleWord(true);
          ioGantt.setSize(557,47);
          ioGantt.setLocation(15,327);
          ioGantt.setAutoscrolls(true);
          //demoPanel.add(ioGantt);
          scrollpane2 = new JScrollPane(ioGantt,
               JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
               JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
          scrollpane2.setSize(557,47);
          scrollpane2.setLocation(15,327);
          //demoPanel.add(scrollpane2);
          statistics.setBackground(Color.black);
          statistics.setForeground(Color.white);
          statistics.setEditable(false);
          statistics.setLineWrap(true);
          statistics.setWrapStyleWord(true);
          statistics.setSize(760,100);
          statistics.setLocation(18,405);
          statistics.setAutoscrolls(true);
          //demoPanel.add(statistics);
          scrollpane3 = new JScrollPane(statistics,
               JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
               JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
          scrollpane3.setSize(760,100);
          scrollpane3.setLocation(18,405);
          //demoPanel.add(scrollpane1);
          //demoPanel.add(scrollpane2);
          //demoPanel.add(scrollpane3);
          nonOver.setLayout(null);
          nonOver.setSize(800,525);
          nonOver.setLocation(0,0);
          nonOver.setOpaque(false);
          nonOver.add(scrollpane1);
          nonOver.add(scrollpane2);
          nonOver.add(scrollpane3);
          demoPanel.add(nonOver);
     public static void main(String[] args) {
          MetalLookAndFeel.setCurrentTheme(new JetTheme());
          try {
               UIManager.setLookAndFeel(new MetalLookAndFeel());
          } catch(Exception e) {}
          setDefaultLookAndFeelDecorated(true);
          JDialog.setDefaultLookAndFeelDecorated(true);
          SrtfMvtDemo mainDemo = new SrtfMvtDemo();
          mainDemo.setVisible(true);
     public void actionPerformed(ActionEvent ae) {
          if(ae.getSource()==buttonOpen) {
               Opener open = new Opener();
               isStarted = open.doOpen();
               if(isStarted) {
                    buttonStart.setEnabled(true);
                    buttonPause.setEnabled(true);
          if(ae.getSource()==buttonStart) {
               buttonOpen.setEnabled(false);
               buttonStart.setEnabled(false);
               showUI();
               isStarted = true;
               showUI();
               mainThread.start();
          if(ae.getSource()==buttonPause) {
               isPaused = !isPaused;
          if(ae.getSource()==buttonAbout) {
               JOptionPane.showMessageDialog(null, "This machine project is made "+
                    "by:\nAndrei Victor\nJohanne Pagaduan\nOliver Recio\nINTROOS S11",
                    "About", JOptionPane.INFORMATION_MESSAGE);
     public void run() {
          do {
               while(!isPaused) {
                    if(fQueue.size() > 0 && fQueue.size() == Job.getNumberOfJobs()) {
                         isFinished = true;
                         break;
                    try {
                         mainThread.sleep(10);
                    } catch(Exception e) {
                    nTimer++;
                    System.out.println("Time: " + nTimer);
                    if(cpu.currentJob != null)
                         System.out.println("J"+cpu.currentJob.getID()+" Burst: "+cpu.currentJob.getBurst());
                    jQueue.check();
                    rQueue.check();
                    cpu.check();
                    ioQueue.check();
                    ioDevice.check();
                    repaint();
          } while(!isFinished);
          JOptionPane.showMessageDialog(null, "Simulation Finished", "Sim Info",
               JOptionPane.INFORMATION_MESSAGE);
     public class DemoJPanel extends JPanel {
          //Do your paint stuff here!
          public DemoJPanel() {
               setDoubleBuffered(true);
          public void paintComponent(Graphics g) {
               super.paintComponent(g);
               if(!isStarted) {
                    g.drawImage(imageBg.getImage(), 0, 0, this);
               } else {
                    g.drawImage(imageDiagram.getImage(), 0, 0, this);
                    g.drawString("Time: " + nTimer, 700, 370);
                    g.setXORMode(Color.black); //this lets me see through the image
                                                       //but doesn't let me interact with it.
                    for(int i=0; i<64; i++) {
                         if(memory.memory[i] != -1)
                              g.setColor(new Color(128,47,249));
                         else
                              g.setColor(new Color(0,0,0));
                         g.fill3DRect(655,28+(i*4)+i,125,4,true);
     /** JetTheme class to change the color of the L&F of the Metal theme.
public static class JetTheme extends DefaultMetalTheme {
/** Method to return the theme name.
public String getName() { return( "Jet" ); }
private final ColorUIResource primary1 =
new ColorUIResource(80,80,80);
private final ColorUIResource primary2 =
new ColorUIResource(90,90,90);
private final ColorUIResource primary3 =
new ColorUIResource(50,50,50);
private final ColorUIResource secondary1 =
new ColorUIResource(0,210,0);
private final ColorUIResource secondary2 =
new ColorUIResource(0,140,0);
private final ColorUIResource secondary3 =
new ColorUIResource(0,0,0);
private final ColorUIResource black =
new ColorUIResource(0,255,0);
private final ColorUIResource white =
new ColorUIResource(0,0,0);
          protected ColorUIResource getPrimary1() { return( primary1 ); }
          protected ColorUIResource getPrimary2() { return( primary2 ); }
          protected ColorUIResource getPrimary3() { return( primary3 ); }
          protected ColorUIResource getSecondary1() { return( secondary1 ); }
          protected ColorUIResource getSecondary2() { return( secondary2 ); }
          protected ColorUIResource getSecondary3() { return( secondary3 ); }
          protected ColorUIResource getBlack() { return( black ); }
          protected ColorUIResource getWhite() { return( white ); }

This is how I paint a background image:
http://forum.java.sun.com/thread.jsp?forum=57&thread=316074

Similar Messages

  • Action &OBJECT_ID& does not exist - when Scrolling the Scrollbar in Table

    Hi All,
    When  executing the application of  ABAP webdynpro component  at runtime when we scroll the scrollbar of the table then we are getting the following dump. please let me know the solution to fix the issue.
    Thanks in advance.
    Dump
    The following error text was processed in the system BRD : Action &OBJECT_ID& does not exist
    The error occurred on the application server c700u043_BRD_10 and in the work process 1
    The termination type was : RBAX_STATE
    The ABAP call stack was:
    method : IF_WDR_RR_CONTROLLER~GET_ACTION of program SAPLWDR_RUNTIME_REPOSITORY
    method : GET_ACTION_INTERNAL of program CL_WDR_CONTROLLER----CP
    Thanks,
    PortalUser100

    Hi..
    I dnt get anything when i see the error, its like somewhere standard error. And are you trying to scroll horizontal or vertical scroll?
    Any way, we can achieve scrolling through one application parameter called wdtablenavigation and its value is SCROLLBAR.
    then you will get scroll bar for all tables in your component.
    Once you double click on appplication,you will find parameters tab, there pass the above values.
    Regards
    Srinivas

  • I can no longer scroll on my iMac in Mavericks

    For some reason completely unknown to me, I suddenly can no longer scroll, or even see scrollbars on my iMac, running Mavericks. It's been perfectly fine for months and just yesterday...poof! No scrolling.
    At first I thought it was limited to Safari, but then noticed it's for all browsers and all programs on my computer.
    Can anyone please help me with this? The only searches I've done show articles at least two years old.
    P.S. I can "scroll" with the up-down arrow keys, but not with a mouse of any kind (wired or wireless), and the scroll bars do not appear until I use the arrow keys.
    27", Late 2012 iMac
    OS X 10.9.3

    Leroy, this has to be the single most embarrassing thing I've ever done on a computer.
    The restart worked.
    In my own lame defense, I had just restarted my iMac prior to this occurring, so I figured the last thing that would fix this would be another restart.
    I know you can't see it, but my head is hanging in shame!
    Thank you for mentioning the restart. I'm always telling people to reboot before doing anything else, and this time, I should have done it myself.
    I'm going to go hide under a rock for a while.
    Thanks again!

  • Can a item in a scrollbar stay static?

    Hello,
    I want to build a scrollbar that when you rollover one of the items it'll show you the information on it in the side but to do so I have to insert the information also into the scrollbar content and If I move the thumb on the track the infprmation also move with the content?
    can a item in a scrollbar stay static? can clicks inside a scrollbar affects an outside content? or anyother way that it'll work?
    here's a pic

    Hi Idansh,
    You can do this by creating the "static content" as a custom component. The custom component can have multiple states so when you click on the items inside the scrolling bar, they change the state of that custom component. Only have the "buttons" be in the scrolling content and not the changing, static content.
    I hope this makes sense and I hope I am understanding what you are wanting to do.
    Tim

  • I recently upgraded to OSX 10.9.  Within Mail, I can no longer scroll in any window but the mailbox window.  What happened?

    I recently upgraded to OSX 10.9.1.  Within Mail, I can no longer scroll  in any window but the mailbox window.  What happened?  Not in the message window or the reading pane.

    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    *Firefox > Preferences > Advanced > Network > Cached Web Content: "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Firefox > Preferences > Privacy > Cookies: "Show Cookies"
    Did you check for connection problems?
    *http://kb.mozillazine.org/Error_loading_websites
    You can also try different connection settings.
    *Firefox > Preferences > Advanced : Network : Connection > Settings
    *https://support.mozilla.org/kb/Options+window+-+Advanced+panel

  • I can no longer scroll in Word

    I can no longer scroll through a document in Word, can someone tell me how to fix it?

    you have provided minimal information in your question. to help, we need lots!
    what version of Word? -  Apple Menu > About Microsoft Word
    what has changed since this began? update / upgrade software - system or App?
    have you updated Yosemite to version 10.10.*1* ? -- in the Finder -  Apple Menu > About this Mac
    to clarify, scrolling is normal in all other App & Finder windows?
    In Word, are the scroll bars 'present' (visible)?
         if present, are all scroiling functions failing?
              mouse click
                   arrows - both 'fine' and 'page' <-(my Word version has its own scroll unique button versions, separate from System)
                        up, down, left, right - (last two depends on Zoom of page)
                   in the blank areas of the scroll bars - 'page' or 'jump to here' as set in System Prefs *(see OS X Yosemite: General preferences )
                   click, hold & drag the scroll BAR itself
    does the page scroll using the arrow keys?
         when the text cursor moves past the visible portion of the document page?
         when using key combination - fn Function + 'up' or 'down' and/or fn Function + 'left' ('Home' or top of page) & 'right' ('End' or bottom of page)
    these answers will get us started...
    with anticipation
    ÇÇÇ

  • I can no longer scroll through app selections in Genius iPad

    I can no longer scroll through app selections in Genius on my iPad in the App Store. I see the first row and half of the second row and cannot scroll. This is a new condition. Landscape or portrait is the same.

    Just adding my voice as well.
    Had this issue for awhile now. Believe it must have surfaced after last iOS update.
    Quite annoying since Genius was a good way to quick browse for new app suggestions.

  • Can we create scroll bar Table in ADE?

    Hi All,
    Can we create scroll bar Table in ADE. Please refer the enclosed attachment Table.JPG.
    We used the following CSS property, which is displaying the scroll bar table in HTML but not in ADE.
    #table_data {width:400px; overflow:auto; }
    Please Suggest.
    Regards,
    Jaffar

    Hi Swathi,
    The whole concept of internal table is to manipulate the data at runtime.
    This replaces the concept of two dimentional array in other languages.
    The power of internal tables is it gets lakhs of records at runtime. I mean it can accomodate lots of records at runtime.
    So you can create a table type in DDIC and use it to declare your internal table.
    Yes, You can create global internal tables for function modules.
    By declaring the internal table in top include you can use this internal table all the function modules of that function group. So if one function module is filling the data another can use it as it is stored globally.
    Hope this answers your curiosity.
    Award points if useful else getback.
    Aleem.

  • Why can't I scroll down on windows of certain sites? Like the new BMO site!

    Why can't I scroll down on windows of certain sites? Like the new BMO site!  Please help, I'm going crazy!

    Use two fingers held together to scroll within a window on a web page.
    The iPad User Guide is bookmarked for you in Safari. If you're new to iOS devices, you may want to give it a read through.
    Best of luck.

  • I can't shift + scroll at the same time! HELP!

    I have a windows 8 , dell laptop. I have a Microsoft wireless 3500 mouse. I can't Shift+scroll at the same time and it's annoying when I play games that I have to shift+scroll which is basically the game I play all the time. Please help!

    It's not, it's a downloadable game. Also it doesn't work with pages that you scroll down on like youtube, etc when I hold shift.

  • Satellite P series - I can no longer scroll using edge of the touch pad

    Please can anyone tell me why I can no longer scroll using the edge of the touch pad.
    This seems to have occurred since I had to reinstall Vista following a problem with some faulty Ram.
    Thanks

    Hi
    One reason can be a missing touchpad driver.
    But if the touchpad driver has been installed, then you should check the settings of the touchpad.
    In control panel -> mouse you will find the touchpad properties. It should be the last tab.
    There you can check enable and disable and configure many options.
    Cheers

  • Can Adobe Interactive PDF consume a service that returns JSON?

    Can Adobe Interactive PDF consume a service that returns JSON? A few web sites seem to suggest it can:
    http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_c-d_43.html
    http://blogs.adobe.com/acdc/2008/08/using_json_to_exchange_data_wi.html

    Its probably better to post this in the Form or Designer forum as those ones deal more with the capabilities of XFA based PDFs.  The Generator forum deals with the server software that converts documents to PDF.
    Having said that.
        You should be able to do it, but not directly. I don't believe that there is a way to map the JSON returned values to a field, as XFA pdf's generally support XML.  You may be able to put the returned JSON value into a single field and then write some code that would parse that value into the proper fields.

  • Can no longer scroll after download to firefox 5

    I can't vertically scroll since downloading firefox 5 from 3.6.18'''bold text'''

    Try to modify the pref ui.trackpoint_hack.enabled on the about:config page from the default value -1 to 0 or 1 to see if that makes the scroll pad work.
    To open the <i>about:config</i> page, type <b>about:config</b> in the location (address) bar and press the "<i>Enter</i>" key, just like you type the url of a website to open a website.<br />
    If you see a warning then you can confirm that you want to access that page.<br />
    *Use the Filter bar at to top of the about:config page to locate a preference more easily.
    *Preferences that have been modified show as bold(user set).
    *Preferences can be reset to the default or changed via the right-click context menu.

  • Can't interact with any open windows, can't interact with flash content

    I've already tried reinstalling, resetting and deleting my profile, nothing's changed.
    I can't close any Firefox window by pressing "x", or by pressing Alt+F4, I can only close it through the task manager or task bar. Minimising or going into windowed mode is also impossible.
    If a new window opens itself (e.g. A download) I can't interact with it at all - It's visible on top of the main window, but nothing I do affects it.
    I also can't interact with flash content (like pausing a youtube video)
    There is absolutely no feedback when I try. The icon doesn't change.
    I recently reset firefox, there are no add-ons, themes etc. installed, the problem persists.
    I am running Windows 7 64bit, everything else (including other browsers) appears to be working fine and a virus scan (Avast! free version) turned up nothing.
    I'd really appreciate any help!

    Hello,
    '''Try Firefox Safe Mode''' to see if the problem goes away. Safe Mode is a troubleshooting mode, which disables most add-ons.
    ''(If you're not using it, switch to the Default theme.)''
    * You can open Firefox 4.0+ in Safe Mode by holding the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * Or open the Help menu and click on the '''Restart with Add-ons Disabled...''' menu item while Firefox is running.
    ''Once you get the pop-up, just select "'Start in Safe Mode"''
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshooting extensions and themes]] article for that.
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    ''When you figure out what's causing your issues, please let us know. It might help other users who have the same problem.''
    Thank you.

  • Can I get scroll bars in lion?

    can I get scroll bars in lion?

    Ninja-neko wrote:
    can I get scroll bars in lion?
    System Preferences > General > Show Scroll Bars
    Pete

Maybe you are looking for

  • Copy oracle server data to remote system over internet

    Hi, I am using Redhat 4 linux system as Oracle 10g server. My database is in archivelog mode. I am not good at data guard so i am not using it. But i want to copy my archive log file to another linux system over internet. so that in case of server cr

  • How to switch off the induction furnace with LabView efter an LCF test is finished?

    Hi, I am working with low cycle fatigue testing at Instron 8801 and are using Instron Fast Track2 LabView LCF software for controlling tests, read the files, calculate modulus, etc. and produce figures. For heating of the specimens during LCF-tests I

  • PowerBook crash and now Mail won't open

    My PowerBook G4 crashed hard some time ago, and since then Mail hasn't worked (I defaulted back to Eudora because I was swamped, but now I finally have some time to try to deal with this). When I open it, I get as far as the menu headings (File, Edit

  • Put two signals in a single waveform

    i wanna put a triangular and a sinusoidal signal in a waveform. i've bundle (i don't know if this is the right thing to do) them but i'm getting wire problems. can somebody help me? p.s. - my VI is attached Message Edited by coimbra on 11-21-2008 01:

  • Alv event on keyboard arrow (up or down)

    Hello, i hope that someone can help me with my problem. i am looking for an event in alv that reacts on the keyboard arrows: cursor up or down. i know that i can use doubleclick or hotspot event, but my customer wants it by cursor up or down. i habe