Rookie to the Java World!!!

Hello everyone, I need to develop an application using Java. I've never had experience w/Java before. I've done some searching on Sun here as well as other sites. But so far I'm very confused. Can someone tell me where is a good place to start as far as what I need to learn and develop a GUI application in Java? I've downloaded J2SE and IDE from Sun. But I have no clue on how to use or what they're good for.
Any help would be greatly appreciated!
Thank you in advance =)

Crawl through some tutorials, that's always a good way to start:
General Java:
http://java.sun.com/docs/books/tutorial/
Swing (for GUIs):
http://java.sun.com/docs/books/tutorial/uiswing/

Similar Messages

  • Standalone executables and dependencies in the Java World

    I'm a very seasoned C/C++ developer who's just learning Java. I have this gnawing question that's bugging me. It's rather elementary but it requires someone with experience to answer it.
    If I'm delivering a standalone executable (C/C++) to a Windows or Linux customer, it is possible to deliver simply a "*.exe" file (windows) or a Linux Executable file (Linux) which can be installed and run immediately with no dependencies not included in a typical installation. (although, on linux, if there is a gui involved, a typical default Linux install may be missing some dependencies for the gui )
    But in the Java world, since the JRE is not necessarily included in a Standard Windows or Linux default installation, my customer would always have to install the JRE on their machine before they can run any code that I produce in Java ...correct? And there is no way to execute a jarfile as a standalone; it always must be executed by the JRE ("java -jar <jarfilename.jar> ) ...right? And if I were to code a new GUI application in Java on the Linux platform, it would have to be run via "java -jar <gui_jarfilename.jar> ...correct?

    R2me2 wrote:
    "Your questions cause me to suggest that you look into Java Web Start;"
    No, this is exactly what I'm not asking. I mean really standalone ....as in the executable runs by itself without user having to install anything else* (via CD, web or anywhere). So I suppose the answer to my question is that NO, there's no such thing in the Java World and that whenever a java program is installed, it always has the JRE as a dependency and that the installation of a java executable is not complete until the JRE is installed.Not to sound like a noob but what were you expecting. Java runs on the JRE and that is what makes it portable as the JRE can be installed almost anywhere o.O
    This is not the inconvenience that you are making it out to be. No user is gonna beef with you if they came to you asking for a java application to be installed and I most certainly have played the client role, having to download the latest JRE to run my bank applets. No so long as you provide the user with all the info they need like a link to JRE download etc you will be fine.. :)

  • What's going on in the java world?

    Hi guys,
    I haven't used Java since 2002. What's going on here. Would u tell me? Will be a great help.
    Thanx.
    shoovo

    Hi guys,
    I haven't used Java since 2002. What's going on here.
    Would u tell me? Will be a great help. A lot actually. Java has come of age. It's fast, stable and the Swing emulations really passable.
    The abandoned Java3D has made a come back as open source (kind of).
    A new major Java version called Tiger has been released with lots of language changes that elevates the Java abstraction level a notch. This includes generics, autoboxing and highlevel concurrency.
    Eclipse is better than ever.

  • Solve the problem that stumped the Java world

    A little background: For a couple of weeks I have been posting queries for help
    with several problems in my table-based application. Usually I have gotten calls
    for more code. I have stripped the app down to the ONE problem that remains. The
    code included below is 772 lines long (down from over 2500) for five files.
    I post this query for anyone who is still interested in the problem.
    I am hoping that the solution is short work for an experienced Java coder, though I can't figure it out.
    Table1               145
    Table2               152
    T1RowDragger     211
    T2RowDragger     243
    "main" class     21
         total          772
    The goal is to copy a row from one JTable (table1) to another (secondTable). To do
    that I need to connect "t1DataModel," the DefaultTableModel of table1 to
    "T2RowDragger," the Drag and Drop class of secondTable.
    This is the method which should handle the copy It is located in "T2RowDragger":      public void interTableCopy( int rowNumber, int position ) {
              DefaultTableModel t1DataModel = (DefaultTableModel)table1.getModel();      -------- the problem
              Object t1SourceRowData = t1DataModel.getDataVector().elementAt(rowNumber);
              DefaultTableModel t2DataModel = (DefaultTableModel)secondTable.getModel();
              Object t2SourceRowData = t2DataModel.getDataVector().elementAt(rowNumber);
              t2DataModel.getDataVector().setElementAt(t1SourceRowData, position);
              t2DataModel.fireTableRowsUpdated(position, position);
              secondTable.repaint();
         }However, it returns a NullPointerException at the first line of the method.
    My diagnostic printout to the console reads:
         "t1DataModel = null
         t2DataModel = SecondTable$SecondTableModel@202ac00
         t2SourceRowData = [, , , , , , , ]
         T2RowDragger: Drag Dropped at : Row 12"
    When this version is run:
         public void interTableCopy( int rowNumber, int position ) {
         //     DefaultTableModel t1DataModel = (DefaultTableModel)table1.getModel();
                   System.out.println( "t1DataModel = " + t1DataModel );
         //     Object t1SourceRowData = t1DataModel.getDataVector().elementAt(rowNumber);
         //          System.out.println( "t1SourceRowData = " + t1SourceRowData );
              DefaultTableModel t2DataModel = (DefaultTableModel)secondTable.getModel();
                   System.out.println( "t2DataModel = " + t2DataModel );
              Object t2SourceRowData = t2DataModel.getDataVector().elementAt(rowNumber);
                   System.out.println( "t2SourceRowData = " + t2SourceRowData );
         //     t2DataModel.getDataVector().setElementAt(t1SourceRowData, position);
              t2DataModel.fireTableRowsUpdated(position, position);
              secondTable.repaint();
         }Please note that (1) the drag and drop code is written in the Macintosh API. (2) the code is not exactly pretty.
    As always many thanks for any assistance.
    ---------------------------- code Starts here -------------------------------
         Table1.java ------------------------------------------------------------------------------------
    import java.awt.datatransfer.Transferable;
    import java.awt.datatransfer.DataFlavor;
    import com.apple.mrj.MRJOSType;
    import com.apple.mrj.dnd.*;
    import com.apple.mrj.datatransfer.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.text.*;
    import java.awt.Toolkit;
    class Table1 extends JTable {
         JFrame frame;
         JTable table1;
         JTable secondTable;
         SecondTable table2;
         TableColumnModel t1ColumnModel;
         TableColumnModel t2ColumnModel;
         JPanel topPanel;
         JPanel buttonPanel;
         public static Color rowDark = new Color( 135, 164, 173 );
         public static Color blueGray = new Color( 164, 176, 172 );
         public static Color greenishLight = new Color( 138, 197, 153 );
         public static Color selected = new Color( 255, 196, 140 ); // yellowishLight
         public static Font test_10ptCraw = new Font("CrawModern", Font.PLAIN, 10);
         private int rows = 40, cols = 8;
         private Object[] rowData = new Object[cols];
         Vector t1DataVector;
         Vector t2DataVector;
         DefaultTableModel t1DataModel;
         final SecondTable twotable = new SecondTable(t1DataModel);
    // -------------------------------------------------------------------- variables for Drag&Drop
         public static Object sourceTable = "";
         public static Object dropTable = "";
         public static int startRow;
         public static int dropRow;
    class T1Model extends DefaultTableModel {
         public boolean isCellEditable(int row, int col) {
         return true;
    T1Model t1Model = new T1Model();
         public Table1() {
         for( int c = 0; c < cols; c++ ) {
              t1Model.addColumn( "Column " + Integer.toString(c) );
         for( int r = 0; r < rows; r++ ) {
              for( int c = 0; c < cols; c++) {
              //     rowData[c] = "ONE( " + r + "," + c + ")";
                   rowData[c] = "";
              t1Model.addRow( rowData );
    // -------------------------------------------------------------------------- set up the components
         topPanel = new JPanel();
              topPanel.setPreferredSize( new Dimension( 618, 40 ) );
              //topPanel.setBackground( Color.white );
         buttonPanel = new JPanel();
              buttonPanel.setPreferredSize( new Dimension( 618, 40 ) );
              //buttonPanel.setBackground( Color.white );
    t1DataVector = t1Model.getDataVector();
         table1 = new JTable();
              table1.setModel( t1Model );
              table1.setAutoResizeMode( JTable.AUTO_RESIZE_OFF );
              table1.getTableHeader().setReorderingAllowed( false );
              table1.getTableHeader().setResizingAllowed(false);
              table1.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
              table1.setCellSelectionEnabled( false );
              table1.setRowHeight( 20 );
              table1.setGridColor( Color.black );
              table1.addMouseListener( new T1RowDragger( table1, table2, t1DataVector ) ); // ----- addMouseListener
    t1DataModel = (DefaultTableModel)table1.getModel();
    // --------------------------------------------------------------------------- set the TableCellRenderer
    //     TableCellRenderer t1XRenderer = new T1RowAlternatorX();
    //     table1.setDefaultRenderer(Object.class, t1XRenderer);
         JTableHeader t1Header = table1.getTableHeader(); // ------------------------------- TableHeader
         Dimension dim = t1Header.getPreferredSize();
         dim.height = 20;
         t1Header.setPreferredSize(dim);
         t1Header.setFont( test_10ptCraw );
    // -------------------------------------------------------------------- assemble the frame
         frame = new JFrame( "Table1" );
         JScrollPane scrollPane = new JScrollPane( table1 );
         table1.setPreferredScrollableViewportSize(new Dimension(600, 350));
         JPanel mainPanel = new JPanel();
         mainPanel.setLayout(new BorderLayout());
         mainPanel.add(topPanel, BorderLayout.NORTH);
         mainPanel.add(scrollPane, BorderLayout.CENTER);
         mainPanel.add(buttonPanel, BorderLayout.SOUTH);
         frame.getContentPane().add( mainPanel );
         frame.setSize(618, 430);
         frame.setVisible(true);
         } // ------------------------------------------- close out the constructor "public Table1()"
    } // ---------------------------------------------------  close out "class Table1 extends JTable"
    SecondTable.java ------------------------------------------------------------------------------------
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.util.*;
    class SecondTable extends JTable {
         private int rows = 100, cols = 8;
         private Object[] rowData = new Object[cols];
         JFrame frame;
         JTable table1;
         JTable secondTable;
         TableColumnModel t1ColumnModel;
         TableColumnModel t2ColumnModel;
         JPanel topPanel;
         JPanel buttonPanel;
         public static Color rowDark = new Color( 135, 164, 173 );
         public static Color blueGray = new Color( 164, 176, 172 );
         public static Color greenishLight = new Color( 138, 197, 153 );
         public static Color selected = new Color( 255, 196, 140 ); // yellowishLight
         public static Font test_10ptCraw = new Font("CrawModern", Font.PLAIN, 10);
    // -------------------------------------------------------------------- variables for Drag&Drop
         Vector t1DataVector;
         Vector t2DataVector;
         public static Object sourceTable = "";
         public static Object dropTable = "";
         public static int startRow; // change to: sourceRow;
         public static int dropRow;
         class SecondTableModel extends DefaultTableModel {
               public boolean isCellEditable(int row, int col) {
                       return col > 0 && col < 5;
         SecondTableModel t2Model = new SecondTableModel();
    // to pass Table1's data model in the SecondTable ctor.
         DefaultTableModel t1DataModel;
         public SecondTable( DefaultTableModel t1DataModel ) { // ------------------------------------------- the constructor "public SecondTable()"
         this.t1DataModel = t1DataModel;
    //     t2Model = (DefaultTableModel) getModel();
         for( int c = 0; c < cols; c++ ) {
              t2Model.addColumn( "Column " + Integer.toString(c) );
         for( int r = 0; r < rows; r++ ) {
              for( int c = 0; c < cols; c++) {
              //     rowData[c] = "t2 ( " + r + "," + c + ")";
                   rowData[c] = "";
              t2Model.addRow( rowData );
    // ------------------------------------------------------------------------ set up the components
         topPanel = new JPanel();
              topPanel.setPreferredSize( new Dimension( 618, 40 ) );
              topPanel.setBackground( Color.white );
         buttonPanel = new JPanel();
              buttonPanel.setPreferredSize( new Dimension( 618, 40 ) );
              buttonPanel.setBackground( Color.white );
    t2DataVector = t2Model.getDataVector();
         secondTable = new JTable(); // -------------------------------------------------------------- JTable
              secondTable.setModel( t2Model );
         //     secondTable.setColumnModel( t2ColumnModel );
              secondTable.setAutoResizeMode( JTable.AUTO_RESIZE_OFF );
              secondTable.getTableHeader().setReorderingAllowed( false );
              secondTable.getTableHeader().setResizingAllowed(false);
              secondTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
              secondTable.setCellSelectionEnabled( false );
              secondTable.setRowHeight( 20 );
              secondTable.setGridColor( Color.black );
              secondTable.addMouseListener( new T2RowDragger( table1, secondTable, t1DataVector,
                                                                          t2DataVector, t1DataModel ) ); // - Drag&Drop addMouseListener
    // -------------------------------------------------------------------- set the TableCellRenderer
    //     TableCellRenderer t2XRenderer = new T2RowAlternatorX();
    //     secondTable.setDefaultRenderer(Object.class, t2XRenderer);
         JTableHeader t2Header = secondTable.getTableHeader(); // ------------------------------- TableHeader
         Dimension dim = t2Header.getPreferredSize();
         dim.height = 20;
         t2Header.setPreferredSize(dim);
         t2Header.setFont( test_10ptCraw );
    // -------------------------------------------------------------------- assemble the frame
         JScrollPane scrollPane = new JScrollPane( secondTable );
         secondTable.setPreferredScrollableViewportSize(new Dimension(600, 350));
         JPanel mainPanel = new JPanel();
              mainPanel.setLayout(new BorderLayout());
              mainPanel.add(topPanel, BorderLayout.NORTH);
              mainPanel.add(scrollPane, BorderLayout.CENTER);
              mainPanel.add(buttonPanel, BorderLayout.SOUTH);
         frame = new JFrame( "SecondTable" );
              frame.getContentPane().add( mainPanel );
              frame.setSize(618, 430);
              frame.setLocation( 200, 200 );
              frame.setVisible(true);
         } // ------------------------------------------- close out the constructor "public SecondTable()"
    } // ---------------------------------------------------  close out "class SecondTable extends JTable"
         T1RowDragger.java ------------------------------------------------------------------------------
    import java.awt.datatransfer.Transferable;
    import java.awt.datatransfer.DataFlavor;
    import com.apple.mrj.MRJOSType;
    import com.apple.mrj.dnd.*;
    import com.apple.mrj.datatransfer.*;
    //import com.apple.mrj.dnd.Drag;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    class T1RowDragger extends DragAdapter implements DragInitiatorListener {
    static JTable table1;
    static JTable secondTable;
    static Vector t1DataVector;
    //public T1RowDragger( JTable table1, Vector t1DataVector ) {
    public T1RowDragger( JTable table1, JTable secondTable, Vector t1DataVector ) {
    this.table1 = table1;
    this.secondTable = secondTable;
    this.t1DataVector = t1DataVector;
    Object sourceTable = "";
    Object dropTable = "";
         int startRow;
         int dropRow;
         int dragStartRow;
         boolean dragging = false;
         public boolean dragMoved( DragEvent e ) {
         dragEntered( e );
              return true;
         protected void displayDragUnderEffects(Point p) {
              int row = table1.rowAtPoint(p);
              int column = table1.columnAtPoint(p);
              table1.setRowSelectionInterval(row, row);
              table1.setColumnSelectionInterval(column, column);
              //table1.repaint();
         public boolean dragEntered( DragEvent e ) { // ................................. dragEntered
         int dragEnteredRow = table1.rowAtPoint( e.getPoint() );
    //     table1.rowAtPoint( e.getPoint() ).setBackground( selected );
    //     dragEnteredRow.setForeground( selected );
         displayDragUnderEffects( e.getPoint() );
              if ( dragEnteredRow == -1 ) {;
                   System.out.println( "[if] dragEnteredRow = " + dragEnteredRow );
              } else {               
         dragging = true;
                   System.out.println( "Drag Entered at : Row " + dragEnteredRow );
                   System.out.println( "" );
                   return true;
         public boolean dragDropped( DragEvent e ) { // ................................. dragDropped
         dragging = false;
    e.getDrag().setDropAccepted( true );
         if( e.getSource() == table1 ) { // -------------- set "dropTable" variable (in "dragDropped")
              Table1.dropTable = "table1";
         else if( e.getSource() == secondTable ) {
              dropTable = "secondTable";
         int theRow = table1.getSelectedRow();
         int nCol = table1.getSelectedColumn();
         int dragDropRow = table1.rowAtPoint( e.getPoint() );
         dropRow = table1.rowAtPoint( e.getPoint() );
         if ( dragDropRow == -1|| nCol == -1 ) {;
              System.out.println( "[if] dragDropRow = " + dragDropRow );
                                                           // do nothing     
         } else {               
              moveRow( startRow, startRow, dropRow ); // ============================== Call the "moveRow" method
              table1.repaint();
              System.out.println( "startRow : " + startRow );
              System.out.println( "dragStartRow : " + dragStartRow );
              System.out.println( "dropRow : " + dropRow );
         System.out.println( "T1RowDragger: e = " + e );
         System.out.println( "sourceTable = " + Table1.sourceTable );
         System.out.println( "dropTable = " + Table1.dropTable );
              System.out.println( "Drag Dropped at : Row " + dragDropRow );
              System.out.println( "" );
              return false;
         private boolean canAcceptDrag( DragEvent e ) {
              return true; // e.getDrag().allItemsContainFlavors(kAcceptableFlavors);
         // OUTGOING DRAGS:
         public void dragGesture( DragInitiatorEvent e ) { // ............................ dragGesture
              Table1.sourceTable = "table1"; // ---------------------- set "Table1.sourceTable" variable
         startRow = table1.getSelectedRow();
         dragStartRow = table1.getSelectedRow();
              Table1.startRow = table1.getSelectedRow(); // ---------- set "Table1.sourceTable" variable
         if( e.getSource() == table1 ) { // ------------ set "sourceTable" variable (in "dragGesture")
              sourceTable = "table1";
    /*     else if( e.getSource() == secondTable ) {
              sourceTable = "secondTable";
         int nCol = table1.getSelectedColumn();
         OutgoingDrag drag = e.getDrag();
              if ( dragStartRow == -1 || nCol == -1 ) {return; // do nothing
              } else {               
                   Transfer item = new Transfer();
                   //item.addFlavor(OSTypeFlavor.kTypeTEXT, ((String)fContent).getBytes());
                   drag.addItem(item);
                   e.setDragRect( 0, e.getY()+50, 600,20 );// ............... sets drag rectangle graphic
                   System.out.println( "Drag Initiated at: Row " + dragStartRow );
                   System.out.println( "X: " + e.getX() );
                   System.out.println( "Y: " + e.getY() );
         System.out.println( "sourceTable = " + Table1.sourceTable );
         private Object fContent = kTextData;
         private static final String kTextData = "What a drag!";
         public void dragCompleted( DragInitiatorEvent e ) { // .......................... dragCompleted
         public void dragFailed( DragInitiatorEvent e ) { // ............................. dragFailed
         public void moveRow(int startIndex,int endIndex,int toIndex)
            throws IndexOutOfBoundsException {
            int rows = t1DataVector.size();
            if (startIndex >= rows || endIndex >= rows || toIndex >= rows) {
                throw new IndexOutOfBoundsException();
            // Swap if start > end
            if (startIndex > endIndex) {
                startIndex ^= (endIndex ^= (startIndex ^= endIndex));
            // save block to move
            Object[] block = new Object[(endIndex - startIndex) + 1];
            for (int j=0; j < block.length; j++) {
                block[j] = t1DataVector.elementAt(startIndex + j);
              // Copy the stuff to replace the block
              if (startIndex < toIndex) {
                 for (int j=startIndex; j < toIndex; j++) {
                    t1DataVector.setElementAt(t1DataVector.elementAt(block.length + j), j);
              } else if (startIndex > toIndex) {
                 // changed code
                 for (int j=startIndex ; j > toIndex; j--) {
                    t1DataVector.setElementAt(t1DataVector.elementAt(j-1), j);
            // Copy block to new position
            for (int j=0; j < block.length; j++) {
                t1DataVector.setElementAt(block[j], toIndex + j);
         T2RowDragger.java ------------------------------------------------------------------------------
    import java.awt.datatransfer.Transferable;
    import java.awt.datatransfer.DataFlavor;
    import com.apple.mrj.MRJOSType;
    import com.apple.mrj.dnd.*;
    import com.apple.mrj.datatransfer.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    class T2RowDragger extends DragAdapter implements DragInitiatorListener {
         JTable table1;
         JTable secondTable;
         Vector t1DataVector;
         Vector t2DataVector;
    DefaultTableModel t1DataModel;
         public T2RowDragger( JTable table1, JTable secondTable, Vector t1DataVector,
                                       Vector t2DataVector, DefaultTableModel t1DataModel ) {
         this.table1 = table1;
         this.secondTable = secondTable;
         this.t1DataVector = t1DataVector;
         this.t2DataVector = t2DataVector;
         this.t1DataModel = t1DataModel;
         int startRow;
         int dropRow;
    Object sourceTable = "";
    Object dropTable = "";
         // OUTGOING DRAGS:
         public void dragGesture( DragInitiatorEvent e ) { // ............................ dragGesture
              Table1.sourceTable = "secondTable";
         startRow = secondTable.getSelectedRow();
         int dragStartRow = secondTable.getSelectedRow();
         int nCol = secondTable.getSelectedColumn();
         OutgoingDrag drag = e.getDrag();
              if ( dragStartRow == -1 || nCol == -1 ) {return; // do nothing
              } else {               
                   Transfer item = new Transfer();
                   item.addFlavor(OSTypeFlavor.kTypeTEXT, ((String)fContent).getBytes());
                   drag.addItem(item);
                   e.setDragRect( 0, e.getY()+50, 618,20 );
                   System.out.println( "T2RowDragger: Drag Initiated at: Row " + dragStartRow );
                   System.out.println( "X: " + e.getX() );
                   System.out.println( "Y: " + e.getY() );
         System.out.println( "sourceTable = " + Table1.sourceTable );
         public boolean dragMoved( DragEvent e ) {
         dragEntered( e );
              return true;
         protected void displayDragUnderEffects(Point p) {
              int row = secondTable.rowAtPoint(p);
              int column = secondTable.columnAtPoint(p);
              secondTable.setRowSelectionInterval(row, row);
              secondTable.setColumnSelectionInterval(column, column);
              //secondTable.repaint();
         public boolean dragEntered( DragEvent e ) {
         int dragEnteredRow = secondTable.rowAtPoint( e.getPoint() );
         displayDragUnderEffects( e.getPoint() );
              if ( dragEnteredRow == -1 ) {;
                   System.out.println( "T2RowDragger: Entered out of bounds !!" );
              } else {               
                   System.out.println( "T2RowDragger: Drag Entered at : Row " + dragEnteredRow );
                   System.out.println( "T2RowDragger: startRow : Row " + startRow );
                   System.out.println( "T2RowDragger: dropRow : Row " + dropRow );
                   System.out.println( "" );
                   return true;
         public boolean dragDropped( DragEvent e ) { // ................................... dragDropped
              e.getDrag().setDropAccepted( true );
              Table1.dropTable = "secondTable"; // -------------- set "dropTable" variable (in "dragDropped")
              Table1.dropRow = secondTable.rowAtPoint( e.getPoint() ); // -------------- set "dropTable" variable (in "dragDropped")
              int theRow = secondTable.getSelectedRow();  // ------------ superfluous
              int nCol = secondTable.getSelectedColumn();
              Table1.dropRow = secondTable.rowAtPoint( e.getPoint() );
              dropRow = secondTable.rowAtPoint( e.getPoint() );
         if ( Table1.dropRow == -1|| nCol == -1 ) {;
              System.out.println( "T2RowDragger: Dropped out of bounds !!" );
                                                           // do nothing     
         } else {               
    // ---------------------------------------------------------------------- new d&d code, 07/27/01
              if( Table1.sourceTable == "table1" ) {
                   interTableCopy( Table1.startRow, Table1.dropRow );
                   secondTable.repaint();
              else if( Table1.sourceTable == "secondTable" ) {
                   moveRow( startRow, startRow, dropRow );
                   secondTable.repaint();
              System.out.println( "T2RowDragger: Drag Dropped at : Row " + Table1.dropRow );
              System.out.println( "" );
         System.out.println( "sourceTable = " + Table1.sourceTable );
         System.out.println( "dropTable = " + Table1.dropTable );
              System.out.println( "T2RowDragger: startRow : " + startRow );
              System.out.println( "T2RowDragger: dropRow : " + dropRow );
              System.out.println( "Drag Dropped at : Row " + Table1.dropRow );
              System.out.println( "" );
                   return false;
         public void moveRow(int startIndex,int endIndex,int toIndex) throws IndexOutOfBoundsException {
            int rows = t2DataVector.size();
            if (startIndex >= rows || endIndex >= rows || toIndex >= rows) {
                throw new IndexOutOfBoundsException();
            // Swap if start > end
            if (startIndex > endIndex) {
                startIndex ^= (endIndex ^= (startIndex ^= endIndex));
            // save block to move
            Object[] block = new Object[(endIndex - startIndex) + 1];
            for (int j=0; j < block.length; j++) {
                block[j] = t2DataVector.elementAt(startIndex + j);
              // Copy the stuff to replace the block
              if (startIndex < toIndex) {
                 for (int j=startIndex; j < toIndex; j++) {
                    t2DataVector.setElementAt(t2DataVector.elementAt(block.length + j), j);
              } else if (startIndex > toIndex) {
                 // changed code
                 for (int j=startIndex ; j > toIndex; j--) {
                    t2DataVector.setElementAt(t2DataVector.elementAt(j-1), j);
             // Copy block to new position
            for (int j=0; j < block.length; j++) {
                t2DataVector.setElementAt(block[j], toIndex + j);
         public void dragCompleted( DragInitiatorEvent e ) { // .......................... dragCompleted
         public void dragFailed( DragInitiatorEvent e ) { // ............................. dragFailed
         private boolean canAcceptDrag( DragEvent e ) {
              return true; // e.getDrag().allItemsContainFlavors(kAcceptableFlavors);
         private Object fContent = kTextData;
         private static final String kTextData = "T2RowDragger: What a drag!";
         public void interTableCopy( int rowNumber, int position ) {
    //          DefaultTableModel t1DataModel = (DefaultTableModel)table1.getModel();
                   System.out.println( "t1DataModel = " + t1DataModel );
    //          Object t1SourceRowData = t1DataModel.getDataVector().elementAt(rowNumber);
    //               System.out.println( "t1SourceRowData = " + t1SourceRowData );
              DefaultTableModel t2DataModel = (DefaultTableModel)secondTable.getModel();
                   System.out.println( "t2DataModel = " + t2DataModel );
              Object t2SourceRowData = t2DataModel.getDataVector().elementAt(rowNumber);
                   System.out.println( "t2SourceRowData = " + t2SourceRowData );
    //          t2DataModel.getDataVector().setElementAt(t1SourceRowData, position);
              t2DataModel.fireTableRowsUpdated(position, position);
              secondTable.repaint();
         public void selectiveCellCopy() {
              int sR = 1;               
              firstEmptyRow = 11;
              for ( int sC = 1; sC < 4; sC++ ) {                    
                   Object value = table1.defaultTableModelX.getValueAt( sR, sC );
                   DefaultTableModel t2DataModel = (DefaultTableModel)twotable.secondTable.getModel();
                   t2DataModel.setValueAt( value, firstEmptyRow, (sC + 4) );
         //          t2Model.setValueAt( value, firstEmptyRow, (sR + 4) );           
         TableSetGo5.java ------------------------------------------------------------------------------
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class TableSetGo5 {
         public static void main(String args[]) {
              Table1 tableOne = new Table1();
         //     SecondTable tableTwo = new SecondTable();
         } // ------- closes out "public static void main(String args[])"
    } // ----------- closes out "public class TableSetGo5"---------------------------- code Ends here -------------------------------

    Hi,
    Instantiated a variable is like...
    JTable table1 = new JTable();
    if you do
    JTable table1
    System.out.println(table1);
    JTable table1 = new JTable();
    it will print "null", and if you do,
    table1.someTableMethod() you will get an error!!!!
    Do not take that personnal(;0)))) but I know that you do not have a lot of experiece just by looking at the way you are selecting the name for your variables... like Table1, table1 and secondTable...But believe me, by working here on the forum you will be a pro soon.
    Take care,
    JRG

  • Java ... and the real world

    Good Day,
    I'm new at JAVA language, I'm basicly a C++ programmer, but I wanted to get inside the java world and know what is it all about, I have the motivation to make it my 1st lang.
    But, there is a question, is it used widely like the other old and new languages, what makes it a better choice to develope with, what is the advantages I mean ??!!
    is it ready for a real huge application from the real world??
    give me an example
    thanks in advance

    Don't hold your breath ...by that I mean it will be
    better in some ways and the same in most ways.
    My point is that the future of computing, its
    application and its growth lies in network and
    inter-network applications, not in desktop and PC
    stand-alone applications.I don't know if i agree (that desktop apps aren't going to be 'the area' in the future)... just about everybody uses computers nowadays, with the vast majority being home desktop users. The desktop app market is set up in such a way that it cannot reach saturation, as 'everyone' (i.e. the majority of users) always want the upgrades... Norton Antivirus 2004 anyone?
    Basically, I agree with you that Java is not a player in this market, and systems integration is (and will continue to be) a huge growth area. Java should play a central role in this, due in part to its platform independence. Only problem is, in the future if the only programming jobs are bolting together components and existing systems, there will be even less coder jobs than today. So you could say, whilst the future of computing is network and inter-network apps, therein lies our doom...

  • Test Driven Development (TDD) in the ABAP world

    Hi All,
    It's been a long time since I've had any spare time to be active on the SCN forums so firstly hello to everyone.
    I've worked on a number of different SAP technologies over the years, starting with ABAP and moving into BSP, Portal API, Web Dynpro, Visual Composer, etc...  I'm currently working on a 7.01 Portal sat on top of an Oracle database and an old R/3 4.5b system.
    I'm also currently working on methodologies (trying to give something back to my colleagues here at AO) and have hit a bit of a blank around Test Driven Development when working in the ABAP stack.  I use JUnit to help me design, build and test Java based web services, ultimately used in WD, VC and via standalone Java applications.  I'm keen on increasing the adoption of TDD and other XP based practices but it needs to be viable in the ABAP world as well as the Java world.
    Here's my question - does anyone have any suggestions/experiences/guides or even just thoughts around using TDD with ABAP?
    I try to make all code I create service based so I rely on heavy use of componentisation, regardless of the language I am working with.  Obviously this is great with Java and ABAP Objects is also quite good, but sometimes we have to work with good old fashioned ABAP in the shape of programs, function groups and function modules.  I tend to treat a function group as a class and the function modules as the methods when designing and componentising.
    Applying the Java TDD approach, my rough idea is to use class/function groups to package my logic and then extend the class or group with an extra method/module that acts as the unit test routine.  I wonder if there is a better way though?
    It would be good to have a decent discussion in this area and capture everyone's thoughts as I'm sure I'm not the only person thinking along these lines.
    Thanks,
    Gareth.

    Hi Sandra,
    Thanks for that.  I wasn't sure if there'd be a proper SAP solution or not.
    Gareth.

  • Using the JAVA ImportXmlTemplate function, should I always use XSL directory?

    Using the JAVA ImportXmlTemplate function requires XSL directory, I do not need XSL for my updates, how can I workaround this requirement?

    Ok, thanks for your quick answer. I saw you last blog posting regarding simple bar codes, I hope your next one turns up soon (read: today ;-) ).
    I did take a swing at writing my own class according to the user guide, using JDeveloper. One of my problems is that I am not that familiar with the whole java world, my experience lies almost entirely within .NET development. So when I read stuff like "make sure the class is available in the classpath for the JVM" and things like that, it is not a detailed enough description for me in order to make anything out of it. Do you think you can clarify that for me?
    I also wonder if you have any tips and tricks on how to trace/log information from the class when it executes? Because I think that I can actually get it to be called, it's just that something goes wrong and the generated PDF becomes badly formatted and has no content. I can see that some calls are made to a Logger class inside the example class. I guess that I need to set up some runtime configuration for that information to turn up in a file, but again me lacking experience from the java world prevents me from accomplishing that :-)
    Regarding tracing and logging from the java classes for the BI Publisher, can I get them to trace or log debug information in some clever way?
    The app I am developing is a .NET app that calls these classes using a product called juggerNET. I am developing a print direct application for JDEdwards EnterpriseOne since BI Publisher is not entirely integrated into it yet.
    I would greatly appreciate a quick reply this time as well if you can find the time!
    Best regards, Jörgen

  • Test.jsp not able to display the output from the java code.

    when i try to invoke http://localhost/papz/test.jsp
    I dont see anything. The page is blank. And there are no error messages in any log files. When i click on view source in IE i get to see the entire source code, including the jave code.
    <html>
    <head>
    <title>Test</title>
    <body>
    <%
    out.println("Hello World");
    %>
    asdfasdfasdf
    </body>
    </html>
    i added in the asdfasdf to see whehter it will be printed or not... It does print that stuff out.
    when i try to invoke the login.jsp page, i get the dialog box "save this file to disk"
    Any clues whats going on...?
    I followed the instructions...over and over again... but it doesnt seem to help.
    win nt 4.0
    apache 1.3.12
    jserv 1.1.1
    Pls help. Thanks

    Hi,
    Have you solved your problem?
    I4m trying to do the same, but I installed portal 30, then portal to go, and when I try to run test.jsp I get the following error:
    Request URI:/papz/test.jsp
    Exception:
    java.lang.NoSuchMethodError: oracle.jsp.util.JspUtil: method
    stripTarget(Ljava/lang/String;C)Ljava/lang/String; not found
    Thanks
    Pablo Lopera
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by NewBie:
    when i try to invoke http://localhost/papz/test.jsp
    I dont see anything. The page is blank. And there are no error messages in any log files. When i click on view source in IE i get to see the entire source code, including the jave code.
    <html>
    <head>
    <title>Test</title>
    <body>
    <%
    out.println("Hello World");
    %>
    asdfasdfasdf
    </body>
    </html>
    i added in the asdfasdf to see whehter it will be printed or not... It does print that stuff out.
    when i try to invoke the login.jsp page, i get the dialog box "save this file to disk"
    Any clues whats going on...?
    I followed the instructions...over and over again... but it doesnt seem to help.
    win nt 4.0
    apache 1.3.12
    jserv 1.1.1
    Pls help. Thanks<HR></BLOCKQUOTE>
    null

  • Using the "java" command in Java 1.4.1

    Hello..
    I don't seem to be able to run any application that should run with
    the "java" command in Java 1.4.1. Everytime I use "java" I get the "java.lang.NoClassDefinitionError"
    Even running this simple program doesn't work:(
    package chapter10;
    public class test {
    public static void main(String args[]) {
    System.out.println("Hello WORLD!!");
    }//end class
    when I run: "java chapter10/test"
    I get the following message:
    "Exception in thread 'main' java.lang.NoClassDefinitionError: chapter10/test"
    And the sam happens to any other class when I try to run it:(
    The "javac" command works fine:) but the "java" is giving me a hard time:(
    I would appreciate any suggestions or answers to this problem:) THANK U

    See if this explanation helps.
    Assume that your programs are part of a package named divelog, which is specified by the first line in each source file: package divelog;
    Also assume that this directory (C:\javaT\myWork\) is part of the CLASSPATH list of directories.
    Also assume that all the source files reside in this directory structure: C:\javaT\myWork\divelog\
    Then a statement to compile a source file Named Divelog.java is:
    C:\JavaT\myWork\>javac divelog\Divelog.java
    Explanation:
    Java starts looking for classes in the directory(s) listed in the classpath. In this case, one of the directories should be: C:\JavaT\myWork\ since it contains your divelog package.
    Compiling
    A class can either be part of a package (ie, no package statement at the top of the class.), or not.
    If the class is not part of a package: Its source file needs to be in one of the classpath directories. To compile you use the command: javac SomeFile.java, from within the classpath directory that contains the file.
    The class is part of a package (this case): The source file must be in a subdirectory structure that starts in one of the classpath directories. The subdirectory structure must match the package statement.
    So, you generate a directory structure C:\javaT\myWork\divelog\ which is the [classpath directory + the package subdirectory structure], and place Divelog.java in it.
    Then from the classpath directory (C:\JavaT\myWork\) use the command: javac divelog\Divelog.java
    This creates a file, Divelog.class in the divelog directory. (The following is where people tend to get lost.) The correct name now, as far as java is concerned, is the combination of package name and class name: divelog.Divelog (note I omit the .class)
    Running
    To run a class that's not part of a package: From within the classpath directory that contains the class. use the command: java SomeFile
    To run a class that is part of a package: From within the classpath directory (C:\JavaT\myWork\) use the command java divelog.Divelog (Note that this is analogous to the command for a class not in a package, you just use the fully qualified name)

  • Why is the Java runtime resource hungry and slow?

    Hi,
    First of all let me make it clear that I'm not here to bash Java. I'm a big fan of the technology. In fact I believe in its potential as it is the only true 100% cross-platform runtime. Now that it has been open sourced, it has just made me happier,
    However, the only factor which has been hurting me is that the Java runtime is resource hungry and has long startup times.
    Consider a Adobe Flash .swf file with lot of animation, it is opened by the Flash player in a snap. On the other hand Java applets (with same amount of graphics) take several seconds to load even from the local machine and also require much more memory. With the introduction of Flex flash might become a platform of choice for RIA. Java FX has made matters worse. The loading time of Java FX is much higher than that applets themselves.
    The problem with Flash Player is it not 100% platform independent. For example the latest version of player was released for Linux several months after it was released for Windows and Mac OS X.
    Is there any way to make the Java runtime use less memory and start faster? If this can be achieved I feel that applets are a better choice over Flex for building RIAs. After all appearance is not everything and definitely Java is a much more robust platform than Flash.

    I'm running it on Kubuntu Linux. Even on this Flash Player is much faster at loading embedded Flash animations than JRE loads applets.
    Seriously, if alone the speed of loading applets can be increased, the world will have an extremely robust platform for RIAs.

  • Error : "Could not create the Java Virtual Machine"

    Hi,
    i am beginner in java. I am doing project making a small embedded linux system to run java app.
    first i install JDK on my host (i686-linux 2.6.16-openSuse 10.1) and JRE on my target (i686-linux 2.4.32), both are version 1-5-. then I try to make the "Hello World!" program ,test it on the host, works fine.
    then i put on my target system, but it didnt work. the error message was:
    There was an error trying to initialize the HPI library
    Please check your installation. Hotspot does not work correctly
    when installed in the JDK 1.2 Linux Production Release, or
    with any JDK 1.1.x release.
    Could not create the Java virtual machine. thanks for any help and suggestion for the newbee

    Maybe this older thread is of help:
    http://forum.java.sun.com/thread.jspa?threadID=643395

  • Versions - Where's the real world?

    I'm just curious what the members here think.
    What version of Java do you think most people in the business world are using?
    If you're not in the U.S.A., please indicate that and where you are.
    Thank you.

    Java4um wrote:
    I'm just curious what the members here think.
    What version of Java do you think most people in the business world are using?
    If you're not in the U.S.A., please indicate that and where you are.
    Thank you.I think people in the business world are generally blissfully unaware of which version of Java they are using.
    Much depends on the field/market you're in (not geographical location). For example, I imagine that embedded software will generally run on older versions than stand-alone desktop applications. Application Servers tend to be a bit conservative, especially in production environments, so I would expect to see Java 5 more often than Java 6 there.
    As a developer I tend to use multiple versions of Java (we produce mainly web-based applications). We're currently still supporting Java 5 for previous releases. New releases use Java 6, although we haven't updated to 1.6.0 update 10 yet. For specific clients, we may occasionally need to revert to Java 1.4.

  • Code works in the real world - fails in the emulator

    If you want to test this try http://hatemytory.com/java/deploy.wml
    Anyway, my code loads an image over the network using http. This (appears) to work fine in the real world but in the WTK emulator it chokes by only downloading the first 16358 bytes of the image and then failing on the createImage call.
    Apologies for the code being a bit choppy - I've been fiddling with it to see why it might fail - is this me or is it the WTK?
    private void loadToryImage()throws IOException {
              HttpConnection hc = null;
              DataInputStream in = null;
              String torylist = null;
              byte[] data = null;
              int index = 0;
              int length = 0;
              try {
                   String baseurl =
                   "http://hatemytory.com/tory-cgi/getpngtory.pl?name=";
                   String word = mTory.replace(' ', '+');
                   String coords = "&x=" + x_width + "&y=" + y_height;
                   String url = baseurl + word + coords;
                   hc = (HttpConnection) Connector.open(url);
                   length = (int)hc.getLength();
                   if (length != -1) {
                        data = new byte[length];
                        in = new DataInputStream(hc.openInputStream());
                        in.readFully(data);
                   else {
                        //read in in chunks
                        int chunkSize = 0;
                        int readLength = 0;
                        in = new DataInputStream(hc.openInputStream());
                        chunkSize = (int)hc.getLength();
                        data = new byte[chunkSize];
                        do {
                             if (data.length < index + chunkSize) {
                                  byte[] newData = new byte[index + chunkSize];
                                  System.arraycopy(data, 0, newData, 0, data.length);
                                  data = newData;
                             readLength = in.read(data, index, chunkSize);
                             index += readLength;
                        }while (readLength == chunkSize);
                        length = index;
                   logo = Image.createImage(data, 0, length);
              catch (IOException ioe) {
                   logo = null;
                   return;
              finally {
                   if (in != null) in.close();
                   if (hc != null) hc.close();
              return;
         }

    If you want to test this try http://hatemytory.com/java/deploy.wml
    Anyway, my code loads an image over the network using http. This (appears) to work fine in the real world but in the WTK emulator it chokes by only downloading the first 16358 bytes of the image and then failing on the createImage call.
    Apologies for the code being a bit choppy - I've been fiddling with it to see why it might fail - is this me or is it the WTK?
    private void loadToryImage()throws IOException {
              HttpConnection hc = null;
              DataInputStream in = null;
              String torylist = null;
              byte[] data = null;
              int index = 0;
              int length = 0;
              try {
                   String baseurl =
                   "http://hatemytory.com/tory-cgi/getpngtory.pl?name=";
                   String word = mTory.replace(' ', '+');
                   String coords = "&x=" + x_width + "&y=" + y_height;
                   String url = baseurl + word + coords;
                   hc = (HttpConnection) Connector.open(url);
                   length = (int)hc.getLength();
                   if (length != -1) {
                        data = new byte[length];
                        in = new DataInputStream(hc.openInputStream());
                        in.readFully(data);
                   else {
                        //read in in chunks
                        int chunkSize = 0;
                        int readLength = 0;
                        in = new DataInputStream(hc.openInputStream());
                        chunkSize = (int)hc.getLength();
                        data = new byte[chunkSize];
                        do {
                             if (data.length < index + chunkSize) {
                                  byte[] newData = new byte[index + chunkSize];
                                  System.arraycopy(data, 0, newData, 0, data.length);
                                  data = newData;
                             readLength = in.read(data, index, chunkSize);
                             index += readLength;
                        }while (readLength == chunkSize);
                        length = index;
                   logo = Image.createImage(data, 0, length);
              catch (IOException ioe) {
                   logo = null;
                   return;
              finally {
                   if (in != null) in.close();
                   if (hc != null) hc.close();
              return;
         }

  • RMI Use in the real world

    I present an RMI module in the Java course I teach. I know enough about RMI to be able to talk about it, and write a simple classroom example, but I have never done RMI in the real world. Can anyone offer an example of what kind of applications are being developed that use RMI?
    Thanks,
    J.D.

    I can tell you about two sites.
    1. A system which allocates and dispatches crews, trucks, backpack hoses, spare socks, etc to bushfires (wildfires to you). It operates between two Government departments here in Australia. Each of those despatchable items is a remote object and there have been up to 50,000 active in the system at a time during the hot summer months. This is a large and life-critical system.
    2. A monitoring system for cable TV channels. A piece of hardware produces a data stream representing things like channel utilization, error rates, delay, etc and this is multiplexed via RMI to a large number of operator consoles. Again this is a major and business-critical system.
    And of course every J2EE system in existence uses RMI internally, albeit almost entirely RMI/IIOP.

  • Novice to the programming world

    heya folks...
    well anyway i'm kinda new to the programming world...so this new bean wants to learn from the old timers :)
    i've got 2 programming languages that i wanna learn in my mind which is JAVA or C++. among the 2 which would you recommend?
    Furthermore, could you provide the pros and cons of the languages? Although i've researched about the languages, still i cant figure out which one to chose. Let say, after i've mastered one of the languages, which one would incorporate 3D graphics easily ?

    The choise between Java and C++ is a hard one because it depends on what kind of programs you want to write. If you just want to get started with programming I suggest Java or C# actually. They are similar and simpler than C++.
    If you're using Windows and don't need the portability of Java while learning how to program, C# may be the best choise.
    Java has a high-level 3D graphics API called Java3D. If you want get to going with 3D programs anytime soon, Java may be the best choise.
    Programming isn't about language syntax only. You also have to learn about algoritms, data structures and programming techniques that are independent of any language in particular. If you don't know much about this I wouldn't recommend C++.

Maybe you are looking for

  • Loading multiple swfs

    I need to have many movieClips and load them from an external swf. I can make that work using a movieClipLoader, but I need to gotoAndStop on a different part of the loaded movieClip timeline for each loaded instance. What's the best approach? Multip

  • Concurrent Managers are taking long time to pick the request- Urgent help

    Hi All, We have upgrade 11.5.10.2 to 12.0.6 with PCP and loading balancing. Whennever concurrent request is submitted it takes long time to pick the request. We have the increases proceseses and reduced the sleep time of the standard manager. Any inp

  • HELP! How to validate DATE?

    Hello... how to validate a DATE variable? I have used SimpleDateFormat (dd/MM/yyyy). For some input it worked fine, but for: 12/67/200394 (OK!) <- this is false, right? but not trapped! 1234546 (TRAPPED!) 12/324/1234 (OK!) <- this is false, right? bu

  • ERROR PropertyMapWrapper Invocation for getter InvocationTargetException

    Hello, using Oracle SQL Developer Data Modeler 3.0.0.665 I get the following error when engineering from relational to logical model the following schema: screenshot of the relational model: https://picasaweb.google.com/lh/photo/C38q8WKjU3zi-ZhS_2syf

  • Guest tunnel/auto-anchor from 2100 to 4400 WLC

    We'd like to extend our current Guest LAN from a 4400 WLC in our data center to a 2100 WLC located at a remote facility. However, we cannot get the foreign controller to pass traffic to the anchor controller – or so it seems. The catch is that we're