Printing multiple hidden JPanels using Book and Pageable

I am trying to print a number (in some cases a large number) of JPanels that reside in a Vector; they are only visible one-at-a-time but need to be printed all together. When printing if I am viewing the first page the first page is printed. If viewing any other page nothing is printed at all. I believe that the latter issue is a result of the first page being blank and causing printing to halt when NO_SUCH_PAGE is returned to the print manager.
After some searching I have found no reasonable way to manage this. Displaying each page before appending it to the Book will be cumbersome so I am looking for a way to take each JPanel out of the Vector and add it to the Book for printing.
public static void print(Vector book) {
      bk = new Book();     
      PageFormat pf = new PageFormat();
      pf.setOrientation(PageFormat.LANDSCAPE);
      Paper sheet = pf.getPaper();
      sheet.setSize(paperWidth, paperHeight);
      sheet.setImageableArea(x, y, width, height);
      pf.setPaper(sheet);
      for (Iterator it = book.iterator(); it.hasNext();) {
         bk.append(new PrintPage((Preview)(it.next())), pf);
      print();
   protected static void print() {
      PrinterJob printJob = PrinterJob.getPrinterJob();     
      printJob.setPageable(bk);
      if (printJob.printDialog()) {
         try {
            printJob.print();
         } catch (PrinterException pe) {
            System.out.println("Error printing: " + pe);
   }Any help would be much appreciated. If you have any idea how this might be accomplished I would love to hear it.
Thanks...

An update...
I have ferreted the issues down to a strange inconsistency in the Printable page class:
public class PrintPage implements Printable {
   Component toBePrinted;
   public PrintPage(Component componentToBePrinted) {
      this.toBePrinted = componentToBePrinted;
//         JFrame testFrame = new JFrame();
//         testFrame.getContentPane().add(toBePrinted);
//         toBePrinted.setVisible(true);
//         toBePrinted.validate();
//         testFrame.pack();
//         testFrame.setVisible(true);
   public int print(Graphics g, PageFormat pageFormat, int pageIndex) {
      if (pageIndex > 0) {
         return NO_SUCH_PAGE;
      } else {
         Graphics2D g2d = (Graphics2D) g;
//         JFrame testFrame = new JFrame();
//         testFrame.getContentPane().add(toBePrinted);
//         toBePrinted.setVisible(true);
//         toBePrinted.validate();
//         testFrame.pack();
//         testFrame.setVisible(true);
         g2d.translate(pageFormat.getImageableX(),  pageFormat.getImageableY());
         disableDoubleBuffering(toBePrinted);
         toBePrinted.setVisible(true);
         toBePrinted.validate();
         toBePrinted.paint(g2d);
         enableDoubleBuffering(toBePrinted);
         return PAGE_EXISTS;
   }(Fogive the commented lines, they are to illustrate the JFrame test described below)
If I create a new JFrame in the constructor and add the JPanel / Component 'toBePrinted' to it I can see the contents perfectly fine. If I do the same in the print() method prior to printing there is only content for the first page and four other JFrames with no content. It seems that the JPanels are not being rendered in the print() method which is screwy since the constructor has no problems, the same scope, access, etc.
Any ideas?

Similar Messages

  • Printing multiple envelopes from address book with Lion

    I am having trouble getting envelopes to print properly from Address Book in Lion.  I have specified size #10 envelopes.  When I print them, the text printed on successive envelopes moves further and further down the page until the address drops off of one envelope and is then printed at the top of the next envelope.  If I print to PDF, I see the same behavior.  I have an HP Photosmart Premium printer.  I didn't have this problem before I upgraded to Lion, and all my settings are the same as they were prior to the upgrade.  I have seen that other users have the same problem on the forums, but there isn't a clear cut answer to how to solve the problem anywhere.  I also tried using the easy envelopes widget, and I still have the creeping further down the envelope problem.  HELP!!!

    It seems to be a bug in Lion. Try the solutions provided in other disucssions about changing print size and orientation. Create a custom size and save it. You should be able to test it by printing to pdf first to check it. That way you won't have to waste paper.
    https://discussions.apple.com/message/18390621#18390621
    https://discussions.apple.com/message/18504818#18504818

  • Printing multiple copies in 1.3 and 1.4

    Hi,
    I have a problem while trying to print multiple copies of a doc programmatically (without the Print Dialog)with 1.3 and 1.4, but nobody seems to know an answer.
    In 1.3 you can set the nr. of copies on the PrinterJob with the setCopies() Method. But this just doesn't work...
    pj.setCopies(2);
    pJ.print();
    prints only one copy!
    On the 1.4 you can use the PrintRequestAttributeSet to set the nr of copies, I tried this too, but it also doesn't work, I always receive just one copy (or the nr. of copies set in the Print Dialog...)
    PrintRequestAttributeSet attset = new HashPrintRequestAttributeSet();
    attset.add(new Copies(2));
    pJ.print(aset);
    This has to work somehow, nobody seems to miss it and it is part of the API. Is there some other trick that must be taken into account? The Bug List brings a few old errors, but under 1.4 there is no bug listed...
    Thanks for helping me!
    Maria

    Thanks a lot for helping me, this just wasn't my problem; but at least I'am meanwhile a little bit wiser:
    the problem seems to be the printer: I can try here on 3 different printers (one of them is the ADOBE PDF, where I mostly do the testing).
    The Printer 1 returns the SupportedAttributeValues for Copies 1-2000 and prints the 2 Copies wished ( works properly!)
    The Printer 2 returns the SupportedAttributeValues for Copies 1-999 but doesn't print more than 1 copy (Any idea ??? )
    The Printer 3 ( the ADOBE PDF one ) returns the SupportedAttributeValues for Copies.class 1 and prints allways only one copy, which at the first view seems to be right...(I already have tried to change the MultipleDocumentHandling to SINGLE_DOCUMENT.SINGLE_DOCUMENT_NEW_SHEET but that doesn't help!)
    But I don't understand, why all the printers print 2 copies if I do it through the Print Dialog: when I increase the number of copies in the dialog, the specified number of copies is allways printed!!!
    It is driving me crazy! I cannot properly implement the requirement to print 2 copies of a document, because there is no information from the printer that this won't do it ( see the printer 2!!!) The information about the printer that the java API returns, seems to be less than the printer really can!!!??? I hope, I am wrong...
    So, if you have solved such problems, please let me know how!
    Lot of thanks,
    Maria

  • How to print uspto patent images using Safari and Quicktime

    3/18/06
    Do you want to know how to print US patent images using Safari? Read on.
    When you access the "images" link of a specific patent on the www.uspto.gov/ website using Safari, the page you are viewing is only one small upper left tile of a huge patent image that is not sized to the screen. You can scroll and try to read the page but it's almost impossible. Try to print it out and you only print what's on the screen. Bummer.
    The fix:
    Place the cursor on the opened image (it may appear blank), hold down the CONTROL key on you keyboard and click on the image. Two instructions come up. Click on the "Save Image to the Desktop" instruction and a DImg.tiff file will be created on your desktop. Click on the .tiff file and it should open in the Preview program, then simply print out the image. Voila!!!!
    Click the yellow arrow in the left margin to access page 2 of the patent and repeat the previous instructions to create another .tiff file on your destop. Do every page and you'll have the patent available to print out one page at a time.
    You can then rename the files and create a folder for that specific patent so you can access it later without signing onto uspto site.
    It's odd that the ever compatible Apple does not provide seamless compatibility to view and print patent images on the US Patent and Trademark Office's website. Where would they be without protecting their own intellectal property? Let's hope the next version of Quicktime includes the appropriate ITU T.6 or CCITT Group 4 (G4) compression language.
    Even the "throw it out the Windows" operating system is up to speed on this issue for America's hard working inventors.
    Keep on inventing.
    Tommy K
    imac 400 DV   Mac OS X (10.3.9)   Cube 450
    imac 400 DV   Mac OS X (10.3.9)   Cube 450

    Another similar thread on this issue...
    http://discussions.apple.com/thread.jspa?messageID=1602391

  • How Do I Network Multiple Base Stations Using Ethernet AND Wireless?

    Hi, everyone. I am having great difficulty setting up a network using multiple Airport Extreme base stations that are connected using both ethernet and wireless connections. I have one main base station connected to a cable modem, and I want to create a unified network and share its internet connection with three other base stations: one that is connected on an ethernet network, one connected to it wirelessly, and the fourth that would be connected wirelessly to the base station on the ethernet network.
    The "Designing Airport Networks" manual explains how to build roaming networks of base stations that are connected to one another via ethernet. And it also explains how to build a WDS of wirelessly connected base stations. What it doesn't explain is how to build a network employing both ethernet AND wireless!
    I spent most of today trying to get the base stations to work in various configurations to no avail. I could get part of the network working, but not all of it. I'm at the point where I'm going to need to do a hard, factory reset on all the base stations and start over, but I wanted to see if anyone had any suggestions for me. Any help would be incredibly appreciated! Thanks so much...
    Message was edited by: Bill Ryan2

    If you have stations connected via Ethernet and want them to appear as a single seamless wireless network, configure them as follows:
    Same SSID (network name).
    Different channels. As far apart as possible.
    Same wireless encryption type/level/password.
    Only the base station connected to the Internet source distributes IP addresses. All the others are configured as bridges.
    If you have stations connected wirelessly using WDS and want them to appear as a single seamless wireless network, configure them as follows:
    Same SSID (network name).
    Same channel.
    Same wireless encryption type/level/password.
    It appears that you want to mix the 2 type of connections. This is easily done and here is a simple example:
    base1 Ethernet base2
    In this example base1 and base 2 are configured as I suggested above for Ethernet connections.
    Now add base3 connected wirelessly:
    base1 Ethernet base2 wireless base3
    Now base2's configuration must be modified slightly so that it acts as a WDS main. base3 is configured to act as a WDS remote (or relay).
    No changes are needed to base1 since it is completely unaware and uninvolved in the WDS link between base2 and base3.

  • I am trying to print labels from my address book, and when I change it to have the first names first, only some names work.  Does anyone know what the problem is or how to fix it?

    I want to print labels from my address book, but when I try to put first names first, only some will work.  Does anyone know why this is happening and how to fix it?

    Hi MollyPhloot07,
    I'm glad you found the coupons.com app and you might also want to take a look at the GroceryIQ app from the same company.  Please note that at this time, printing is only support from iPad to HP wireless inkjet printer.  That's most likely the reason why your Canon isn't displaying when attempting to print.  The other way to go might be emailing the coupons you want to your email address, then open that email and print from a conventional desktop or laptop computer.
    Hope this helps!
    Coupon Support

  • Label printing at Goods Receipt using SMARTFORMS and Zebra software

    Hi Experts,
    Upon designing a functional design for the printing of labels upon goods receipt and a re-print through MB90 I would like to understand the procedure on how the label gets printed. From what I understand the following steps are done:
    A label is designed in the Zebra application tool.
    The file is downloaded from the application and uploaded into SAP
    A SMARTFORM is created in SAP and assifned to a new output type.
    The new output type is assigned to the Zebra Printer.
    Is there any need for an abap program to be written, if so when and what is its purpose?

    Output Type WEE1 uses sap print program  SAPM07DR.
    Can the following data fields be retrieved from this program:
    Material Number (MSEG-MATNR)
    Bin Number (MSEG-LGPLA)
    Material Description (Feed (MAKT-MATNR) Get (MAKT-MAKTX))
    Supplier Name: Feed (MSEG-MBLNR) get (MSEG-EMLIF)
    MSEG-EMLIF=LFA1-LIFNR
    Feed (LFA1-LIFNR) get (LFA1-NAME1)
    Supplier Material Number: Feed (EKPO-EBELN) get (EKPO-IDNLF)
    PO number and Item: Feed (MSEG-MBLNR) get (MSEG-EBELN) and (MSEG-EBELP)
    GRN Date: Feed (MKPF-MBLNR) get (MKPF-BLDAT)

  • I need to pass multiple select options using submit and reutrn

    dear all,
    my requirement is i need to pass multiple values for work center like(biw01,biw02,biw03    etc) for this iam giving as biwl* and biot* for the tcode zpp_hmm ,using this i am going to get total working hours of perticular equiment.
    for this iam using submit and return query but iam unable to pass multiple work centers as input.
    my code is
    DATA : z_budat TYPE  RANGE OF budat,
           wa_budat LIKE LINE OF z_budat.
    wa_budat-low = '20111001'.
    wa_budat-sign = 'I'.
    wa_budat-option = 'BT'.
    wa_budat-high = '20111031'.
    APPEND wa_budat TO z_budat.
    CLEAR wa_budat.
    *wa_budat-High = '20111031'.
    *wa_budat-sign = 'I'.
    *wa_budat-option = 'BT'.
    *append wa_budat to z_budat.
    DATA : z_arbpl TYPE  RANGE OF arbpl,
           wa_arbpl LIKE LINE OF z_arbpl.
    wa_arbpl-low = 'BIWL*'.
    wa_arbpl-sign = 'I'.
    wa_arbpl-option = 'EQ'.
    APPEND wa_arbpl TO z_arbpl.
    CLEAR wa_arbpl.
    wa_arbpl-high = 'BIOT'.
    *wa_arbpl-sign = 'I'.
    *wa_arbpl-option = 'BT'.
    *APPEND wa_arbpl TO z_arbpl.
    SUBMIT   zpp_rep_hemm_perf WITH s_bukrs = '1004'  WITH s_budat IN z_budat WITH      s_werks = 'SMJT'
                   with   S_ARBPL IN Z_ARBPL USING SELECTION-SCREEN '1000' AND RETURN.
    but my doubt is whether it is corect or wrong what ever i am passing inputs for arbpl.
    thanks in advance.

    You can pass all parameter (rsparams-kind = 'P') and select-options (rsparams-kind = 'S') as a single internal table of type RSPARAMS. Go on appending the field names and values as rows and pass using SELECTION-TABLE parameter of SUBMIT command.
    I gave appending one set of selection values for s_budat field but you can go on appending more values for s_budat and other fields.
    DATA: lt_rsparams TYPE TABLE OF rsparams,
          ls_rsparams TYPE rsparams.
    CLEAR ls_rsparams.
    ls_rsparams-selname  = 'S_BUDAT'.
    ls_rsparams-kind = 'S'.
    ls_rsparams-sign = 'I'.
    ls_rsparams-option = 'BT'.
    ls_rsparams-low =  '20111001'.
    ls_rsparams-high = '20111031'.
    APPEND ls_rsparams TO lt_rsparams.
    SUBMIT zpp_rep_hemm_perf WITH SELECTION-TABLE lt_rsparams
                      USING SELECTION-SCREEN '1000'
                      AND RETURN.

  • Why can I not print multiple files to one sheet and create a PDF of that format via Print dialogue on Mac? Very important part of workflow!!!!

    Try this if you use mac.
    Create a multiple page PDF. Three pages.
    Go to print.  - Multiple pages per sheet so that you see all three pages on your sheet to be printed.
    At this point, on a windows machine, you can print this as a PDF.  On Mac, it only lets you save as PDF (Not with the format selected).
    WHY has this functionality been removed from the Mac version of Acrobat XI??? Adobe?

    Jon,
    Unfortunately, Rave's response is quite incorrect on two major points.
    The Adobe PDF PostScript printer driver instance was indeed part of the Macintosh version of Acrobat Pro until a few years ago.
    However, it was NOT Adobe that killed the feature. Apple did! In one of the MacOS updates, Apple fully removed the capability that Adobe had to support this virtual printer. There was nothing that Adobe could do about this, regrettably. Adobe didn't cripple anything. Complain to Apple!
    However, Adobe does provide a replacement for it that will yield similar results, but it is not available in Acrobat or Adobe Reader!!! In most applications' print dialogs (such as Word) - which printer you select is irrelevant, click on the PDF button and select the Save as Adobe PDF option. This will save your document as a PDF file with Adobe technology. But again, this is not available from with Acrobat or Adobe Reader.
    However, you should note that the process that you previously followed and you would like to continue to use is commonly referred to as “refrying a PDF” and is strongly discouraged even where it continues to work under Windows. Why? The print function of Adobe applications including Acrobat and Reader is optimized for PostScript for printing, not for creation of PDF. Resultant PDF files have lost any transparency (it has been flattened) and all color management has been lost.
    What you are really trying to do is to create a pre-imposed PDF file from an existing PDF file. Going through PostScript was and still is a very bad idea.
    There are some third party plug-ins to Acrobat, such as Quite Imposing (Quite Software, <http://www.quite.com>) and PDF Snake (<http://www.pdfsnake.com>) as well as some “free” (you get what you pay for) solutions you can look up on the web that can do PDF imposition without ruining your PDF via PostScript.
    Hopefully this can assist you.
              - Dov

  • Printing multiple PDF's using JavaScript

    Hi,
    I have a simple HTML page containing links to a few PDF docs (e.g. www.server1.com/doc1.pdf, www.server1.com/doc2.pdf, etc). There's also a button called "Print" that is supposed to print all the docs when clicked. Is there any way I could print all these documents together without having to display the print dialog for every file? I was thinking a solution would be collating the docs into a single PDF doc but I don't know how to do it. Any ideas?
    Thanks!

    Thanks for the help. So collating is off the table. Now consider this:
    <embed id="doodad" src="http://www.tagg.org/pdftest.pdf" width="0" height="0" name="pdfFile"/>
    <script>
            var x = document.getElementById("doodad");
            x.click();
            x.setActive();
            x.focus();
            x.print();
    </script>
    This script basically send a single PDF doc to the printer and results in the print dialog to pop up. If I want to send multiple docs to the printer is there any way so that either the said dialog would not show or it only showed once for all the docs queued? I may be getting more into the JS side of things in which case I apologize in advance; if that's the case I can ask my question on a JS forum.
    Thanks again!

  • Cannot print out correct colors using Mac and Epson Artisan 1430

    I recently switched from using Illustrator on my PC to using Illustrator on my IMAC.  My display on the PC and the display on the IMAC show the graphics in the exact same colors.  When I print a graphic from my PC in Illustrator on my Epson printer it is identical to the display on my PC.  When I print the same graphic from my IMAC on my Epson printer, the color is not the same - it is a bit off.  I have tried everything - what should I do?

    Just checking, was this the driver you downloaded?
    Printer Driver v8.31
    Intel-based Macs with OS X (v10.4.11 - v10.6.x), PowerPC Macs with OS X (v10.4.11 - v10.5.8)
    epson13988.dmg - 28.1MB - posted on 09/14/10
    http://tinyurl.com/2bmj3as
    Or this one...
    Drivers and Utilities Combo Package
    Intel-based Macs with OS X (v10.4.11 - v10.6.x), PowerPC Macs with OS X (v10.4.11 - v10.5.8)
    epson13990.dmg - 80.8MB - posted on 09/14/10

  • Create and manage multiple web sites using iWeb and GoDaddy

    Now that Mobile Me is going away and the other comments in this discussion relate to iwebsites were written several years ago, I am looking for  new and up-to-date information.
    I have been building and maintaining a website using my MobileMe account and porting it over to GoDaddy.
    I need to re-write the site if for no other reason than it is getting cluttered and needs freshining.
    I would also like to create some other seperate web sites with their own URL
    1)  Is iWeb capable of doing this?
    2)  All the information I have found on iWebsites is at least 3 years old and there does not seem to be updates to that software.
    3)  Are there other tools that will allow me to do this?
    And finally, does the group have  any words of wisdom for me.
    Thanks Dunc

    It is now generally acknowledged that iWeb, and iDVD, has been discontinued by Apple. This is evidenced by the fact that new Macs are shipping with iLife 11 installed but without iWeb and iDVD.
    However, iWeb will still continue to work but without the following:
    Features No Longer Available Once MobileMe is Discontinued:
    ◼ Password protection
    ◼ Blog and photo comments
    ◼ Blog search
    ◼ Hit counter
    ◼ MobileMe Gallery
    All of these features can be replaced with 3rd party options.
    I found that if I published my site to a folder on my hard drive and then uploaded with a 3rd party FTP client subscriptions to slideshows and the RSS feed were broken.  If I published directly from iWeb to the FPT server those two features continued to work correctly.
    There's another problem and that's with iWeb's popup slideshows.  Once the MMe servers are no longer online the popup slideshow buttons will not display their images.
    Click to view full size
    However, Roddy McKay and I have figured out a way to modify existing sites with those slideshows and iWeb itself so that those images will display as expected once MobileMe servers are gone.  How to is described in this tutorial: #26 - How to Modify iWeb So Popup Slideshows Will Work After MobileMe is Discontinued.
    It now appears that the iLife suite of applications offered on disc is now a discontinued product and the remaining supported iApps will only be available thru the App Store from now on. However, the iLife 11 boxed version that is still available at the online Apple Store (Store button at the top of the page) and those still on the shelves of retailers will include iWeb and iDVD. Those two apps were listed in small, gray text on the iLife 11 box that I bought.
    Personally, if I didn't already have a copy I would purchase one to have it for reinstallation purposes if ever needed.
    This might be of some interest to you at this time: Life After MobileMe.
    If you're running or planning on running Lion the following will be of some interest to you:
    In Lion the Library folder is now invisible. To make it permanently visible enter the following in the Terminal application window: chflags nohidden ~/Library and hit the Enter button - 10.7: Un-hide the User Library folder.
    For opening your domain file in Lion for the first time or to switch between multiple domain files  Cyclosaurus has provided us with the following script that you can make into an Applescript application with Script Editor. Open Script Editor, copy and paste the script below into Script Editor's window and save as an application.
    Just launch the applicaiton, find and select the domain file you want to open and it will open with iWeb. It modifies the iWeb preference file each time it's launched so one can switch between domain files.
    do shell script "/usr/bin/defaults write com.apple.iWeb iWebDefaultsDocumentPath -boolean no"delay 1
    tell application "iWeb" to activate
    You can download an already compiiled version with this link: iWeb Switch Domain. This applicaiton can be use with earlier versions of the OS to select and open multiple domain files.
    WARNING: iWeb Switch Domain will overwrite an existing Domain.sites2 file if you select to create a new domain in the same folder.  So rename your domain files once they've been created to something other than the default name.
    OT

  • Problems printing to HP printers using Bonjour and XP

    Good afternoon all
    I am unable to print from my ThinkPad X61 PC laptop running XP (Service Pack 3) to either of my HP printers (Laserjet 6MP and PhotoSmart C3180) connected to my Airport Extreme via a USB hub. They work fine from my MacBook running Snow Leopard, or when directly connected to my PC.
    I am able to install both printers using Bonjour Printer Wizard (and recognize them through Airport Utility). I then print a document, it spools to the print queue, then generates an error saying the document failed to print. I have tried it without the hub with the same result.
    I have reinstalled Bonjour and the printer drivers and followed the Printer Troubleshooting Guide procedure to no avail. I have also tried the TCP/IP port creation which did not work. Any help would be greatly appreciated.
    Yours
    Sam

    Hi Pahu,
    Thanks for you reply. Here's some additional information because I'm not quite sure how to resolve the network addressing as you described. The router is set up as a DHCP server, using the standard 192.168.1.1 IP address, and the subnet mask is 255.255.255.0 The starting IP address is 192.168.1.100, and I have it set to allow up to 50 connections. (No particular reason, I think that may have been the default.) The printer is set up to check a variety of connection protocols, starting with DHCP. If that fails, it moves to BOOTP, etc. When I print the network configuraton page from the printer, it tells me the IP address is 169.254.18.32, subnet mask 255.255.0.0, default gateway 169.254.18.32, and the IP is configured by AUTOIP.
    In the past, when it has been working properly, the printer shows an IP address of 192.168.1.10X, usually .100 or .101, but it depends on which device I've powered up first. This is what I would expect, given that the printer should be communicating with the router and be assigned an IP address by DHCP. What I can't figure out is why the printer reverts to its internal default IP address 169.254.18.32, and why this is inaccessible even if I try to designate the printer as an IP printer and type in the printer's IP address.
    Do I need to set the printer to refresh its DHCP lease more often to ensure it doesn't get cut off by the router? How do I make sure the printer stays on the same subnet as the computers if they're all on the same router? Should I assign the printer a static IP address like 192.168.1.100, then set the DHCP range to start at 192.168.1.101? Sorry to ask so many questions, I'm not a network expert and I didn't think this printer would be such a pain to configure.
    Cheers,
    R

  • Re-order components in JPanel using Drag and Drop

    Hi,
    I have a JPanel that contains some more JPanels (the Layout is GridBagLayout - one column, each row - 1 JPanel). I would like to drag one JPanel (1) and after dropping it on some other JPanel (2), the (1) should be inserted at (2)'s position.
    I really can't get the idea from sun's tutorials :(

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class DragTest extends JPanel
        public DragTest()
            setLayout(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.insets = new Insets(5,5,5,5);
            gbc.weighty = 1.0;
            gbc.weightx = 1.0;
            gbc.fill = GridBagConstraints.BOTH;
            gbc.gridwidth = GridBagConstraints.REMAINDER;
            for(int j = 0; j < 4; j++)
                JPanel panel = new JPanel(new BorderLayout());
                panel.setBorder(BorderFactory.createEtchedBorder());
                panel.add(new JLabel("panel " + (j+1), JLabel.CENTER));
                add(panel, gbc);
        public static void main(String[] args)
            DragTest test = new DragTest();
            DragListener listener = new DragListener(test);
            test.addMouseListener(listener);
            test.addMouseMotionListener(listener);
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(test);
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
    class DragListener extends MouseInputAdapter
        DragTest dragTest;
        Component selectedComponent;
        GridBagConstraints constraints;
        Point start;
        boolean dragging;
        final int MIN_DRAG_DISTANCE = 5;
        public DragListener(DragTest dt)
            dragTest = dt;
            dragging = false;
        public void mousePressed(MouseEvent e)
            Point p = e.getPoint();
            Component[] c = dragTest.getComponents();
            for(int j = 0; j < c.length; j++)
                Rectangle r = c[j].getBounds();
                if(r.contains(p))
                    selectedComponent = c[j];
                    start = p;
                    dragging = true;
                    break;
        public void mouseReleased(MouseEvent e)
            if(dragging)  // no component has been removed
                dragging = false;
                return;
            Point p = e.getPoint();
            if(!dragTest.getBounds().contains(p))  // out of bounds
                // failed drop - add back at index = 0
                dragTest.add(selectedComponent, constraints, 0);
                dragTest.revalidate();
                return;
            Component comp = dragTest.getComponentAt(p);
            int index;
            if(comp == dragTest)
                index = getDropIndex(dragTest, p);
            else  // over a child component
                Rectangle r = comp.getBounds();
                index = getComponentIndex(dragTest, comp);
                if(p.y - r.y > (r.y + r.height) - p.y)
                    index += 1;
            dragTest.add(selectedComponent, constraints, index);
            dragTest.revalidate();
        private int getDropIndex(Container parent, Point p)
            Component[] c = parent.getComponents();
            for(int j = 0; j < c.length; j++)
                if(c[j].getY() > p.y)
                    return j;
            return -1;
        private int getComponentIndex(Container parent, Component target)
            Component[] c = parent.getComponents();
            for(int j = 0; j < c.length; j++)
                if(c[j] == target)
                    return j;
            return -1;
        public void mouseDragged(MouseEvent e)
            if(dragging)
                if(e.getPoint().distance(start) > MIN_DRAG_DISTANCE)
                    // save constraints for the drop
                    GridBagLayout layout = (GridBagLayout)dragTest.getLayout();
                    constraints = layout.getConstraints(selectedComponent);
                    dragTest.remove(selectedComponent);
                    dragging = false;
                    dragTest.revalidate();
    }

  • HT4356 printing page from facebook using picture and airprint page in upper left quadrant with words and margin cut off

    I have a ipad 4 with 6700 hp printer. I was told by support that the way to print a page from facebook was to take a picture of the page and then print the picture. When I do this the picture is printed in the upper left hand quadrant with part of the wording cut off. Is the only or best way to print from facebook and how can I fix the location of the print. Seems Hoaky to me
    Luther288

    Well after weeks of anguish, trips to the apple store (not very professional ), calls to Apple support (no help), calls to HP support, they transfered me to airprint support who actually told me how to fix my problem. For an HP printer download from the app store HPAIO remote print. You have to search on AIO remote print. Installed this app and now I can make the print work like I would like. Good luck

Maybe you are looking for

  • Creating a User Table via DI API

    Hi all, I'm using SAP Business One 2004A (6.70.185) SP: 00 PL: 07 and corresponding SAP Business One DI API 2004 I want to create a user table. I try to create it this way: I have two functions First function to create the table Private Function AP_A

  • MIRO document number created

    All, I have a PR that was created in USD and adopted to a PO in EUR.  When I attempt to voucher an invoice against the PO in MIRO when I hit save no document number is created.  In MIRO the system is attempting to pay in EUR and have a green light fo

  • Almost there... need IP printer help.

    I've got 7.5.5 running on my 6116CD. I've got it seeing my Windows LAN and establishing an IP address. How do I get it to add a network (IP) printer?

  • Stat. Delivery Date SLFDT not updated in ME21N

    Hello. We have updated SAP from 4.6C to ECC 6.0 and now SLFDT is not filled when creating PO (ME21N). Not first time and not when delivery date is changed (and not printed). Does anyone have an idea on where to look/debug? Where in the code is this f

  • Can I produce a new sequence in Premiere Elements 7

    I bought Premiere Elements 7 with 15 class licences for my students. I really admire the Elements 7 and very happy to be able to present this affordable and yet so efficient program to my students. There's only one thing I really miss: how can I prod