java - JScrollPane with scroll arrows but no scrollbar -
i want create scrollpane on picture:
with arrows on component sides , no scrollbar visible. horizontal scrolling needed. can done jscrollpane?
you can make own component using scrollpane , creating own buttons use actions of scrollbar:
import java.awt.*; import javax.swing.*; import javax.swing.plaf.basic.*; public class scrollpanesscce extends jpanel { public scrollpanesscce() { setlayout( new borderlayout() ); jtextarea textarea = new jtextarea(1, 80); textarea.settext("hopefully answer question"); jscrollpane scrollpane = new jscrollpane( textarea ); scrollpane.sethorizontalscrollbarpolicy(scrollpaneconstants.horizontal_scrollbar_never); add(scrollpane); jscrollbar horizontal = scrollpane.gethorizontalscrollbar(); basicarrowbutton west = new basicarrowbutton(basicarrowbutton.west); west.setaction( new actionmapaction("", horizontal, "negativeunitincrement") ); add(west, borderlayout.west); basicarrowbutton east = new basicarrowbutton(basicarrowbutton.east); east.setaction( new actionmapaction("", horizontal, "positiveunitincrement") ); add(east, borderlayout.east); } private static void createandshowui() { jframe frame = new jframe("scrollpanesscce"); frame.setdefaultcloseoperation(jframe.exit_on_close); frame.add(new scrollpanesscce(), borderlayout.north); frame.setsize(100, 100); frame.setlocationbyplatform( true ); frame.setvisible( true ); } public static void main(string[] args) { eventqueue.invokelater(new runnable() { public void run() { createandshowui(); } }); } }
you need use action map action class.
Comments
Post a Comment