• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need to create a Navagation Button control using Annotation

 
jacob raja
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am new to SWT and annotations i need to create a Button when a click this button i need to create a tab. so that where ever i using this button (control) i need to create a tab. kindly let me know how to start with.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50196
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch. Sorry nobody has replied so far; I think nobody understands exactly what you want. Please explain more fully.

Are you trying to add tabs to a JTabbedPane? Have you looked in the API for JTabbedPane, which has a link to the Java Tutorial?

CR
 
jacob raja
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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");
}
 
Campbell Ritchie
Sheriff
Pie
Posts: 50196
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know enough about annotations, I am afraid.
CR
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm unclear as to how you think annotations might help you here, especially since you said you don't know much about them. Annotations are a way to provide metadata to a class. Typically they would replace configuration file data such that might exist in XML files.

Sounds like you might be trying to force something that isn't a good fit.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic