Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recent content by Stijn147

  1. Stijn147

    writing to a file

    Try this: public void saveDialog() { /*...*/ try { PrintWriter bw = new PrintWriter(new FileWriter("myText.txt")); bw.write("myText.txt"); bw.flush(); } catch(IOException e) { System.out.println("main():" + e)...
  2. Stijn147

    need help for date in java sql

    When working with dates it is better to use preparedStatements: PreparedStatement ps=con.prepareStatement("SELECT * from EVENT WHERE event_date > ?"); ps.setDate(1, new Date(2003,06,01)); ps.executeQuery();
  3. Stijn147

    array [j] = array [++j] + 10;

    Golden rule: When a variable appears more then once in a statement, never use statements with side-effects on that variable within that statement. The sequence of calculating the whole statement can be different from compiler to compiler. instead of: array[j] = array[++j]+10; write: j++...
  4. Stijn147

    Separate Panels

    Try this: import java.awt.event.*; import javax.swing.*; class Test extends JFrame implements ActionListener { JButton button1=new JButton("Show panel 2"); JButton button2=new JButton("Show panel 1"); JPanel panel1=new JPanel(); JPanel panel2=new JPanel()...
  5. Stijn147

    using actionlistener with an array of jbuttons

    This is the only way to do it: an ActionEvent only contains the address of the JButton that is pressed. You'll have to search your buttonarray for a matching address. public void actionPerformed(Actionevent e) { if (e.getSource()==buttons[0][0]) // ..... if...
  6. Stijn147

    Can I disable a JMenuItem ?

    myItem.setEnabled(false);
  7. Stijn147

    JDBC-ODBC connection

    The 11th line has to be: connection = DriverManager.getConnection(url); If you make a new variable in a block, this will be dstroyed once you've left this block. The reason for the error is that when an Exception should occur on the 11th line connection would still be null. The stack will be...
  8. Stijn147

    Binary Search problem!!

    The error is in this part: int start = pointer; while (start >= 0) { if (searchCriteria.compareTo(arrayToSearch[start][0].substring(0, len)) == 0) { results[nextFreeLocation++] = theList.getItem(Integer.parseInt(arrayToSearch[start--][1])); } else break; } When you...
  9. Stijn147

    Event Handling - Access to object instance from method actionPerformed

    Put the line TextArea input = new TextArea(...); also outside your constructor. Why do I have to declare JRadioButton byteSelected and TextArea input as members of GUI? When your program starts the main method is called. GUI frame = new GUI(); This makes a new instance of the class GUI...
  10. Stijn147

    Event Handling - Access to object instance from method actionPerformed

    In the method actionPerformed only members of the class GUI are accessible. Sollution: public class GUI extends Frame implements ActionListener{ JRadioButton byteSelected=new JRadioButton("Byteorientiert",false); public GUI() {...
  11. Stijn147

    TCP/IP protocol question

    Read this about the OSI Network Model: http://www.ussg.iu.edu/usail/network/nfs/network_layers.html (don't wory about Session and Presentation Layer, those aren't used) Is your question about sending IP-packets or about opening TCP-connections ?
  12. Stijn147

    Insert Long into a Vector Type

    Another sollution: long date; Vector v=new Vector(); //Put date in the vector: Long t=new Long(date); v.addElement(t); //Get date out of the vector: date=((Long)v.elementAt(0)).longValue();
  13. Stijn147

    Tablated Data in output file

    This is what I find in the API specification of BufferedWriter: public void newLine() throws IOException Write a line separator. The line separator string is defined by the system property line.separator, and is not necessarily a single newline ('\n') character.
  14. Stijn147

    Tablated Data in output file

    tabs, carriage returns, backslash and quotes are 'Escape Characters' You can't write these in your code between " " like other characters. Instead you have to use Escape Sequences. These sequences begin with a backslash System.out.print("this\tis a\ntest"); This example...
  15. Stijn147

    FTP Port Problem (Active/Passive)???

    If your IP-address is 192.168.x.x, you're using a private IP-address and you connect to the internet through a NAT-router. The problem with private IP-addresses is that you can make connections with servers on the internet, but they can't make connections with you. FTP in active mode opens the...

Part and Inventory Search

Back
Top