- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 3
- Posts with Upvotes
- 3
- Upvoting Members
- 3
- Downvotes Received
- 5
- Posts with Downvotes
- 3
- Downvoting Members
- 3
14 Posted Topics
Re: C:\temp>java RandomSeq 10 0.1995878045764118 0.18697513449515613 0.6346645242682385 0.6909903957451974 0.05055577107407527 0.8429962094911159 0.8997199708121247 0.753002832281699 0.7655982819397776 0.4395337156072403 C:\temp>java RandomSeq 10 > txt.txt C:\temp>more txt.txt 0.45298364345396724 0.052193562285097195 0.5216091648361046 0.3600187351861466 0.6047989454746013 0.9062731448554414 0.8493113352078762 0.21295096211349018 0.8555603561942511 0.45169566534727856 This was in windows xp, I got the same result with linux Copy/Paste exactly what you did and saw, what … | |
Re: As JavaAddict said, Serialized objects give you a good option if you're looking to store a few bits It won't save nulls, but you can create an object to swap for nulls when you're reading/writing Check out the java.io.ObjectOutputStream a simple [code] File f = new File("c:\\myobj.obj"); ObjectOutputStream out = … | |
Re: er paste your exception here.. the null pointer exception stacktrace will show you the line there's a problem, and looking in the code, you'll see the variable on that line that's giving the problem. eg. [code] Exception in thread "main" java.lang.NullPointerException at Main.displayStuff(main.java:11) at Main.main(main.java:17) [/code] would tell you to … | |
Re: If the objects are written as MailingLabel objects, read them in and cast them before adding to the arraylist (which you specified takes MailingLabel classes, so add(Object) is now add(MailingLabel) more or less) arrayOfMailingLabels.add((MailingLabel)in.readObject()); works? | |
Re: Try something small/simple like [code] File f = new File("c:\\myreallybigfile.txt"); FileInputStream fin = new FileInputStream(f); byte[] partial = new byte[1024]; // or whatever fin.read(partial); String str = new String(partial); // or whatever ;) System.out.println(str); fin.close(); [/code] change to suite and stick in error handling etc | |
Re: [CODE] Calendar calendar = Calendar.getInstance(); [/CODE] As masijade said, this is creating a Calendar instance, and its default is the current date/time.. however, the Calendar object doesn't have an empty constructor like .. JPanel for example The way to create a Calendar object is to call the STATIC method getInstance() … | |
Re: Line 12 is going to give you trouble regardless .. change this to super. Component comp = [B]super.[/B]getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); As for the other problem, you have set your new renderer as the cell renderer for all the columns? table.setDefaultRenderer(Integer.class, new myCellRenderer()); or table.getColumnModel().getColumn(0).setCellRenderer(new myCellRenderer()); table.getColumnModel().getColumn(1).setCellRenderer(new myCellRenderer()); … | |
Re: hmm try remove line 327 <appender-ref ref="CONSOLE"/> on jboss startup, are there any errors and warnings relating to log4j? | |
Re: [QUOTE=BestJewSinceJC;1146074]I don't know why your call to super.paintComponent(g) is the [I]second[/I] call in your method; I was always taught that a call to super has to be the first call in your method as it says [URL="http://java.sun.com/docs/books/tutorial/java/IandI/super.html"]here[/URL]. I could be wrong and this might be a special case, but I … | |
Re: You can also write your own eg. ActionListener that takes in the parent in its constructor so it can access local variables in its 'parent' .. ie. construct your own implementation of an actionlistener that takes in some interface in its constructor (that the parent implements) and work away | |
Re: [code] public void test(Object obj){ if(obj instanceof String){ System.out.println("Obj is a String, I can cast it to a string and use its methods eg."); System.out.println("The Strings length: "+ ((String)obj).length()); } } [/code] you can also just overload methods, so the correct one gets called eg. [code] public void test(String obj){ … | |
Re: [QUOTE=devstarter;1145202]public boolean isFull(){ //generally full if(parcelIsFull() || hcparcelIsFull() || noSharingParcel()) return true; } [/QUOTE] It's evaluating the line if(parcelIsFull() || hcparcelIsFull() || noSharingParcel()) .... if this is true, it returns true .. but what happens if it evaluates to false? You need [code] if( parcelIsFull() || hcparcelIsFull() || noSharingParcel() ) … | |
Re: Yup add a document to the jtextfield .. hmm like [code] class JTextFieldLimit extends PlainDocument { private int limit; JTextFieldLimit(int limit) { super(); this.limit = limit; } public void insertString (int offset, String str, AttributeSet attr) throws BadLocationException { if (str == null) return; if ((getLength() + str.length()) <= limit) … | |
Re: [code] Date d = new Date(); SimpleDateFormat sf12 = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss aa"); SimpleDateFormat sf24 = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); // use sf12 to parse or format a date/string to get a Date d1a = sf12.parse("21/12/2009 01:23:12 pm"); Date d1b = sf12.parse("21/12/2009 01:23:12 am"); Date d2 = sf24.parse("21/12/2009 01:23:12"); System.out.println(d1a); System.out.println(d1b); … |
The End.