vertical scrollbar to scroll horizontally

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jlgenf
    New Member
    • Jan 2008
    • 3

    vertical scrollbar to scroll horizontally

    Is it somehow possible to make the vertical scrollbar scroll horizontally?
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by jlgenf
    Is it somehow possible to make the vertical scrollbar scroll horizontally?
    Are you talking about a JScrollBar? It has an orientation property ...

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by r035198x
      Are you talking about a JScrollBar? It has an orientation property ...
      I don't think that's it; the orientation simply tells the JScrollBar how to display:
      horizontally or vertically. Just a scrollbar fires events when it has been moved
      and the user is free to interpret those events. I'm a bit curious though what the
      OP has in mind ...

      kind regards,

      Jos

      Comment

      • RedSon
        Recognized Expert Expert
        • Jan 2007
        • 4980

        #4
        What is it like a joke or something? You want to make a program where you click on a vertical scroll bar and it scrolls it horizontally?

        I once say an application that looked like a simple dialog box, it asked the question "Do you approve of the job Bill Clinton is doing?" It had two buttons, one said "Yes, I do." the other said "No, I don't." The funny part was when you moved your mouse toward the "No" button it would move away from your mouse. You could never click on it because it would move away. It was obviously a joke program but still pretty clever.

        Comment

        • BigDaddyLH
          Recognized Expert Top Contributor
          • Dec 2007
          • 1216

          #5
          Hah!

          [CODE=Java]import java.awt.*;
          import java.io.*;
          import javax.swing.*;

          class HackedScrollpan e extends JScrollPane {
          public HackedScrollpan e(Component view) {
          super(view);
          }

          public void twist() {
          JScrollBar vert = this.verticalSc rollBar;
          JScrollBar horz = this.horizontal ScrollBar;
          this.verticalSc rollBar = horz;
          this.horizontal ScrollBar = vert;
          }
          }

          public class TextAreaExample implements Runnable {
          public static void main(String[] args) throws IOException {
          SwingUtilities. invokeLater(new TextAreaExample ());
          }

          public void run() {
          JTextArea textArea= new JTextArea(20, 30);
          textArea.setFon t(new Font("serif", Font.PLAIN, 16));
          try {
          textArea.read(n ew FileReader("Tex tAreaExample.ja va"), null);
          } catch (IOException e) {
          throw new RuntimeExceptio n(e);
          }
          JFrame f = new JFrame("TextAre aExample");
          f.setDefaultClo seOperation(Win dowConstants.EX IT_ON_CLOSE);
          HackedScrollpan e sp = new HackedScrollpan e(textArea);
          sp.twist();
          f.getContentPan e().add(sp);
          f.pack();
          f.setLocationRe lativeTo(null);
          f.setVisible(tr ue);
          }
          }[/CODE]

          Comment

          • jlgenf
            New Member
            • Jan 2008
            • 3

            #6
            Originally posted by r035198x
            Are you talking about a JScrollBar? It has an orientation property ...
            it's for a friend of mine, who wants to have a photo gallery of his works on his homepage (he is a painter) and he wants to use the vertical scrollbar for the horizontal scrolling (the horizontal scrollbar is hidden). I know, this is a little bit strange, but I can't figure out, how it could be done.
            Thanks for all your answers!

            Comment

            • BigDaddyLH
              Recognized Expert Top Contributor
              • Dec 2007
              • 1216

              #7
              Originally posted by jlgenf
              it's for a friend of mine, who wants to have a photo gallery of his works on his homepage (he is a painter) and he wants to use the vertical scrollbar for the horizontal scrolling (the horizontal scrollbar is hidden). I know, this is a little bit strange, but I can't figure out, how it could be done.
              Thanks for all your answers!
              Web page? Then why use Java? This is starting to sound like JavaScript hacking, now. How is Java involved?

              Comment

              • RedSon
                Recognized Expert Expert
                • Jan 2007
                • 4980

                #8
                ... twist() ROFL!

                Comment

                • BigDaddyLH
                  Recognized Expert Top Contributor
                  • Dec 2007
                  • 1216

                  #9
                  Originally posted by RedSon
                  ... twist() ROFL!
                  <embarrassed>
                  Please don't tell anyone you saw me write that hack!
                  </embarrassed/>

                  Comment

                  • r035198x
                    MVP
                    • Sep 2006
                    • 13225

                    #10
                    Originally posted by BigDaddyLH
                    <embarrassed>
                    Please don't tell anyone you saw me write that hack!
                    </embarrassed/>
                    giggle

                    note: I didn't hear it from RedSon.

                    Comment

                    • jlgenf
                      New Member
                      • Jan 2008
                      • 3

                      #11
                      Originally posted by BigDaddyLH
                      Web page? Then why use Java? This is starting to sound like JavaScript hacking, now. How is Java involved?
                      Java is involved because i don't see any other ways to make it work. If you think there're other options fot that - i'd appreciate your help.
                      And of course this is not a JavaScript hacking.

                      P.S. sorry for not answering so long

                      Comment

                      Working...