Search Results

Search found 2 results on 1 pages for 'danielfh'.

Page 1/1 | 1 

  • Thread testing for time

    - by DanielFH
    Hi there :) I'm making a thread for my application that's going to do an exit operation at a given time (only hours and minutes, day/month doesn't matter). Is this the right way to do it, and also the right way to test for time? I'm testing for a 24 hour clock by the way, not AM / PM. I'm then in another class going to call this something like new Thread(new ExitThread()).start(); public class ExitThread implements Runnable { @Override public void run() { Date date = new Date(System.currentTimeMillis()); String time = new SimpleDateFormat("HHmmss").format(date); int currentTime = Integer.parseInt(time); int exitTime = 233000; while(true) { try { Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } if(currentTime >= exitTime ) { // do exit operation here } } } Thanks. //D

    Read the article

  • Aligning messageformat on printing a JTable.

    - by DanielFH
    I'm using this for the moment to print out my table, and it works. But I'm not really happy with the layout of the messageformatting, I would like to have both pagenumber and date in the footer, and date format aligned to the left side of the table, and page to the right. How can I do that? Been reading some stuff about overriding the PrintTable method, but seems to get pretty complex from what I've read. Hope you can help me with this issue, thank you. :) import javax.print.attribute.HashPrintRequestAttributeSet; import javax.print.attribute.PrintRequestAttributeSet; import javax.print.attribute.standard.OrientationRequested; import javax.swing.JTable; import dk.beesys.rims.ui.WindowInventory; public class Print { private static Print INSTANCE; public static Print getInstance() { if (INSTANCE == null) { INSTANCE = new Print(); } return INSTANCE; } private Print(){ } public void printList(java.awt.event.ActionEvent ignore) { String strDate = MessageFormat.format("{0,date,short} {0,time,short}", new Date()); MessageFormat header = new MessageFormat("- {0} -"); MessageFormat footer = new MessageFormat("Printed: " + strDate); PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); aset.add(OrientationRequested.LANDSCAPE); try { WindowInventory.getInstance().getTable().print(JTable.PrintMode.FIT_WIDTH, header, footer, true, aset, true); } catch (java.awt.print.PrinterException e) { System.err.format("Cannot print %s%n", e.getMessage()); } }

    Read the article

1