Scrolling a JScrollPane in code

hello
java.awt.ScrollPane has a way to send the scrollpane to a certain point in code, however, it seems to be lacking in JScrollPane. how do you scroll in JScrollPane to a certain point?
i tried having the item ask for focus, but that didnt work.
any ideas?

another complication: the panel is being resized as well. while its large, the user clicks on it and i want to have it shrink down to only the selected item. so i shrink it to 37 high and scroll down as previously mentioned. however, if the selection is in the last few, its still stuck on the same extent as before (i think). so it goes down as far as it could while it was large, and no more. so i can never get to those that are only visible while large.
thinking its the extent and/or the visible area, i changed those values and it still doesnt work.
i know its adjustable, because, once its small, the next time i make a selection (selected while small) it scrolls and shrinks (already shrunk) to the selected item. of course, this is easy becasue it must be visible to be selected and as i said, its already shrunk.
the problem is the first time, while its large and the selection shrinks it.
-j

Similar Messages

  • JScrollPane, simple code, why doesnt it work?

    i am just learning how to add scroll bars,
    i do not understand why my code below doesnt work,
    can u tell me how to fix it & what i have done wrong?
    appreciated...
    // ex 5_17 did not have a large enough display area...
    // ex 5_17a changes the way it is displayed, i have added a scroll bar
    import javax.swing.JOptionPane;
    import javax.swing.JTextArea;
    import javax.swing.JScrollPane;
    public class Ex5_17a{
         public static void main( String args [] ){
              int terms = 1;
              double pie = 4;
              double ans = 0;
              double p = 3;
              JTextArea outputArea = new JTextArea( "15,15");
              JScrollPane scroller = new JScrollPane( outputArea );
              String result = "";
         while (terms < 40){
                   terms++;
               if ((terms % 2)==0){
                  pie = pie - (double)(4/p);
                  ans = pie;}
               else{
                  pie = pie + (double)(4/p);
               ans = pie;
               p = p+2;
               result += + pie + "   " + terms + "   " + ans + " \n";
            //outputArea.append(result);
         }//end of while terms<30
         outputArea.setText( result );
            JOptionPane.showMessageDialog(null,
               scroller,"Pie display",JOptionPane.PLAIN_MESSAGE);
         System.exit(0);
         }//end of main
    }//end of class
    [/code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    What does "15, 15" mean?
    If you want to initialize ta with number of rows and cols:
    JTextArea outputArea = new JTextArea(15, 15);
    To make sure you have scrolling that you want one of possibilities of using constants:
    scroll = new JScrollPane(ta,
    ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

  • Scroll bars for this code...

    Hai All,
    Here is the problem i am placing .. when ever there are no.of records to display i want to put the scroll bars to view.... and i am adding my code ... can any one please give me the solution how to add vertical scroll bar to this code....
    import java.util.*;
    import java.awt.*;
    import java.sql.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.lang.ArithmeticException;
    import java.sql.DriverManager;
    import java.sql.Connection;
    import java.sql.Statement;
    import java.sql.ResultSet;
    import java.sql.CallableStatement;
    import java.sql.SQLException;
    import java.awt.BorderLayout;
    import java.awt.event.AdjustmentEvent;
    import java.awt.event.AdjustmentListener;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollBar;
    public class MyExample extends Frame {
    Thread t;
    Frame f ;
    Label bat_result,proc_reply,tot_records,tot_aft_records,dtrs_label,vrs_label1,vrs_label2,vrs_label3,or,dateformat,fileno,fname,fdcode,fdob,fappdate;
    Button b1,dialup,b2,report,b5,vrs,dtrs,dtrs_search,vrs_search;
    ActionListener a;
    TextField value,value1,vrs_fileno,vrs_fdate,vrs_tdate,dtrs_date,fileno_result,fdcode_result,fname_result,fdob_result,fappdate_result;
    Image image,icon;
    Toolkit tool;
    JProgressBar progress;
    JButton button;
    JLabel label1;
    JPanel topPanel;
    Random random;
    MediaTracker mTracker,mTracker1;
    public MyExample()
    setLayout(null);
    setSize(900,600);
         setResizable(true);
         setBackground(new Color(223,224,194));
         setTitle("Menu Window!");
         icon = Toolkit.getDefaultToolkit().getImage("");
         setIconImage(icon);
    setVisible(true);
         tool = Toolkit.getDefaultToolkit();
    image = tool.getImage("");
    mTracker = new MediaTracker(this);
    mTracker.addImage(image,0);
         setSize(900,600);
         a = new MyActionListener();
         add(b1 = new Button(""));
         b1.setBounds(40,180,120,20);
    b1.setBackground(new Color(12632551));
    b1.setActionCommand("");
    b1.addActionListener(a);
    b1.setVisible(true);
         add(dialup = new Button(""));
         dialup.setBounds(40,230,120,20);
    dialup.setBackground(new Color(12632551));
    dialup.setActionCommand("");
    dialup.addActionListener(a);
    dialup.setVisible(true);
         add(b2 = new Button(""));
         b2.setBounds(40,280,120,20);
    b2.setBackground(new Color(12632551));
    b2.setActionCommand("");
    b2.addActionListener(a);
    b2.setVisible(true);
         add(report = new Button(""));
         report.setBounds(40,330,120,20);
    report.setBackground(new Color(12632551));
    report.setActionCommand("");
    report.addActionListener(a);
    report.setVisible(true);
    add(vrs = new Button(" "));
         vrs.setBounds(50,370,120,20);
    vrs.setBackground(new Color(12632551));
    vrs.setActionCommand("");
    vrs.addActionListener(a);
    vrs.setVisible(false);
    add(dtrs = new Button(" "));
         dtrs.setBounds(50,410,120,20);
    dtrs.setBackground(new Color(12632551));
    dtrs.setActionCommand("");
    dtrs.addActionListener(a);
    dtrs.setVisible(false);
    add(dtrs_label = new Label(" "));
    dtrs_label.setBounds(340, 180, 80, 20);
    dtrs_label.setVisible(false);
         add(vrs_label1 = new Label(" "));
    vrs_label1.setBounds(330, 180, 80, 20);
    vrs_label1.setVisible(false);
    add(vrs_label2 = new Label(" "));
    vrs_label2.setBounds(330, 230, 80, 20);
    vrs_label2.setVisible(false);
    add(vrs_label3 = new Label(" "));
    vrs_label3.setBounds(580, 230, 60, 20);
    vrs_label3.setVisible(false);
    add(dateformat = new Label(""));
    dateformat.setBounds(520,180, 80, 20);
    dateformat.setVisible(false);
    add(vrs_search = new Button(""));
         vrs_search.setBounds(250,180,120,20);
    vrs_search.setBackground(new Color(12632551));
    vrs_search.setActionCommand("");
    vrs_search.addActionListener(a);
    vrs_search.setVisible(false);
    add(dtrs_search = new Button(""));
         dtrs_search.setBounds(600,180,120,20);
    dtrs_search.setBackground(new Color(12632551));
    dtrs_search.setActionCommand("");
    dtrs_search.addActionListener(a);
    dtrs_search.setVisible(false);
    add(or = new Label(""));
    or.setBounds(500, 270, 80, 20);
    or.setVisible(false);
         add(b5 = new Button(""));
         b5.setBounds(40,380,120,20);
    b5.setBackground(new Color(12632551));
    b5.setActionCommand("");
    b5.addActionListener(a);
    b5.setVisible(true);
         add(proc_reply=new Label(" "));
         proc_reply.setBounds(350,300,150,20);
    proc_reply.setVisible(false);
    add(tot_records=new Label(" "));
         tot_records.setBounds(350,270,150,20);
    tot_records.setVisible(false);
    add(tot_aft_records=new Label(" "));
    tot_aft_records.setBounds(350,330,180,20);
    tot_aft_records.setVisible(false);
    show();
         addWindowListener(new WindowAdapter()
         public void windowClosing(WindowEvent w)
              System.exit(0);
    public void paint(Graphics g){
    g.drawImage(image,0,0,null);
    class MyActionListener implements ActionListener {
    public void actionPerformed(ActionEvent ae) {
    String s = ae.getActionCommand();
    if( ae.getSource() == button )
    button.setEnabled( false );
         if (s.equals("")) {
    int x=JOptionPane.showConfirmDialog(f,"Do You Want To Close");
         if(x==0){
         System.exit(0);
         else if (s.equals("")) {
         batch b=new batch();
              else if (s.equals("")) {
         dialcall dc=new dialcall();
              else if (s.equals("")){
    procedure proc=new procedure();
    else if (s.equals("")){
    reportcall rc=new reportcall();
    else if (s.equals("")) {
         verification vs=new verification();
              vs.verification1();
    else if (s.equals("")) {
         datatransfer dts=new datatransfer();
         dts.datatransfer1();
                   else if (s.equals("")) {
         datatransfer dts=new datatransfer();
         dts.display(dtrs_date.getText());
    else if (s.equals("")) {
         verification vs=new verification();
         vs.ver_display(vrs_fileno.getText(),vrs_fdate.getText(),vrs_tdate.getText());
    public class batch extends MyExample{
    public batch()
    setTitle("");
         icon = Toolkit.getDefaultToolkit().getImage("");
         setIconImage(icon);
    setVisible(true);
         Process p1;
         try{
         b1.removeActionListener(a);
         p1 = Runtime.getRuntime().exec("");
    p1.waitFor();
    t.sleep(8000);
         batchResult br=new batchResult();
    catch(Exception bat)
              JOptionPane.showMessageDialog(batch.this, "Error: "+bat.toString(), "Warning", JOptionPane.WARNING_MESSAGE);
    public class batchResult extends MyExample{
    public batchResult(){
    String conCount="";
         Connection conresult = null;
         PreparedStatement totalrecords;
         ResultSet resultset = null;
         Statement constmt = null;
         int hh=0;
         try{
    Class.forName("oracle.jdbc.driver.OracleDriver");
    conresult = DriverManager.getConnection( "thindriver");
    constmt = conresult.createStatement();
    conCount = "query";
    totalrecords = conresult.prepareStatement(conCount);
    resultset = totalrecords.executeQuery(conCount);
                   try{
    if(resultset.next()){
                   hh = resultset.getInt("rec");
                   }catch(Exception we)
                        JOptionPane.showMessageDialog(batchResult.this, "Error: "+we.toString(), "Warning", JOptionPane.WARNING_MESSAGE);
                   if(hh!=0){
    JOptionPane.showMessageDialog(f,"No.of records Imported: "+hh);
    else {
                   JOptionPane.showMessageDialog(f,"No Records Found to Transfer");
                   }catch(Exception ew)
                        JOptionPane.showMessageDialog(batchResult.this, "Error: "+ew.toString(), "Warning", JOptionPane.WARNING_MESSAGE);
    public class dialcall extends MyExample{
    public dialcall()
    b1.removeActionListener(a);
    setTitle("");
         icon = Toolkit.getDefaultToolkit().getImage("");
         setIconImage(icon);
    setVisible(true);
         Process p2;
         try{
         b1.removeActionListener(a);
         p2 = Runtime.getRuntime().exec("");
    p2.waitFor();
    catch(InterruptedException dl)
              JOptionPane.showMessageDialog(dialcall.this, "Error: "+dl.toString(), "Warning", JOptionPane.WARNING_MESSAGE);
    catch(Exception dl)
              JOptionPane.showMessageDialog(dialcall.this, "Error: "+dl.toString(), "Warning", JOptionPane.WARNING_MESSAGE);
    public class procedure extends MyExample{
    public procedure()
    setSize(900,600);
         setTitle("");
         icon = Toolkit.getDefaultToolkit().getImage("");
         setIconImage(icon);
    setVisible(true);
    b1.removeActionListener(a);
         dialup.removeActionListener(a);
         //b2.removeActionListener(a);
    Statement stmt = null;
         // DB Connection Variables
    final String driverClass = "oracle.jdbc.driver.OracleDriver";
    final String connectionURL = "";
    final String userID = "";
    final String userPassword = "";
    String beforeCount="";
         String afterCount="";
         Connection con = null;
         Connection con1 = null;
         PreparedStatement bCountRecords;
    PreparedStatement aCountRecords;
    int a=0,b=0;
    ResultSet rset2 = null;
         ResultSet rset1 = null;
         String cnt="";
         String cnt1="";
         String bb=null;
         //CallableStatement cstmt1 = null;
         //CallableStatement cstmt2 = null;
         ProgressBarExample pbe=new ProgressBarExample();
         pbe.setVisible( true );
         try{
         Class.forName("oracle.jdbc.driver.OracleDriver");
    con = DriverManager.getConnection( "thindriver");
    stmt = con.createStatement ();
    beforeCount = "";
              afterCount = "";
    bCountRecords = con.prepareStatement(beforeCount);
    aCountRecords = con.prepareStatement(afterCount);
              rset1 = bCountRecords.executeQuery(beforeCount);
                   try{
                   Runtime.getRuntime().exec(" ");
              Runtime.getRuntime().exec(" ");
    catch (Exception proc1) {
    proc1.printStackTrace();
         rset2 = aCountRecords.executeQuery(afterCount);
    if(rset1.next()){
                   a = rset1.getInt("bcnt");
                   String aa = Integer.toString(a);
              display1(aa);
    if(rset2.next())
         b=rset2.getInt("acnt");
         while(true){
                   rset2 = aCountRecords.executeQuery(afterCount);
              if (rset2.next()){
                   b=rset2.getInt("acnt");
                        System.out.println(a);
                                            System.out.println(b);
    if(b==a)
         bb = Integer.toString(b);
         display2(bb);
         processbar(a,b);
         button.setVisible( false );
         JOptionPane.showMessageDialog(f,"Records Transfered Successfully");
         break;
    else if (a!=0)
    processbar(a,b);
    else {
         pbe.setVisible(false);
    JOptionPane.showMessageDialog(f,"No Records found to transfer");
    break;
         } catch (ClassNotFoundException proc) {
    // proc.printStackTrace();
              JOptionPane.showMessageDialog(procedure.this, "Error: "+proc.toString(), "Warning", JOptionPane.WARNING_MESSAGE);
    } catch (SQLException proc) {
    // proc.printStackTrace();
              JOptionPane.showMessageDialog(procedure.this, "Error: "+proc.toString(), "Warning", JOptionPane.WARNING_MESSAGE);
    // proc_reply.setBounds(240,310,150,20);
    // proc_reply.setVisible(true);
    public void display1(String count)
         tot_records.setBounds(350,250,180,20);
         tot_records.setVisible(true);
         value=new TextField(count);
         value.setBounds(550,250,180,20);
         value.setVisible(true);
         add(value);
         value.setEditable(false);
         public void display2(String count1)
    tot_aft_records.setBounds(350,450,180,20);
         tot_aft_records.setVisible(true);
         value1=new TextField(count1);
         value1.setBounds(550,450,180,20);
         value1.setVisible(true);
         add(value1);
         value1.setEditable(false);
    public void processbar(int a,int b)
    label1.setText( "Record " + b+ " of "+a );
    Rectangle labelRect = label1.getBounds();
    labelRect.x = 0;
    labelRect.y = 0;
    label1.paintImmediately( labelRect );
    progress.setValue( b*100/a );
                                  Rectangle progressRect = progress.getBounds();
    progressRect.x = 0;
    progressRect.y = 0;
                                  progress.paintImmediately( progressRect );
         DoBogusTask(b);
    public void DoBogusTask( int iCtr )
    random = new Random( iCtr );
    for( int iValue = 0; iValue < random.nextFloat() *1; iValue++ )
    public     class ProgressBarExample extends JFrame
    public ProgressBarExample()
                        setTitle( "" );
                        setLocation(450,300);
    setSize( 310, 130 );
         //setBackground( Color. );
    // setBackground(new Color(14672066));
    topPanel = new JPanel();
    topPanel.setPreferredSize( new Dimension( 310, 130 ) );
    getContentPane().add( topPanel);
    label1 = new JLabel( "Waiting to start tasks..." );
    label1.setPreferredSize( new Dimension( 280, 24 ) );
    topPanel.add( label1 );
    progress = new JProgressBar();
    progress.setPreferredSize( new Dimension( 300, 20 ) );
                        progress.setMinimum( 0 );
    progress.setMaximum(100 );
    progress.setValue( 0 );
    progress.setBounds( 20, 35, 260, 20 );
    topPanel.add( progress );
    button = new JButton( "Start Process" );
    topPanel.add( button );
                        button.setVisible(false);
    button.addActionListener( a );
         public class reportcall extends MyExample{
    public reportcall()
    report.setVisible(true);
         b1.removeActionListener(a);
         b2.removeActionListener(a);
         report.removeActionListener(a);
         b5.setVisible(false);
         b5.setBounds(40,440,120,20);
         b5.setVisible(true);
    vrs.setVisible(true);
         dtrs.setVisible(true);
    public class verification extends MyExample{
    public void verification1(){
         setTitle("");
         icon = Toolkit.getDefaultToolkit().getImage("");
         setIconImage(icon);
    setVisible(true);
    vrs_fileno = new TextField("");
    vrs_fileno.setBounds(450, 180, 80, 20);
    add(vrs_fileno);
    vrs_fileno.setVisible(true);
         vrs_label1.setVisible(true);
         or.setBounds(450, 210, 80, 20);
         or.setVisible(true);
         vrs_fdate = new TextField("");
    vrs_fdate.setBounds(450, 230, 120, 20);
    add(vrs_fdate);
    vrs_fdate.setVisible(true);
         vrs_label2.setVisible(true);
         vrs_tdate = new TextField("");
    vrs_tdate.setBounds(650, 230, 120, 20);
    add(vrs_tdate);
    vrs_tdate.setVisible(true);
         vrs_label3.setVisible(true);
    dateformat.setVisible(false);
    dateformat.setBounds(780, 230, 120, 20);
    dateformat.setVisible(true);
         vrs_search.setVisible(false);
         vrs_search.setBounds(500,300, 80, 20);
         vrs_search.setVisible(true);
    public void ver_display(String fno,String fdate,String tdate){
    String FILE_NO1;
    String NAME1;
    String ADDRESS_TYPE1;
    String VER_STATUS1;
    int i1=0,b=0;
    Connection con1 = null;
    Statement stmt1 = null;
    try {
         Class.forName("oracle.jdbc.driver.OracleDriver");
    con1 = DriverManager.getConnection( "thin driver");
    stmt1 = con1.createStatement();
    String qry1 = "";
         String qry2 ="";
              ResultSet rs12 = stmt1.executeQuery(qry2);
                   if(rs12.next())
         b=rs12.getInt("cnt");
    if(b==0){
              JOptionPane.showMessageDialog(f,"No Records Found");}
                   else{
                        ResultSet rs11 = stmt1.executeQuery(qry1);
    while (rs11.next()) {
                   FILE_NO1 = rs11.getString(1);
    NAME1 = rs11.getString(2);
    ADDRESS_TYPE1 = rs11.getString(3);
    VER_STATUS1 = rs11.getString(4);
    show(FILE_NO1, NAME1, ADDRESS_TYPE1, VER_STATUS1, i1++);
    catch (ClassNotFoundException proc) {
    // proc.printStackTrace();
    catch (SQLException proc) {
    //proc.printStackTrace();
    public void show(String a, String b, String c, String d,int i) {
    Label fileno=new Label("File No");
    Label fname=new Label("Name");
    Label faddtype =new Label("Address Type");
    Label fstatus=new Label("Status");
         TextField fileno_result = new TextField(a);
    TextField fname_result = new TextField(b);
    TextField faddtype_result = new TextField(c);
    TextField fstatus_result = new TextField(d);
    fileno.setBounds(340, 180, 100, 20);
    add(fileno);
    fname.setBounds(440, 180, 130, 20);
    add(fname);
    faddtype.setBounds(575, 180, 120, 20);
    add(faddtype);
    fstatus.setBounds(700, 180, 90, 20);
    add(fstatus);
         fileno_result.setBounds(320, 200 + 20 * i, 100, 20);
    add(fileno_result);
    fileno_result.setVisible(true);
    fileno_result.setEditable(false);
    fname_result.setBounds(420, 200 + 20 * i, 150, 20);
    add(fname_result);
    fname_result.setVisible(true);
         fname_result.setEditable(false);
         faddtype_result.setBounds(570, 200 + 20 * i, 120, 20);
    add(faddtype_result);
    faddtype_result.setVisible(true);
         faddtype_result.setEditable(false);
    fstatus_result.setBounds(690, 200 + 20 * i, 120, 20);
    add(fstatus_result);
         fstatus_result.setVisible(true);
    fstatus_result.setEditable(false);
    public class datatransfer extends MyExample{
    public void datatransfer1(){
    setTitle("");
         icon = Toolkit.getDefaultToolkit().getImage("");
         setIconImage(icon);
    setVisible(true);
    dtrs_date = new TextField("");
    dtrs_date.setBounds(420, 180, 80, 20);
    add(dtrs_date);
         dateformat.setVisible(true);
    dtrs_date.setVisible(true);
         dtrs_search.setVisible(true);
         dtrs_label.setVisible(true);
    public void display(String date1){
    String FILE_NO;
    String DIST_CODE;
    String NAME;
    String DOB;
              String APPLN_DATE;
    int i1=0,b=0;
    Connection con1 = null;
    Statement stmt1 = null;
    try {
         Class.forName("oracle.jdbc.driver.OracleDriver");
    con1 = DriverManager.getConnection( "thin driver");
    stmt1 = con1.createStatement();
    String qry1 = "";
    String qry2 = "";
              ResultSet rs12 = stmt1.executeQuery(qry2);
                   if(rs12.next())
         b=rs12.getInt("cnt");
    if(b==0){
              JOptionPane.showMessageDialog(f,"No Records on this date");}
                   else{
                        ResultSet rs11 = stmt1.executeQuery(qry1);
    while (rs11.next()) {
                   FILE_NO = rs11.getString(1);
    DIST_CODE=rs11.getString(2);
                   NAME = rs11.getString(3);
    DOB = rs11.getString(4);
    APPLN_DATE = rs11.getString(5);
    show1(FILE_NO, DIST_CODE, NAME, DOB,APPLN_DATE,i1++);
    catch (ClassNotFoundException proc) {
    //proc.printStackTrace();
    catch (SQLException proc) {
    // proc.printStackTrace();
    public void show1(String a, String b, String c, String d,String e,int i) {
    fileno=new Label("File No");
    fdcode=new Label("District");
    fname =new Label("Name");
    fdob=new Label("Date Of Birth");
         fappdate=new Label("Application Date");
    TextField fileno_result = new TextField(a);
    TextField fdcode_result = new TextField(b);
    TextField fname_result = new TextField(c);
    TextField fdob_result = new TextField(d);
    TextField fappdate_result = new TextField(e);
    fileno.setBounds(323, 180, 80, 20);
    add(fileno);
    fdcode.setBounds(420, 180, 40, 20);
    add(fdcode);
    fname.setBounds(480, 180, 100, 20);
    add(fname);
    fdob.setBounds(590, 180, 120, 20);
    add(fdob);
    fappdate.setBounds(710, 180, 120, 20);
    add(fappdate);
         fileno_result.setBounds(320, 200 + 20 * i, 100, 20);
    add(fileno_result);
    fileno_result.setVisible(true);
    fileno_result.setEditable(false);
    fdcode_result.setBounds(420, 200 + 20 * i, 40, 20);
    add(fdcode_result);
    fdcode_result.setVisible(true);
         fdcode_result.setEditable(false);
         fname_result.setBounds(460, 200 + 20 * i, 120, 20);
    add(fname_result);
    fname_result.setVisible(true);
         fname_result.setEditable(false);
    fdob_result.setBounds(580, 200 + 20 * i, 120, 20);
    add(fdob_result);
         fdob_result.setVisible(true);
    fdob_result.setEditable(false);
    fappdate_result.setBounds(700, 200 + 20 * i, 120, 20);
    add(fappdate_result);
         fappdate_result.setVisible(true);
    fappdate_result.setEditable(false);
    public static void main(String[] args) {
    MyExample bpd = new MyExample();
    bpd.setVisible(true);
    }

    deleted - wrong forum, try the swing posting

  • Elder Scrolls Imperial Early Access COde

    Hello, 
    I pre-orderd the PC version of Elder Scrolls Online Imperial Edition. And I dont think I ever got an email with my early access code. Or if I did it is long gone. Is it possible to get this reissued? I have the reciept info available if needed.
    Thank you.

    Hello Iphill,
    If you still haven't received your Elder Scrolls Online early access code, then you'll want to send a message to our Gaming-BBY inbox that includes the following information:
    Message Subject: Game Title & Platform
    Message Body: Include...
    • Proof of purchase (Customer Service PIN from in-store receipt or BestBuy.com order #)
    • Email address (the one you provided for the code)
    We'll then be able to investigate why you might not have received your code and follow-up with you as soon as possible. Please note, however, that sending multiple messages will not result in faster response. Please also do not send messages to multiple moderators as all inquiries on this subject will be forwarded to the Gaming-BBY inbox inbox.
    Aaron|Social Media Specialist | Best Buy® Corporate
     Private Message

  • Scroll 2 JScrollPanes together?

    Quick question. (I hope it's quick anyway.)
    I have 2 JTextAreas side by side added to JScrollPanes.
    I past a list in the one on the left, click a button to do something with that list and it writes to the JTextArea on the right like a log file.
    If the list is longer than the JTextArea is tall, It puts a scroll bar on the right. And when the log pane gets too long, I keep the scrollbar on it at the bottom with this line of code:
    somelog.setCaretPosition(somelog.getText().length());My question is...Can I make the scrollbars of both syncronized? Because right now, only the one on the right keeps up with the bottom of it's text. I would like them both to scroll at the same time. Because there is one line of log output for each item in the list. I would like for when the log starts scrolling, the list scrolls with it so the items remain lined up.
    Thanks!
    Tim

    Try sharing the scrollpanes' scrollbars' model
    scrollList.getVerticalScrollBar().setModel(scrollLog.getVerticalScrollBar().getModel());db

  • JEditorPane not scrolling in JScrollPane no matter what

    Hello,
    I thoroughly researched this problem and I tried all suggestions, but nothing seems to work. I have a JEditorPane inside the JScrollPane, but JEditorPane does not scroll horizontally no matter what. It simply cuts off the text to the right.
    Here is my code:
    reportArea = new JEditorPane() {
    public boolean getScrollableTracksViewportWidth() {                   
    if (getSize().width < getParent().getSize().width)
         return true;
    else
         return false;
    public void setSize(Dimension d) {                   
    if (d.width < getParent().getSize().width)
         d.width = getParent().getSize().width;
    super.setSize(d);
    reportArea.setEditorKit(new HTMLEditorKit());
    reportArea.setEditable(false);
    JScrollPane reportJ = new JScrollPane(reportArea);
    reportJ.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    reportJ.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    Any suggestions will be greatly and truly appreciated!
    Elana

    I need to display HTML page, that's why I need JEditorPane. Also, In the html table that I'm displaying I have the nowrap attribute, so nothing gets wrapped at all. It's just being cut off...
    ;-(

  • EA1 - Right gutter scroll bar in the Code Editor doesn't work?

    SQL Developer version 4.0.0.12, Windows XP
    I'm opening package body in Code Editor. In previous version of SQL Dev after pressing CTRL and moving mouse over the right gutter I could see a few lines of the code from mouse pointed position in the source.
    Now it doesn't work.
    Link below - section "Working in the Procedure Editor":
    http://www.thatjeffsmith.com/archive/2012/01/viewing-plsql-compilation-errors-in-oracle-sql-developer/

    Hi,
    It is true the right gutter's general scrolling window view capability no longer exists in 4.0.  However, if code errors exist, then small blue squares (uncompiled code) or slightly larger red rectangles (compiled code) appear in the gutter representing the relative positions of the bad code.  Hovering the mouse over those produces a pop-up display of the offending code and, in fact, the pop-up will not display if the Ctrl key is pressed at the same time. Of course, clicking on the rectangles or squares moves the editor's current line to that code as in earlier releases.
    So it is not clear whether this is merely the new, intended behavior, or if more of the prior behavior remains to be implemented in 4.0.  As far as I can tell, nothing important has been lost here, but that is just my opinion.
    Regards,
    Gary
    SQL Developer Team

  • How do I invert the horizontal trackpad scrolling in Dreamweaver CC code window (Mac)?

    Having recently installed CC I'm enjoying all the apps so far...although Dreamweaver (which I use quite a lot) is showing unusual scrolling behaviour.
    In my previous version of Creative Suite, for all apps I have a two-handed approach where I use the trackpad to navigate around the document with two fingers, while using a mouse to select the code/element etc.
    I have already turned off the default 'natural' vertical scroll because it feels more intuitive to me (i.e. if I want to scroll down the page, I pull down with two fingers).
    However, with this new version of Dreamweaver, it breaks convention by having reversed the left-right scroll direction, which has thrown me because it is the only app so far that goes against the norm. Previously if I wanted to see code off the right hand side of the window, I would swipe right, but now I have to swipe left. I had a look at the settings and couldn't see a way of changing this.
    Can anyone help?
    Thanks

    Yes, this issue has been fixed in DW CC 2014.1 release. Please try the same.
    More on this is below
    Dreamweaver October 2014 release is now live! Important information.
    Install instructions are below
    Installing the latest update of Dreamweaver CC 2014

  • Implementing a graph scrolling using JScrollPane component

    I would like to ask a question apropos using of JScrollPane component. A part of the default behaviour of this component is adjusting the component's state when the size of the client changes. But, I need to achieve an opposite effect - I need to adjust a size of my client when the size of JScrollPane (and its viewport) changes (for instance, when the user resizes the frame).
    I implement a graph component which will show the graph of a time function. This component should always show nnn seconds without connection to the size of the scroll pane's viewport. So, if the the scroll pane component is resized I need to adjust the size of my client in order to keep the displayed time period unchanged.
    Now the question: how may I check the size of the viewport when the size of the JScrollPane changes? And whether I can do it even if the JScrollPane component has no client?
    If you know any other method of achieving the same effect, plese let me know.
    Thanks.

    I still find getExten\tSize (and getViewRect) work for me. Here's another demo.
    In my component, there's a big oval thats bounded by my component and a smaller
    oval that should track with the viewport's bounds.
    import java.awt.*;
    import javax.swing.*;
    public class ViewportLemonJuice extends JPanel {
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.drawOval(0, 0, getWidth(), getHeight());
            Container parent = (Container) getParent();
            if (parent instanceof JViewport) {
                Rectangle rect = ((JViewport) parent).getViewRect();
                g.drawOval(rect.x, rect.y, rect.width, rect.height);
        public static void main(String[] args) {
            JComponent comp = new ViewportLemonJuice();
            comp.setPreferredSize(new Dimension(800,800));
            JScrollPane sp = new JScrollPane(comp);
            sp.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE);
            JFrame f = new JFrame("ViewportLemonJuice");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(sp);
            f.setSize(500,300);
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

  • Help trying to insert JScrollPane into code

    Yes! It is me again on the same program. I have the program working with a few peoples help on this board. But, I want to make the display look better. So, I thought I would use the JScrollPane component. But, I'm getting a cannot resolve symbol error on the following statement.
    f.setContentPane(scrollPane);
    The code is below. Any help in getting the JScrollPane to work would be very appreciated.
    Code:
    import java.util.*;
    import mycorejava.Day;
    import mycorejava.*;
    import myjavastdio.*;
    import java.io.*;
    import java.text.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class P5AWT extends JFrame
    private JTextField inputfile;
    private JTextField outputfile;
    private JTextArea ta;
    private JMenuItem newMT, openMT, saveAsMT, exitMT;
    String curFile, filename = "";
    int numstaff;
    Employee[] staff;
    public P5AWT()
    super ("P5AWT Starter Program");
    addWindowListener(new WindowAdapter()
    { public void windowClosing(WindowEvent e) { System.exit(0); }} );
    JMenuBar mb = new JMenuBar ();
    setJMenuBar(mb);
    JMenu fileMenu = new JMenu ("File");
    mb.add(fileMenu);
    fileMenu.add (newMT = new JMenuItem ("New"));
    newMT.addActionListener( new NewCommand());
    fileMenu.add (openMT = new JMenuItem ("Open"));
    openMT.addActionListener( new LoadFileCommand());
    fileMenu.add (saveAsMT = new JMenuItem ("Save As"));
    saveAsMT.addActionListener( new SaveAsFileCommand());
    fileMenu.add (exitMT = new JMenuItem ("Exit"));
    exitMT.addActionListener( new CloseCommand());
    JPanel p3 = new JPanel();
    getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER));
    ta = new JTextArea(200, 40);
    //p3.add(ta);
    //getContentPane().add(p3, BorderLayout.CENTER);
    JScrollPane scrollPane = new JScrollPane(ta);
    f.setContentPane(scrollPane);
    // Bail Out
    class CloseCommand implements ActionListener {
    public void actionPerformed (ActionEvent e) {
    System.exit (0);
    // New
    class NewCommand implements ActionListener {
    public void actionPerformed (ActionEvent e) {
    ta.setText(" ");
    // Load a file into the text area.
    class LoadFileCommand implements ActionListener {
    public void actionPerformed (ActionEvent e) {
    int state;
    String msg;
    FileDialog file = new FileDialog (P5AWT.this, "Open File", FileDialog.LOAD);
    file.setFile ("*.*"); // Set initial filename filter
    file.show(); // Blocks
    if ((curFile = file.getFile()) != null) {
    System.out.println(curFile.substring(curFile.indexOf(".") + 1));
    filename = file.getDirectory() + curFile;
    setCursor (Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    doit( filename );
    setCursor (Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    // Load a file into the text area.
    class SaveAsFileCommand implements ActionListener {
    public void actionPerformed (ActionEvent e) {
    int state;
    String msg;
    FileDialog file = new FileDialog (P5AWT.this, "Save As", FileDialog.SAVE);
    file.setFile ("*.*"); // Set initial filename filter
    file.show(); // Blocks
    if ((curFile = file.getFile()) != null) {
    filename = file.getDirectory() + curFile;
    setCursor (Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    saveAs(filename);
    setCursor (Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    public static void main(String[] args)
    JFrame f = new P5AWT();
    f.setSize(475,400);
    f.setVisible(true);
    f.show();
    public void saveAs(String file)
              String emptype = "";
              try
                   PrintWriter fout = Text.create(file);     //attempts to open output
                   for( int x = 0; x < numstaff; x++ )
         if (staff != null) emptype = (staff[x].getClass().getName());
         if (emptype.equals("Employee"))
         staff[x].printToFile(fout);
    //ta.append("\n\n******************** MANAGERS ********************\n");
         for( int x = 0; x < numstaff; x++ )
         if (staff[x] instanceof Manager)
    //staff[x] = (Manager)staff[x]; - This is used if access to elements needed outside of class
         staff[x].printToFile(fout);
                   fout.close();
              catch(IOException e)
                   System.out.println("An IO Exception occured!");
    public void doit(String file)
    String filename = "";
    String emptype = "";
    String firstname = "";
    String lastname = "";
    String ssn = "";
    String hiredate = null;
    String secfirstname = "";
    String seclastname = "";
    String ofile = "";
    numstaff = 0;
    int yy = 0;
    int mm = 0;
    int dd = 0;
    double salary = 0;
    try
    BufferedReader fin = Text.open(file); // attempts to open data file
    try
    numstaff = Text.readInt(fin); // # of records to set array size
    staff = new Employee[numstaff];
    for(int x = 0; x <= numstaff; x++) // # of records
    emptype = Text.readString(fin);
    firstname = Text.readString(fin);
    lastname = Text.readString(fin);
    ssn = Text.readString(fin);
    salary = Text.readDouble(fin);
    yy = Text.readInt(fin);
    mm = Text.readInt(fin);
    dd = Text.readInt(fin);
    if(emptype.equals("M"))
    secfirstname = Text.readString(fin);
    seclastname = Text.readString(fin);
    staff[x] = new Manager( emptype, firstname, lastname, ssn, salary,
    yy, mm, dd, secfirstname, seclastname);
    else
    staff[x] = new Employee(emptype, firstname, lastname, ssn, salary,
    yy, mm, dd);
    staff[x].raiseSalary(5);
    catch (EOFException e)
    ta.append("******************** EMPLOYEES ********************\n");
    for( int x = 0; x < numstaff; x++ )
    if (staff != null) emptype = (staff[x].getClass().getName());
    if (emptype.equals("Employee"))
    staff[x].printToAwt(ta);
    ta.append("\n\n******************** MANAGERS ********************\n");
    for( int x = 0; x < numstaff; x++ )
    if (staff[x] instanceof Manager)
    //staff[x] = (Manager)staff[x]; - This is used if access to elements needed outside of class
    staff[x].printToAwt(ta);
    catch (FileNotFoundException e) // file not found, what the heck is this e thing
    System.out.println("The file: " + file + " doesn't exist! ABORTING!");
    catch(IOException e)
    System.out.println("An IO Exception occured!");
    class Employee
    private NumberFormat coolsalary = NumberFormat.getCurrencyInstance(Locale.US);
    public Employee(String emptype, String fn, String ln, String ssn, double s, int yy, int mm, int dd)
    type = emptype;
    fname = fn;
    lname = ln;
    salary = s;
    social = ssn;
    year = yy;
    day = dd;
    month = mm;
    hireDay = new Day(year,month,day);
    public void print()
    System.out.println();
    System.out.print(fname + " " + lname + "\t" + social + " " + coolsalary.format(salary) + " " + hireDay.toString()); }
    public void printToFile(PrintWriter out)
    out.println();
    out.print(fname + " " + lname + "\t" + social + " " + coolsalary.format(salary) + " " + hireDay.toString());
    public void printToAwt(javax.swing.JTextArea ta)
    ta.append("\n");
    ta.append(fname + " " + lname + "\t" + social + " " + coolsalary.format(salary) + " " + hireDay.toString());
    public void raiseSalary(double byPercent)
    salary *= 1 + byPercent / 100;
    public int hireYear()
    {  return hireDay.getYear();
    public String type;
    public String fname;
    public String lname;
    public double salary;
    public String d;
    public String social;
    public int year;
    public int month;
    public int day;
    public Day hireDay;
    private Date date;
    class Manager extends Employee
    public Manager(String emptype, String fn, String ln, String ssn, double s, int yy, int mm, int dd, String fsec, String lsec)
    super(emptype, fn, ln, ssn, s, yy, mm, dd);
    secretaryfName = fsec;
    secretarylName = lsec;
    public void raiseSalary(double byPercent)
    {  // add 1/2% bonus for every year of service
    Day today = new Day();
    double bonus = 0.5 * (today.getYear() - hireYear());
    super.raiseSalary(byPercent + bonus);
    public void print()
    {    super.print();
    System.out.print(" " + getName());
    public void printToAwt(javax.swing.JTextArea ta)
    super.printToAwt(ta);
    ta.append(" " + getName());
    public void printToFile( PrintWriter out)
    super.printToFile(out);
    out.print(" " + getName());
    public void setSecretaryName(String fn, String ln)
    {  secretaryfName = fn;
    secretarylName = ln;
    public String getName()
    {  return secretaryfName + " " + secretarylName;
    private String secretaryfName;
    private String secretarylName;

    Alright, I feel like the biggest idiot that ever walked the earth. Thank you for your help.

  • Programatic scrolling in JScrollPane

    Hi all,
    I have a JPanel with a GridLayout that contains a series of other JPanels, the whole stuff looks like a list.
    JPanel masterPanel = new JPanel( new GridLayout( .. ) );
    masterPanel.add( new JPanel( .. ) );
    masterPanel.add( new JPanel( .. ) );
    masterPanel.add( new JPanel( .. ) );
    The GridLayout defines one single column, so that all the JPanels look like arranged in a list.
    The masterPanel is then embedded into a JScrollPane using
    setViewPortView( masterPanel );
    now:
    when the JFrame that contains all this is shown the first time I want the JScrollPane to be scrolled to the top.
    I tried to directly manipulate the JScrollBars (setValue( 0 ),
    I used ViewPort.setViewPosition( new Point ( 0, 0 ) ),
    I used scrollPane.scrollRectToVisible( new Rectangle( 0, 0, 20, 20 ) )
    but nothing worked so far, the scroll pane is always scrolled to the bottom ....
    I also browsed the forum but did not find anything that worked.
    Anybody any idea ?
    Andy

    I used scrollPane.scrollRectToVisible( new Rectangle(
    0, 0, 20, 20 ) )don't use the scrollPane but your masterPanel.scrollRectToVisible(...)!
    thomas

  • Trying to scroll a JComponent with JScrollPane but can't do it. :(

    Hi, what im trying to do seems to be simple but I gave up after trying the whole day and I beg you guys help.
    I created a JComponent that is my map ( the map consists only in squared cells ). but the map might be too big for the screen, so I want to be able to scroll it. If the map is smaller than the screen,
    everything works perfect, i just add the map to the frame container and it shows perfect. But if I add the map to the ScrollPane and them add the ScrollPane to the container, it doesnt work.
    below is the code for both classes Map and the MainWindow. Thanks in advance
    package main;
    import java.awt.Color;
    import java.awt.event.WindowEvent;
    import java.awt.event.WindowStateListener;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JViewport;
    public class MainWindow implements WindowStateListener {
         private JFrame frame;
         private static MainWindow instance = null;
         private MenuBar menu;
         public Map map = new Map();
         public JScrollPane Scroller =
              new JScrollPane( map,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS );
         public JViewport viewport = new JViewport();
         private MainWindow(int width, int height) {
              frame = new JFrame("Editor de Cen�rios v1.0");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setSize(width,height);
              frame.setVisible(true);
              menu = MenuBar.createMenuBar();
              JFrame.setDefaultLookAndFeelDecorated(false);
              frame.setJMenuBar(menu.create());
              frame.setBackground(Color.WHITE);
              frame.getContentPane().setBackground(Color.WHITE);
                                    // HERE IS THE PROBLEM, THIS DOESNT WORKS   <---------------------------------------------------------------------------------------
              frame.getContentPane().add(Scroller);
              frame.addWindowStateListener(this);
    public static MainWindow createMainWindow(int width, int height)
         if(instance == null)
              instance = new MainWindow(width,height);
              return instance;               
         else
              return instance;
    public static MainWindow returnMainWindow()
         return instance;
    public static void main(String[] args) {
         MainWindow mWindow = createMainWindow(800,600);
    public JFrame getFrame() {
         return frame;
    public Map getMap(){
         return map;
    @Override
    public void windowStateChanged(WindowEvent arg0) {
         map.repaint();
    package main;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Rectangle;
    import javax.swing.JComponent;
    import javax.swing.Scrollable;
    public class Map extends JComponent  implements Scrollable{
         private Cell [] mapCells;
         private String mapPixels;
         private String mapAltura;
         private String mapLargura;
         public void createMap(String pixels , String altura, String largura)
              mapPixels = pixels;
              mapAltura = altura;
              mapLargura = largura;
              int cells = Integer.parseInt(altura) * Integer.parseInt(largura);
              mapCells = new Cell[cells];
              //MainWindow.returnMainWindow().getFrame().getContentPane().add(this);
              Graphics2D grafico = (Graphics2D)getGraphics();
              for(int i=0, horiz = 0 , vert = 0; i < mapCells.length; i++)
                   mapCells[i] = new Cell( horiz, vert,Integer.parseInt(mapPixels));
                   MainWindow.returnMainWindow().getFrame().getContentPane().add(mapCells);
                   grafico.draw(mapCells[i].r);
                   horiz = horiz + Integer.parseInt(mapPixels);
                   if(horiz == Integer.parseInt(mapLargura)*Integer.parseInt(mapPixels))
                        horiz = 0;
                        vert = vert + Integer.parseInt(mapPixels);
              repaint();
         @Override
         protected void paintComponent(Graphics g) {
              super.paintComponent(g);
              System.out.println("entrou");
              Graphics2D g2d = (Graphics2D)g;
              if(mapCells !=null)
                   for(int i=0, horiz = 0 , vert = 0; i < mapCells.length; i++)
                        g2d.draw(mapCells[i].r);
                        horiz = horiz + Integer.parseInt(mapPixels);
                        if(horiz == Integer.parseInt(mapLargura)*Integer.parseInt(mapPixels))
                             horiz = 0;
                             vert = vert + Integer.parseInt(mapPixels);
         @Override
         public Dimension getPreferredScrollableViewportSize() {
              return super.getPreferredSize();
         @Override
         public int getScrollableBlockIncrement(Rectangle visibleRect,
                   int orientation, int direction) {
              // TODO Auto-generated method stub
              return 5;
         @Override
         public boolean getScrollableTracksViewportHeight() {
              // TODO Auto-generated method stub
              return false;
         @Override
         public boolean getScrollableTracksViewportWidth() {
              // TODO Auto-generated method stub
              return false;
         @Override
         public int getScrollableUnitIncrement(Rectangle visibleRect,
                   int orientation, int direction) {
              // TODO Auto-generated method stub
              return 5;

    Im so sorry Darryl here are the other 3 classes
    package main;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.BoxLayout;
    import javax.swing.JButton;
    import javax.swing.JFileChooser;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JTextField;
    import javax.swing.filechooser.FileNameExtensionFilter;
    public class MenuActions {
         public void newMap(){
              final JTextField pixels = new JTextField(10);
              final JTextField hCells = new JTextField(10);
              final JTextField wCells = new JTextField(10);
              JButton btnOk = new JButton("OK");
              final JFrame frame = new JFrame("Escolher dimens�es do mapa");
              frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(),BoxLayout.Y_AXIS));
              btnOk.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
              String txtPixels = pixels.getText();
              String hTxtCells = hCells.getText();
              String wTxtCells = wCells.getText();
              frame.dispose();
              MainWindow.returnMainWindow().map.createMap(txtPixels,hTxtCells,wTxtCells);         
              frame.getContentPane().add(new JLabel("N�mero de pixels em cada c�lula:"));
              frame.getContentPane().add(pixels);
              frame.getContentPane().add(new JLabel("Altura do mapa (em c�lulas):"));
              frame.getContentPane().add(hCells);
              frame.getContentPane().add(new JLabel("Largura do mapa (em c�lulas):"));
              frame.getContentPane().add(wCells);
              frame.getContentPane().add(btnOk);
              frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
              frame.setSize(300, 165);
              frame.setResizable(false);
             frame.setVisible(true);
         public Map openMap (){
              //Abre somente arquivos XML
              JFileChooser fc = new JFileChooser();
              FileNameExtensionFilter filter = new FileNameExtensionFilter("XML file", "xml" );
              fc.addChoosableFileFilter(filter);
              fc.showOpenDialog(MainWindow.returnMainWindow().getFrame());
              //TO DO: manipular o mapa aberto
              return new Map();          
         public void save(){
         public void saveAs(){
              //Abre somente arquivos XML
              JFileChooser fc = new JFileChooser();
              FileNameExtensionFilter filter = new FileNameExtensionFilter("XML file", "xml" );
              fc.addChoosableFileFilter(filter);
              fc.showSaveDialog(MainWindow.returnMainWindow().getFrame());
              //TO DO: Salvar o mapa aberto
         public void exit(){
              System.exit(0);          
         public void copy(){
         public void paste(){
    package main;
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.KeyEvent;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.KeyStroke;
    public class MenuBar implements ActionListener{
         private JMenuBar menuBar;
         private final Color color = new Color(250,255,245);
         private String []menuNames = {"Arquivo","Editar"};
         private JMenu []menus = new JMenu[menuNames.length];
         private String []arquivoMenuItemNames = {"Novo","Abrir", "Salvar","Salvar Como...","Sair" };
         private KeyStroke []arquivoMenuItemHotkeys = {KeyStroke.getKeyStroke(KeyEvent.VK_N,ActionEvent.CTRL_MASK),
                                                                  KeyStroke.getKeyStroke(KeyEvent.VK_A,ActionEvent.CTRL_MASK),
                                                                  KeyStroke.getKeyStroke(KeyEvent.VK_S,ActionEvent.CTRL_MASK),
                                                                  KeyStroke.getKeyStroke(KeyEvent.VK_S,ActionEvent.SHIFT_MASK),
                                                                  KeyStroke.getKeyStroke(KeyEvent.VK_F4,ActionEvent.ALT_MASK)};
         private JMenuItem []arquivoMenuItens = new JMenuItem[arquivoMenuItemNames.length];
         private String []editarMenuItemNames = {"Copiar","Colar"};
         private KeyStroke []editarMenuItemHotKeys = {KeyStroke.getKeyStroke(KeyEvent.VK_C,ActionEvent.CTRL_MASK),
                                                                 KeyStroke.getKeyStroke(KeyEvent.VK_V,ActionEvent.CTRL_MASK)};
         private JMenuItem[]editarMenuItens = new JMenuItem[editarMenuItemNames.length];
         private static MenuBar instance = null;
         public JMenuItem lastAction;
         private MenuBar()
         public static MenuBar createMenuBar()
              if(instance == null)
                   instance = new MenuBar();
                   return instance;                    
              else
                   return instance;
         public JMenuBar create()
              //cria a barra de menu
              menuBar = new JMenuBar();
              //adiciona items a barra de menu
              for(int i=0; i < menuNames.length ; i++)
                   menus[i] = new JMenu(menuNames);
                   menuBar.add(menus[i]);
              //seta a hotkey da barra como F10
              menus[0].setMnemonic(KeyEvent.VK_F10);
              //adiciona items ao menu arquivo
              for(int i=0; i < arquivoMenuItemNames.length ; i++)
                   arquivoMenuItens[i] = new JMenuItem(arquivoMenuItemNames[i]);
                   arquivoMenuItens[i].setAccelerator(arquivoMenuItemHotkeys[i]);
                   menus[0].add(arquivoMenuItens[i]);
                   arquivoMenuItens[i].setBackground(color);
                   arquivoMenuItens[i].addActionListener(this);
              //adiciona items ao menu editar
              for(int i=0; i < editarMenuItemNames.length ; i++)
                   editarMenuItens[i] = new JMenuItem(editarMenuItemNames[i]);
                   editarMenuItens[i].setAccelerator(editarMenuItemHotKeys[i]);
                   menus[1].add(editarMenuItens[i]);
                   editarMenuItens[i].setBackground(color);
                   editarMenuItens[i].addActionListener(this);
              menuBar.setBackground(color);
              return menuBar;                    
         @Override
         public void actionPerformed(ActionEvent e) {
              lastAction = (JMenuItem) e.getSource();
              MenuActions action = new MenuActions();
              if(lastAction.getText().equals("Novo"))
                   action.newMap();
              else if(lastAction.getText().equals("Abrir"))
                   action.openMap();
              else if(lastAction.getText().equals("Salvar"))
                   action.save();               
              else if(lastAction.getText().equals("Salvar Como..."))
                   action.saveAs();               
              else if(lastAction.getText().equals("Sair"))
                   action.exit();               
              else if(lastAction.getText().equals("Copiar"))
                   action.copy();               
              else if(lastAction.getText().equals("Colar"))
                   action.paste();               
    package main;
    import java.awt.geom.Rectangle2D;
    import javax.swing.JComponent;
    public class Cell extends JComponent{
         public float presSub = 0;
         public double errPressInfer = 0.02;
         public double errPressSup = 0.02;
         public float profundidade = 1;
         public Rectangle2D r ;
         public Cell(double x, double y, double pixel)
              r = new Rectangle2D.Double(x,y,pixel,pixel);          
    Edited by: xnunes on May 3, 2008 6:26 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Scroll Bar code in Awt Required Plz Help me

    Hi,
    My requirment is to add Vertical Scrollbar to the table.There are 12 rows in a table like from January to December.
    I am able to see data of rows as jan,feb,mar,apr only .
    i want to see the data of rows of next months by adding vertical scroll bar using Awt code.
    I added vertical scroll bar using awt code. When i click on that Vertical scroll bar event is going to below method.
    public void adjustmentValueChanged(AdjustmentEvent e) {
    I tried with some logic inside above method but it is not working.what is the code i have to write inside the above method inorder to scroll the next months.
    Plz Help me.
    Thanks In Advance.........

    But i want to do this code In Using Awt only......Well, a JTable is a Swing component so I have no idea what you are talking about.
    To control the size of the table you can use:
    table.setPreferredScrollableViewportSize(???);
    JScrollPane scrollPane = new JScrollPane( table );

  • Programmatically Scroll JScrollPane - Best Practice

    Having a bit of trouble finding the best (most foolproof/efficient/correct) way of programmatically scrolling a JScrollPane to make sure a component is visible. I've written a little demo for the solution I have at the moment and was wondering if it can be improved upon.
    The demo creates 100 clickable JLabels in the right section of the JSplitPane and 100 JLabels with the corresponding integer value in the left section. When the user clicks on a JLabel in the right section the JLabel with the corresponding value in the left section is highlighted red in foreground colour and if the label isn't currently visible the scroll pane is scrolled to show it. This appears to be working OK, but I don't know if it's the best it could be. As you can see from the section that's commented out I've tried to use the scrollRectToVisible method of the viewport in the scroll pane but it's not consistently making the correct label visible.
    Thanks in advance for any advice.
    package tester;
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Rectangle;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.util.HashMap;
    import java.util.Map;
    import javax.swing.Box;
    import javax.swing.BoxLayout;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JScrollPane;
    import javax.swing.JSplitPane;
    import javax.swing.SwingUtilities;
    public class AutoscrollingExample extends JFrame {
         private final int TOTAL_LABELS = 100;
         // Keeps track of label for int value in left box
         private Map<Integer, JLabel> labelsInLeftBoxMap = new HashMap<Integer, JLabel>();
         private JScrollPane leftScrollPane;
         public static void main(String[] args) {
              new AutoscrollingExample();
         private AutoscrollingExample() {
              this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
              splitPane.setLeftComponent(getLeftScrollPane());
              splitPane.setRightComponent(getRightBox());
              splitPane.setDividerLocation(splitPane.getLeftComponent().getPreferredSize().width + 25);
              this.setLayout(new BorderLayout());
              this.add(splitPane, BorderLayout.CENTER);
              this.setLocationByPlatform(true);
              this.setSize(400, 400);
              this.setResizable(false);
              this.setTitle("Scroll Testing");
              this.setVisible(true);
         private Box getRightBox() {
              Box rightBox = Box.createVerticalBox();
              int boxEveryXNumbers = 10;
              Box currentBox = new Box(BoxLayout.LINE_AXIS);
              for(int i=1; i<=TOTAL_LABELS; i++) {
                   JLabel thisLabel;
                   if(i < 10) {
                        thisLabel = new JLabel("  "+i+" ");
                   } else {
                        thisLabel = new JLabel(" "+i+" ");
                   thisLabel.addMouseListener(new MouseAdapter() {
                        public void mouseClicked(MouseEvent e) {
                             handleMouseClickOnLabel(e);
                   currentBox.add(thisLabel);
                   currentBox.add(Box.createHorizontalStrut(5));
                   if(i > 0 && i % boxEveryXNumbers == 0) {
                        rightBox.add(currentBox);
                        rightBox.add(Box.createVerticalStrut(5));
                        currentBox = new Box(BoxLayout.LINE_AXIS);
              rightBox.add(Box.createVerticalGlue());
              return rightBox;
         private JScrollPane getLeftScrollPane() {
              Box leftBox = Box.createVerticalBox();
              for(int i=1; i<=TOTAL_LABELS; i++) {
                   JLabel leftLabel = new JLabel(" "+i+" ");
                   labelsInLeftBoxMap.put(i, leftLabel);
                   leftBox.add(leftLabel);
              leftScrollPane = new JScrollPane();
              leftScrollPane.getViewport().add(leftBox);
              return leftScrollPane;
         private void handleMouseClickOnLabel(MouseEvent e) {
              // Get the int value of clicked label by parsing trimmed text
              JLabel sourceLabelInRightBox = (JLabel) e.getSource();
              int clickedLabelNumber = Integer.parseInt(sourceLabelInRightBox.getText().trim());
              System.out.println("clickedLabelNumber: "+clickedLabelNumber);
              // Highlight the selected label and reset highlight on other labels
              for(Integer oneKey : labelsInLeftBoxMap.keySet()) {
                   if(oneKey.equals(clickedLabelNumber)) {
                        labelsInLeftBoxMap.get(oneKey).setForeground(Color.red);
                   } else {
                        labelsInLeftBoxMap.get(oneKey).setForeground(Color.black);
               * Attempt to scroll the left scroll pane to ensure the selected label
               * is visible
              JLabel labelInLeftComponent = labelsInLeftBoxMap.get(clickedLabelNumber);
              Rectangle leftLabelRectangle = new Rectangle(
                        labelInLeftComponent.getLocation().x,
                        labelInLeftComponent.getLocation().y,
                        labelInLeftComponent.getSize().width,
                        labelInLeftComponent.getSize().height);
              System.out.println(labelInLeftComponent.getLocation());
              if(!SwingUtilities.isRectangleContainingRectangle(leftScrollPane.getViewport().getViewRect(),
                        leftLabelRectangle)) {
                   System.out.println("label isn't visible - attempting to scroll");
                   leftScrollPane.getViewport().setViewPosition(leftLabelRectangle.getLocation());
                   // scrollRectToVisible doesn't consistently scroll so label is visible
                   // leftScrollPane.getViewport().scrollRectToVisible(leftLabelRectangle);
              } else {
                   System.out.println("label is already visible - doing nothing");
    }

    scrollRectToVisible works fine for me (and always has).import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.util.HashMap;
    import java.util.Map;
    import javax.swing.*;
    public class AutoScrollingExample {
      private final int TOTAL_LABELS = 100;
      private Map<Integer, JLabel> labelsInLeftBoxMap = new HashMap<Integer, JLabel>();
      public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
          @Override
          public void run() {
            new AutoScrollingExample().makeUI();
      public void makeUI() {
        JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
        splitPane.setLeftComponent(getLeftScrollPane());
        splitPane.setRightComponent(getRightBox());
        splitPane.setDividerLocation(splitPane.getLeftComponent().getPreferredSize().width + 25);
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(400, 400);
        frame.setLocationRelativeTo(null);
        frame.add(splitPane);
        frame.setVisible(true);
      private Box getRightBox() {
        Box rightBox = Box.createVerticalBox();
        int boxEveryXNumbers = 10;
        Box box = new Box(BoxLayout.LINE_AXIS);
        for (int i = 1; i <= TOTAL_LABELS; i++) {
          JLabel thisLabel = new JLabel(String.format("%3d", i));
          thisLabel.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
              String text = ((JLabel) e.getSource()).getText().trim();
              JLabel target = labelsInLeftBoxMap.get(Integer.parseInt(text));
              ((JComponent) target.getParent()).scrollRectToVisible(target.getBounds());
          box.add(thisLabel);
          box.add(Box.createHorizontalStrut(5));
          if (i > 0 && i % boxEveryXNumbers == 0) {
            rightBox.add(box);
            rightBox.add(Box.createVerticalStrut(5));
            box = new Box(BoxLayout.LINE_AXIS);
        rightBox.add(Box.createVerticalGlue());
        return rightBox;
      private JScrollPane getLeftScrollPane() {
        Box leftBox = Box.createVerticalBox();
        for (int i = 1; i <= TOTAL_LABELS; i++) {
          JLabel leftLabel = new JLabel(" " + i + " ");
          labelsInLeftBoxMap.put(i, leftLabel);
          leftBox.add(leftLabel);
        JScrollPane leftScrollPane = new JScrollPane();
        leftScrollPane.getViewport().add(leftBox);
        return leftScrollPane;
    }db

  • Stop JScrollPane from scrolling

    Hello, I am trying to improve a special editor i have written. Now I tried to add line numbering to it and got stuck. Here's what I did:
    I have a JScrollPane that contains a JPanel. This JPanel has a BorderLayout and contains a JTextPane (where the editable text is) in the CENTER and a JTextArea (containing the line numbers) in the WEST.
    Everytime the text is edited, I count the lines and update the JTextArea so that the right amount of line numbers is shown. But here's the problem: Everytime I update the line numbers, the JScrollPane scrolls down to the very bottom, so in some cases the caret gets hidden (which is very annoying).
    Can someone tell me how I can tell the JScrollPane (or whoever else is to blame for this) not to scroll when I update the line number JTextArea? Is there an easy way to achieve this?
    Thanks in advance

    Another way to do this:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.text.rtf.*;
    class Test extends JFrame
    public Test()
    super("Test");
    JEditorPane edit = new JEditorPane();
    edit.setEditorKit(new MyRTFEditorKit());
    edit.setEditable(true);
    JScrollPane scroll=new JScrollPane(edit);
    getContentPane().add(scroll);
    setSize(300,300);
    setVisible(true);
    public static void main(String a[])
    new Test();
    class MyRTFEditorKit extends RTFEditorKit
    public ViewFactory getViewFactory()
    return new MyRTFViewFactory();
    class MyRTFViewFactory implements ViewFactory
    public View create(Element elem)
    String kind = elem.getName();
    if (kind != null)
    if (kind.equals(AbstractDocument.ContentElementName)) {
    return new LabelView(elem);
    } else if (kind.equals(AbstractDocument.ParagraphElementName)) {
    // return new ParagraphView(elem);
    return new MyParagraphView(elem);
    } else if (kind.equals(AbstractDocument.SectionElementName)) {
    // return new BoxView(elem, View.Y_AXIS);
    return new MySectionView(elem, View.Y_AXIS);
    } else if (kind.equals(StyleConstants.ComponentElementName)) {
    return new ComponentView(elem);
    } else if (kind.equals(StyleConstants.IconElementName)) {
    return new IconView(elem);
    // default to text display
    return new LabelView(elem);
    class MySectionView extends BoxView {
    public MySectionView(Element e, int axis)
    super(e,axis);
    public void paintChild(Graphics g,Rectangle r,int n) {
    if (n>0) {
    MyParagraphView child=(MyParagraphView)this.getView(n-1);
    int shift=child.shift+child.childCount;
    MyParagraphView current=(MyParagraphView)this.getView(n);
    current.shift=shift;
    super.paintChild(g,r,n);
    class MyParagraphView extends javax.swing.text.ParagraphView
    public int childCount;
    public int shift=0;
    public MyParagraphView(Element e)
    super(e);
    short top=0;
    short left=20;
    short bottom=0;
    short right=0;
    this.setInsets(top,left,bottom,right);
    public void paint(Graphics g, Shape a)
    childCount=this.getViewCount();
    super.paint (g,a);
    int rowCountInThisParagraph=this.getViewCount();
    System.err.println(rowCountInThisParagraph);
    public void paintChild(Graphics g,Rectangle r,int n) {
    super.paintChild(g,r,n);
    g.drawString(Integer.toString(shift+n+1),r.x-20,r.y+r.height-3);

Maybe you are looking for

  • PDF from postscript (ps2pdf) displays "Insufficient data for an image" error in Reader

    Hello, I'm not fully confident this is the best place for this, but I'll start here. Note that this is NOT the same as the issue that was recently fixed in Reader 11 (found at http://helpx.adobe.com/acrobat/kb/insufficient-data-image.html) I am using

  • Keeping file names when rendering out DPX to QT

    I am trying to convert a dpx sequence to a quicktime to use for offline editing. When I export the files it does not keep the original file name. It replaces the file name with 1_g1, 2_g1 and so on. I cannot find a way to tell color to keep the orgin

  • How to upgrade iPad2 to iOS 5

    My iPad 2 is 4.3.5 version

  • Convert Action script Flex project to MX Component

    Hi gurus, I am looking into one of the examples on "Inspectable" in Flex project. As per my knowledge to convert we need to define a .MI file. Can anyone help me in converting this project into a MX component. Thanks and Regards Srikanth Anthargam

  • Different results

    Hi all, When queried with dbms_mview.explain_rewrite,it shows materialized view used and rewritten but neither explain plan nor autotrace shows use of mview? Materilized view is a complex topic.