hi CR, when i click a button on a screen it should open up an another tabItem, i wanted to implement using annotation, but i am do not know anything about annotation, with out using annotation i have implemented it.
presently i have a print menuItem in my file menu, when i click on the print it does not open up the print dialog, is that the OS, this is the that i am using kindly let me know the solution
// Prompt the user for an image file
FileDialog fileChooser = new FileDialog(shell, SWT.OPEN);
String fileName = fileChooser.open();
System.out.println("2");
if (fileName == null) { return; }
System.out.println("3");
// Load the image
ImageLoader loader = new ImageLoader();
ImageData[] imageData = loader.load(fileName);
System.out.println("4");
PrinterData printerData = null;
if (imageData.length > 0) {//
System.out.println("5");
// Show the Choose Printer dialog
PrintDialog dialog = new PrintDialog(shell, SWT.CLOSE);
try{
System.out.println("dialog : "+dialog);
printerData = dialog.open();
System.out.println("dialog1 : "+dialog);
}catch(Exception e){
e.printStackTrace();
}
System.out.println("6");
if (printerData != null) {
System.out.println("7");
// Create the printer object
Printer printer = new Printer(printerData);
System.out.println("8");
// Calculate the scale factor between the screen resolution and printer
// resolution in order to correctly size the image for the printer
Point screenDPI = display.getDPI();
Point printerDPI = printer.getDPI();
int scaleFactor = printerDPI.x / screenDPI.x;
System.out.println("9");
// Determine the bounds of the entire area of the printer
Rectangle trim = printer.computeTrim(0, 0, 0, 0);
System.out.println("10");
// Start the print job
if (printer.startJob(fileName)) {
if (printer.startPage()) {
GC gc = new GC(printer);
Image printerImage = new Image(printer, imageData[0]);
// Draw the image
gc.drawImage(printerImage, 0, 0, imageData[0].width,
imageData[0].height, -trim.x, -trim.y,
scaleFactor * imageData[0].width,
scaleFactor * imageData[0].height);
// Clean up
printerImage.dispose();
gc.dispose();
printer.endPage();
}
}
// End the job and dispose the printer
printer.endJob();
printer.dispose();
} else {
System.out.println("No data to print");
}