Swing layout books ?

Hi,
We are a small group of developers and have written quite a lot of Java apps and GUIs, but seems to struggle sometimes getting good layouts on forms etc that we are designing. We obviously know about the different layout managers but i'm not sure we're using them fully or really know them inside out. What we're looking for is more information about how to get the best layouts, tips and tricks, or a complete treatise on the layout managers.
Can anyone recommend a good book on using Swing layout managers, and/or general GUI design principles ? The Sun tutorial is a pretty good start, but is there anything else ?
Many thanks
Alistair

hi,
Professional Java Programming in this link,(but not free download)
http://www.amazon.com/Professional-Java-Programming-Brett-Spell/dp/186100382X

Similar Messages

  • Unable to run jar file without lib folder containing swing-layout-1.0.jar

    I have done my project through NetBeans 5.0. Eventhough I have copied my lib foloder containing swing-layout-1.0.jar inside my project.jar, I am still unable to run my project.jar in other systems, it is creating an error as Could not find the main class. Program will exit. But if I copy the lib foloder containing swing-layout-1.0.jar in the same path as the project.jar, then my project.jar is running.
    But I want to give only the project.jar for other users and not also lib foloder containing swing-layout-1.0.jar each time.
    Could someone please help me with this.

    When you develop GUI applications using the Netbeans you may endup using netbeans specific jar files in your auto generated code.
    And when you build jar files with netbeans it copy the third party jar files used in a application in to a lib folder in the same directory as the jar file of your project. And then set a class path entry to those jar files in your project jar file's manifest file.
    So if you want to redistribute the package you have to redistribute your jar file and every thing in the lib folder in with the same directory structure.
    If you want to change the structure you will have to change the class path to suit the new structure.

  • Swing Layouts

    Why is laying out component sizes in Swing so incredibly opaque?
    Each time I build a swing interface it seems to be a series of visual compromises, and ending up in more TLOC than any other part of even a complex application. Changing one value seems to always mess up everything else or have unexpected side-effects! Half the time, changing the most obvious values have no effect at all. I frequently end up just clearing out ALL layout hints/settings from the UI and starting from scratch with a GridBagLayout just to get something fairly sensible. Yes I am frustrated.
    If any part of the increasingly wonderful java platform needs a major review, then it is the Swing layout APIs or at least the documentation of the exact behaviour and dependencies of methods that influence sizes.
    Either I am stupid (which I would be most willing to accept), or component layout/orientation/sizing/behaviour is very, very far from intuitive.
    I'd love to become a Swing-super-guru-expert, but as I am expected to be an expert on so many other things, I simply do not have the time to spend on it. I believe that it would be much better for the platform as a whole if the UI platform was made more intuitive or at the very least much better documented.
    I am seriously considering moving to SWT, as I just don't have the time or energy to figure all this out.
    /k1

    Oh btw - all the GUI editors I've ever used tend to compound the problems by introducing their own
    quirks, dependencies and restrictions! That's been my experience to date which is why I've steered clear of them.
    As far as swing architecture not being mature. I think the architecture gives you the building blocks, from there any layout mangers can be created. Maybe Sun could provide a few more LayoutManagers but I suspect their tactic is to provide the minimum from which you can do everything so keeping the API size down.
    So don't restrict yourself to those available in the JDK. Have a google and get some freebies. There are all sorts of alternative Layouts there. The fact that these are freely available elsewhere is quite likely why SUn haven't bothered to introduce more themselves some that spring to mind are TableLayout, GridLayout, ProportionalLayout, LabelledLayout
    To my mind it's the beauty of swing that allows it to be so easily extended in this way.
    SpringLayout came in in JDK1.4 http://www.onjava.com/pub/a/onjava/2002/09/11/layout.html but I'm not familiar with that as yet as I write systems that must be JDK1.3 compatible. It looks like a better replacement for GridBagLayout there are probably alternative versions of this to be found on the web..

  • Help with Fixed layout book.

    Recently uploaded a fixed layout book to apple. It was rejected, and as usual we received a onliner from Apple - (blurry, pixelated, split across page breaks, etc.) The book is 150dpi and meets all Apple's guidlines. Any suggestions on what else we can try? The book has art running across 2 pages. Is this not allowed?

    Okay, after taking a look at the book on my iPad, and digging into the epub file on my Mac, I have a couple of ideas as to why it wasn't approved (and, yes, I'd agree, the one-liner from Apple could have been more specific).
    First, on my iPad, the book is not actually opening as a fixed layout book. It's opening as a regular book with your images flowing as text. With the images flowing as they are, many are browen across page boundaries (as you'd see in, say, MS Word, when an image is pasted across a page break), and this is probably why Apple mentions pages being split. In digging into the epub file I didn't see a com.apple.ibooks.display-options.xml file, which is where you specify various features for the book, including fixed-layout.  You need this file in the META-INF folder. 
    The second issue is actually much larger, and likely the reson Apple responded as they did. Each page in your book is stored as one big jpeg containing both graphics and text (sort of like a PDF), and each xhtml page merely inserts that image in the flow of your book. Apple requires that images not contain text, as this makes it impossible for readers to search the contents or use other features of iBooks such as the dictionary and copy'n'paste.  Text embedded in an image does not scale when zoomed in the same way that standalone text is able to scale and be re-rendered as a true font.
    I think you'll need to readdress how your pages have been laid out. Separate the text from the graphics and treat them as independent objects in your HTML and CSS. You might be able to get away with removing all the text from each of your jpeg images and still having "full bleed images" that are simply missing all the text, then layering in the text via HTML.
    Hope that helps!

  • Swing layout error

    i have posted this in the jdbc forum but i have not recieved any responsed yet so im posting it here in the hope that one of you might
    have a solution.
    I searched this forum, and i was surprised to find that none had this problem. I ll get to the point.
    I am using netbeans, so i downloaded the mysql driver , added it to the project library and compiled and ran my program . I did not have any problems.
    so i triedt to run the app on a different machine and it gave me the
    popular swing layout error. I fixed that error. by adding some lines to the xml file mentioned in the netbeans faq.
    Now it gives me another popular error when i try to run the .jar file from command line on the same machine i developed the app
    the errror is
    System Exception Output : com.mysql.jdbc.Driver
    is there a way to avoid this error like the swing layout error
    thanks in advance

    So, nothing whatsoever to do with a Swing layout error, then :o)

  • Please suggest some swing/bean book(Beginer free downloadable)

    Please suggest some dedicated swing/bean book(free downloadable)
    as I am at beginer level.
    It would be nice if it covers all major topics and suits quick
    understanding.

    Good starting place...
    http://java.sun.com/docs/books/tutorial/uiswing/
    and here...
    http://developer.java.sun.com/developer/onlineTraining/GUI/Swing1/shortcourse.html
    then here...
    http://developer.java.sun.com/developer/onlineTraining/GUI/Swing2/shortcourse.html

  • Fixed-layout books must supply a landmarks

    How to resolve this error.
    I am uploading fixed layout epub3 file to itunes connect.
    Fixed-layout books must supply a landmarks

    Maybe I did not explain correctly. let me try again.
    The error is 5107 Landmarks, the link with info I found mentions the same error but instead of landmarks it says guide.
    I did find a sample for using the Landmarks code
    <nav epub:type="landmarks"> <h2>Guide</h2> <ol> <li><a epub:type="toc" href="#toc">Table of Contents</a></li> <li><a epub:type="loi" href="content.html#loi">List of Illustrations</a></li> <li><a epub:type="bodymatter" href="content.html#bodymatter">Start of Content</a></li> </ol> </nav>
    what is confusing me is this book is a fixed layout picture book with no TOC, no tables. Do I leave my guide as is?
    <guide>
        <reference type="cover" title="Cover" href="html/cover.html" />
        <reference type="text" title="Page1" href="html/page1.html" />
    </guide>
    and add the landmark code in the content.opf
    sample code - landmark
    <nav epub: type="landmarks"> <h2>Guide</h2> <ol> <li><a epub type=toc href=toc"> Table of Contents</a></li>
    <a epub:type="loi" href="content.html#loi">
    List of Illustrations</a></li> <li><a epub:type="bodymatter" href="content.html#bodymatter">Start of Content</a></li> </ol> </nav>
    add it this way?
    <nav epub: type="landmarks">
    <h2>
    <reference type="cover" title="Cover" href="html/cover.html" />
        <reference type="text" title="Page1" href="html/page1.html" />
    </h2>
    what do I do here?
    <a epub:type="loi" href="content.html#loi">
    List of Illustrations</a></li> <li><a epub:type="bodymatter" href="content.html#bodymatter">Start of Content</a></li> </ol> </nav>
    Any help?
    R

  • Swing layout/size problem with JFrame and JApplet.

    I have a class that extends a JFrame, the classes layout is BorderLayout. I then have a class that extend JApplet, this classes layout is GridBagLayout (this class has a JTabbedPane - which contains JPanels). The problem I'm having is no matter how big I make the size of the applet or frame (using setSize), the applet/frame stays the same size - no matter how large I make it.
    Can anyone please help?
    Thanks,
    dosteov

    Here is the basic code:
    Thanks in advance,
    dosteov
    public class EADAdm extends JApplet
    EADAdmFrame theFrame = new EADAdmFrame(this);
         public void init()
              // Take out this line if you don't use symantec.itools.net.RelativeURL or symantec.itools.awt.util.StatusScroller
    //          symantec.itools.lang.Context.setApplet(this);
              // This line prevents the "Swing: checked access to system event queue" message seen in some browsers.
              getRootPane().putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);
              // This code is automatically generated by Visual Cafe when you add
              // components to the visual environment. It instantiates and initializes
              // the components. To modify the code, only use code syntax that matches
              // what Visual Cafe can generate, or Visual Cafe may be unable to back
              // parse your Java file into its visual environment.
              //{{INIT_CONTROLS
              getContentPane().setLayout(new GridBagLayout());
              setEnabled(false);
              getContentPane().setBackground(java.awt.Color.lightGray);
              setSize(800,800);
              getContentPane().add(AdmTab, new com.symantec.itools.awt.GridBagConstraintsD(0,1,2,1,0.5,0.5,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.HORIZONTAL,new Insets(3,12,4,14),120,120));
              AdmTab.setFont(new Font("Dialog", Font.PLAIN, 12));
              titleLbl.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
              titleLbl.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
              titleLbl.setText("EAD Administration");
              getContentPane().add(titleLbl, new com.symantec.itools.awt.GridBagConstraintsD(0,0,1,1,0.0,0.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.NONE,new Insets(12,36,0,0),307,15));
              titleLbl.setForeground(java.awt.Color.blue);
              titleLbl.setFont(new Font("Dialog", Font.BOLD, 15));
              exitBtn.setText("Exit EAD Administration");
              exitBtn.setActionCommand("Exit EAD Administration");
              getContentPane().add(exitBtn, new com.symantec.itools.awt.GridBagConstraintsD(0,2,2,1,0.0,0.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.NONE,new Insets(6,371,10,14),66,8));
              exitBtn.setFont(new Font("Dialog", Font.PLAIN, 12));
         //theFrame.setVisible(false);
         login();
         AdmTab.addTab("Administration", new LogoPanel() );
         userPanel = createUserPanel();
         AdmTab.addTab("Edit Users", userPanel );
         fpoPanel = createFPOPanel();
         AdmTab.addTab("Edit FPO", fpoPanel );
         regulationPanel = createRegulationPanel();
         AdmTab.addTab("Edit Regulations", regulationPanel );
         rolloverPanel = createRolloverPanel();
         AdmTab.addTab("Rollover", rolloverPanel );           
              //{{REGISTER_LISTENERS
         SymMouse aSymMouse = new SymMouse();
              this.addMouseListener(aSymMouse);
              SymAction lSymAction = new SymAction();
              exitBtn.addActionListener(lSymAction);
              SymKey aSymKey = new SymKey();
              this.addKeyListener(aSymKey);
         theFrame.getContentPane().add(this);
    public class EADAdmFrame extends JFrame
    EADAdm theApplet;
    public EADAdmFrame(EADAdm theMainApplet)
              //{{INIT_CONTROLS
         //     theApplet = theMainApplet;
         //     this.getContentPane().add(theApplet);
              getContentPane().setLayout(new BorderLayout(0,0));
              getContentPane().setBackground(java.awt.Color.lightGray);
              setSize(1000,1000);
              setVisible(false);
         theApplet = theMainApplet;
              //{{REGISTER_LISTENERS
              SymWindow aSymWindow = new SymWindow();
              this.addWindowListener(aSymWindow);
              SymComponent aSymComponent = new SymComponent();
              this.addComponentListener(aSymComponent);

  • How do you add read aloud to a fixed layout book?

    I have seen some ibooks (childrens books) with read aloud abilities. I know you have to do some programming but what program do you use to edit the code, can you preview it in ibooks (on ipad) if you modify the code, and is there a non-programming way to add audio/speech to your ibooks through ibooks author? Does anyone know the process or what steps and programs needed to add the read aloud feature to an ibook? (I know there are many others out their who would like to know the answers to these questions). Thanks.
    Also, I have HD images (2000x1462) for my ibook in ibooks author and when I preview it on an ipad 2, it downsizes it to regular quality (like 1400x1200 ish). Since I don't yet own an iPad 3, do the images stay HD quality when an ibook (from ibooks author) is viewed on an iPad 3?

    Okay, I just finished building my Ibook in Ibooks Author. I tested one of the free ibooks (Peter Rabit) and liked how it reads to you. I have read many articles and other posts here on Apple.com and everyone seems to want to add this read aloud feature. I have the Fixed Layout EPUBs Miniguide and iBookstore Asse Guide 4_8 and even though the miniguide explains things step by step, its like reading Greek. I am new to programming. Since I assume you are an expert, what I need is help getting started. I'm pretty good at figuring things out, I just need to get a jumpstart as fast as possible. (I don't want to spend a whole month trying to add this read aloud feature).
    1. I have a finished book but its not looking like the fixed layout kids books I see on ibooks. Is there a simple way to just tell ibooks its a fixed layout and get rid of the textbook features without using programming? (I know there are people out there who agree with me)
    2. I know that I need a XML SMIL compatable text editor (BBedit is the only one I heard is free and good). But where do I begin? Is there some kind of template of code where I just add in the code to get the book to read from audio files? If I edit the epub file, will this book still be able to be sent to the iPad through ibooks Author for a preview?
    3. I am familiar with Audacity so the audio part is doable. But the coding is scaring me. To add a word by word reading for the ibook requires more programming.
    4. Tell me a short list of what I need to do in order. I have all this information but its overwhelming because I hate programming. (I tried making an iphone app and gave up because it required Xcode, which is way out of my league). I don't know where to start from my finished iBook so what is the next thing I need to do?
    Thanks Jessica

  • Dealing with Swing Layouts

    I have a collection of small panels with fixed size (around 50x50), and a main panel with size around 600x480.
    At run time I need to show this collection of panels on my main panel.
    Based on your experience, what would be the best layout to show them on my main panel?
    I have tried setting up a GridLayout on my main panel, but my small panels always got resized to fill my main panel, no matter how I tried to stablish the number of rows (length % rows == 0? 0 : 1 + len depending on my collection size.
    Also tried with a flowlayout, but when I added a JSCrollPanel, instead of adding new rows, my scrollpanel kept adding them on the same line :( I even enforced my scroller to
    Is this the correct behaviour? Am I doing something wrong? (I'm sure I do :))
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.GridLayout;
    import java.util.List;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER;
    public class JClass extends JFrame{
        private JPanel panel;
        private JScrollPane scroll;
        protected JClass() {
            panel = new JPanel();
            scroll = new JScrollPane(panel);
            scroll.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER);
            JPanel menu  = new JPanel();
            JButton but  = new JButton("show");
            but.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                   display(5);
            BorderLayout layout = new BorderLayout();
            FlowLayout layout2 = new FlowLayout();
            layout2.setAlignment(FlowLayout.LEFT);
            panel.setLayout(layout2);
            menu.add(but);
            this.setPreferredSize(new Dimension(640,480));
            this.setLayout(layout);
            this.add(scroll, BorderLayout.CENTER);
            this.add(menu,BorderLayout.WEST);
            pack();       
        public void display(int n){
            JButton button;      
            for(int i = 0; i < n; i++){
                button = new JButton();
                button.setPreferredSize(new Dimension(30,30));
                this.panel.add(button);
            this.validate();
            this.repaint();     
        public static void main(String args[]) {
            JClass app = new JClass();
            app.setDefaultCloseOperation(EXIT_ON_CLOSE);
            app.setVisible(true);
    }

    Thanks Camickr.
    And just for the sake of it, do you think is there a way to do it with GridLayout? I mean, fixing the number of columns to three, but without resizing the small panels I will be adding. Maybe by fixing the preferredSize of the panel with the gridlayout to the small panels width * 3 + something?
    In my previous iteration I tried it but this content panel would always take my maximum space, thus expanding my small panels... :(

  • Swing Layout for different screen resolution

    Hi All,
    I am developing an application which will always run in a FULL SCREEN mode.
    I intend to make it working on all screen sizes (resoultions) and on different OS and devices.
    Since I am new to Swing, could anyone of you suggest a good layout manager to manage the components?
    I am using NetBeans 6.8 (which uses a GroupLayout) for designing the GUI but when I change the screen resolution, the arrangement is all messed up.
    Also, I am not able to design my application's GUI using NetBeans GUI builder as there is noway I can get an idea of how things will look like in the EXTENDED_BOTH state.
    It will be very helpful if anyone could suggest..
    Thanks!

    The entire point of Swing LayoutManagers is to get a (reasonably) consistent layout across different resolutions, window sizes, platforms, etc. Of course, different window sizes and aspect ratios will affect things slightly, but any LayoutManager properly used will do the job you're describing.
    As for which LayoutManager to use, I think that's a misleading question because it's not uncommon to use multiple LayoutManagers for a single screen. But in my experience it's possible to do 95% of what you want using GridBagLayout and a properly nested hierarchy of JPanels. GridBagLayout is a pain to get used to (caution against re-using GridBagConstraints), but once you do it's amazing what you can get out of it.

  • Swing layout

    in AWT, the layout was control by the GridBag Layout and constraints, how can i control the layout of the button in swing to the layout that i want it to be?

    hi,
    everyone has this problem at first :) ...
    you need to set your Layout to null rather than GridBag or whatever...
    then on each component (button,label etc) you can call the .setBounds() method.
    this takes 4 ints i think...x,y,width,height so you can positition the things wherever you want then
    alexs

  • Aperture doesn't save book layout, book disappears

    I start to create a book in Aperture. Then I quit Aperture. When I relaunch Aperture, the book no longer appears in the project. However, if I explore the database using "show package contents," I can see a file with the book's name. Why won't Aperture save my book layout? Why does the file appear to exist, yet the book doesn't appear in the project? Can I recover the in-progress layout?

    Yep, that did it! Rebuilt the library as instructed, and the book layout reappeared in the project. Many thanks for the simple and effective solution!

  • Swing layout + awt paintcomponent issue

    Hi guys
    I have a small issue while creating my very first application, or better, creating its GUI.
    i would like to insert in a jpanel three JTextFields on top of the panel where the user could eventually enter data, once the data are entered, a paintComponent displays the results beneath it using graphics, with simple drawLine from the paintComponent method.
    The problem is that i dont succeed to design a "good looking" panel where i can combine the organized layout of the fields and the space left for the lines of the paintcomponent method
    i can enter the fields and the lines like this:
    //contstructor definition
    add(field10);
    add(field2);
    add(field3);
    //eof constructor definition
    public void paintComponent(Graphics g){
    g.drawString("ciao"20,20);
    }but i cannot do this...
    //contructor definition
    setLayout(new GridLayout(3,2));
    add(field10);
    add(field2);
    add(field3);
    //eof constructor definition
    public void paintComponent(Graphics g){
    g.drawString("ciao"20,20);
    }because the GridLayout will occupy the whole panel and the size of the fields will be huge, so that there will be no space left for the paintComponents.
    What i would like to do is to let the GridLayout to occupy only the upper part of the JPanel so that the part below could be left to graphic content.
    I hope it sounds clear.
    Thank you
    Take care
    Edited by: classboy on Sep 8, 2009 9:28 PM

    One of the keys to understanding use of layout managers with Java is that they can be nested. More accurately, you can next Components and have each one use its own layout manager. One solution to your problem is to have a main JPanel use a BorderLayout, then add another JPanel, say called textFieldPanel that uses GridLayout and holds the three JTextFields. This panel can be added to the main panel BorderLayout.SOUTH or .NORTH, depending on your preference, and then have a third JPanel a drawingPanel that overrides paintComponent and displays the graphics, and add this to the main JPanel BorderLayout.CENTER.
    The iterations possible here are close to endless.
    Much luck.

  • Using Java swing layout

    I'm rather new at this and i'm having trouble creating my desired layout, actually i'm having trouble picking my desired layout.
    this is how i'd want my program to look...
    name place time address
    mary Hos. 12:00 70 sine st. JButton
    Kay Sch. 1:00 13 cos st. JButton
    JButton("OK")
    Hopefully you have some idea of where i'm heading. I don't want a table because i want this to be uneditable so i'm doing with with panels. the spots marked "JButton" are of course Buttons (their functions are not important). at the bottom is a single "OK" Jbutton that is aligned with the other JButtons above it.
    my issues are as follows,
    I have just 4 title labels (name, place, time, address) but there are essentially 5 components that make up the body of the list (all the others + a JButton). can anyone tell me what Layout i should use?? i've tried GridBag but i'm having trouble with the JButtons. And How in the world can i place the final OK button?

    I suppose those things were supposed to be arranged in columns? Then you want a JTable. And if you want it to be uneditable, then just make it uneditable. There's no need for enormous workarounds.

Maybe you are looking for

  • JDOQL - isEmpty() on variable field not working?

    I have a class X that has a Set of Filters. Each Filter has a Set of elements. For this example, I'll use CommodityFilter that has a Set of Commodities. Here is some example code of the example: public class X { // type: Filter private Set filters =

  • F.C.E. Difficulties in saving to DVD - PAL

    Having looked through this section and telling Apple that it was impossible to save via anything to DVD on the Pal side of the pond I reverted to PRINTING TO VIDEO and saving back to tape. The idea being, then to send that tape source to a combi Pana

  • Change TS Labview Server from Labview OI?

    I have tried the NI recommended way to select the LabView server programatically from TestStand which works fine e.g.  RunState.Engine.GetAdapterByKeyName("G Flexible VI Adapter").AsLabVIEWAdapter.SetServerInfo(LabVIEWServer_RTEServer, "C:\\Program F

  • 2011 27" iMac is dim on the RIGHT side of the screen

    Just like the countless other people with the 2009 and 2011 27" iMacs, it seems the backlight is not functional on the right half of my screen.  All of the other posts I've searched for seem to point to the left side being the primary issue, mine is

  • How to completely flatten pdf as if it was a paper scan?

    Can someone tell me how I can completely flatten a pdf, just as if I had scanned a paper? So there will not be any data attached to the file? I kwow how to flatten a pdf and to remove as many data as possible (optimize in the document and advanced me