aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes need to create a Navagation Button control using Annotation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "need to create a Navagation Button control using Annotation" Watch "need to create a Navagation Button control using Annotation" New topic
Author

need to create a Navagation Button control using Annotation

jacob raja
Greenhorn

Joined: Feb 20, 2007
Posts: 7
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.


Luv<br />jacob Marshall
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38340
    
  23
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

Joined: Feb 20, 2007
Posts: 7
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

Joined: Oct 13, 2005
Posts: 38340
    
  23
Don't know enough about annotations, I am afraid.
CR
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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.


GenRocket - Experts at Building Test Data
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: need to create a Navagation Button control using Annotation