JFrame layout help

Hi!
I cant find any layout that fits me...
I want to set a layout on a JFrame so that every component I place on the frame will be placed in a vertical line. The components also have to be as far up as possible (not like GridLayout) and to the left.
Thanks!

Hi, now I get the layout. But it gets very small. Why is this?
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTree;
public class TestCheckboxTree extends JFrame
     public TestCheckboxTree()
          super("Testing Checkboxes on JTree!");
          JScrollPane scrollpane = new JScrollPane();
          scrollpane.setPreferredSize(new Dimension(300, 300));
          scrollpane.setAlignmentX(LEFT_ALIGNMENT);
          JPanel panel = new JPanel();
          panel.setBackground(Color.WHITE);
          panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
          JTree tree = CheckboxTree.makeCheckTree(new FolderTree("/home/"));
          JTree tree2 = CheckboxTree.makeCheckTree(new FolderTree("/home/rejeep/programming"));
          panel.add(tree);
          panel.add(tree2);
          scrollpane.getViewport().add(panel);
          add(scrollpane);
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          setSize(500, 500);
          setVisible(true);
     public static void main(String args[])
          new TestCheckboxTree();
}

Similar Messages

  • Creating a purchase order form that has a flowable layout" Help Tutorial

    Regarding the "Creating a purchase order form that has a flowable layout" Help Tutorial,  I can't seem to get the data to pull in for just the PO in question, is there a secret?
    Ideally, it should create one form for each PO with the detail lines for each PO on the individual forms.  Can we do this?
    Many thanks!

    Hi
    If the smartform purchase order is not available in your system
    means you can download the form IDES and you can upload the form in ur ecc 6.0 system.we faced a similar kind of problem in our system and we did as i said.
    Once you uploaded the things you can easily view the form interface and rest of the things related to smartforms.
    Thanks and Regards
    Arun Joseph

  • How can I change the Jframe Java help Icon

    How can I change then Jframe Java help Icon?.
    I am using then HelpSet class and HelpBroker.
    I want to change the java help icon
    Any Idea? thanks. ...

    It can be done, but it's ugly...
    Add in a listener to your topmost JFrame to sense when the focus is lost, since this happens when a help window comes up. When the focus leaves the main window, check all the windows that are up to see if one is a help window. If so, this will give you a reference to the help window and you can drill down to change what you want.
    Here's an example that changes the icon and removes the borders from the javahelp buttons.
    WindowListener wndCloser = new WindowAdapter() {
              //A necessarily roundabout method to affect
              //look and feel aspects of the javahelp viewer.
              //(there is no way to get at these components directly.)
              //When the main frame loses focus, it may be because
              //the help viewer was brought up. Look through all
              //the current frames to see if one is a help viewer.
              //If it is, change the look of the help viewer
              //to what we want.
              Frame m_helpFrame = null;
              public void windowDeactivated(WindowEvent e) {
              if (m_helpFrame != null)
                   return;
              Frame[] frames = getFrames();
              for (int k = 0; k < frames.length; k++) {
                   if (!(frames[k] instanceof JFrame))
                   continue;
                   JFrame jf = (JFrame)frames[k];
                   if (jf.getContentPane().getComponentCount()==0)
                   continue;
                   Component c = jf.getContentPane().
                   getComponent(0);
                   if (c == null || !(c instanceof JHelp))
                   continue;
                   m_helpFrame = jf;
                   //now that we know the Frame, we can change the title icon
                   final Image image2 = <your icon here>
                   m_helpFrame.setIconImage(image2);
                   JHelp jh = (JHelp)c;
                   for (int s=0; s<jh.getComponentCount(); s++) {
                   c = jh.getComponent(s);
                   if (c == null || !(c instanceof JToolBar))
                        continue;
                   JToolBar jtb = (JToolBar)c;
                   //now that we've accessed the toolbar, we can
                   //modify the look of the buttons.
                   for(int i=0; i<jtb.getComponentCount(); i++) {
                        Component comp = jtb.getComponentAtIndex(i);
                        if(comp instanceof JButton) {
                        JButton button = (JButton)comp;
                        button.setBorder(null);

  • Box layout help

    i know how to use a box layout on panels but i am having a problem applying box layout on jframe,
    what i do basicaly is extends jframe first and then in the constructor i put setLayout(new BoxLayout(this,BoxLayout.X_AXIS));
    it gives an error that box layout cant be shared...this method works with all other layouts...
    please help me and please dont tell me to go read the sun online tutorials...

    To speak truely. All the j2se default layout manager will be replaced by the default layoutmanager in NetBeans ---group layout manager.
    I suggest you download a NetBeans IDE and start working with the new layout manager.

  • JPanel and Layout help

    Hi all.
    I need some help with JPanel. I am trying to attach diffrent components using different Layout managers but when I try to attach two different gridLayout Panels it ignores the first one and only shows the last one attached. I am not sure why. I using a different form of GridLayout because I want to show check boxes and radioButtons. I am trying to get a certain look.
    Any help would be appreciated. Thanks for your help and time in advance.
    // FileName: WindowsClass.java
    import javax.swing.*;
    import java.awt.*;
    import java.util.*;
    public class WindowsClass extends JFrame
         //initialize combo radio button vars
         private JPanel selectPanel1;
         private JTextField enterName;
         private JLabel nameLabel;
         private JPanel selectPanel2;
         private JLabel processorLabel;
         private JComboBox processorCB;
         private String pCB[] = { "Pentium 4", "Celeron", "AMD", "Intel Centrino"};
         private JLabel hardDiskLabel;
         private JComboBox hardDiskCB;
         private String hdCB[] = { "30 GB", "40 GB", "60 GB" };
         private JLabel pSpeedLabel;
         private JComboBox pSpeedCB;
         private String psCB[] = { "1.8 GHz", "2.2 GHz", "2.8 GHz" };
         private JPanel selectPanel3;
         private JRadioButton ramRB256;
         private JRadioButton ramRB512;
         private JCheckBox addAccessory;
         // constructor          
         public WindowsClass()
              super( "Computer Configuration Window" );
              selectPanel1 = new JPanel();
              selectPanel1.setLayout( new FlowLayout() );
              nameLabel = new JLabel( "Please enter your name: " );
              enterName = new JTextField(10);     
              selectPanel1.add( nameLabel );
              selectPanel1.add( enterName );
              add( selectPanel1, BorderLayout.NORTH );
              selectPanel2 = new JPanel();
              selectPanel2.setLayout( new GridLayout( 3, 2, 5, 5 ) );
              processorLabel = new JLabel( " Processor" );
              // setup Processor JComboBox and display 4 rows
              processorCB = new JComboBox( pCB );
              processorCB.setMaximumRowCount( 4 );
              selectPanel2.add( processorLabel );
              selectPanel2.add( processorCB );
              hardDiskLabel = new JLabel( " Hard Disk" );
              // setup Hard Disk JComboBox and display 3 rows
              hardDiskCB = new JComboBox( hdCB );
              hardDiskCB.setMaximumRowCount( 4 );
              selectPanel2.add( hardDiskLabel );
              selectPanel2.add( hardDiskCB );
              // setup Processor Speed JComboBox and display 3 rows
              pSpeedCB = new JComboBox( psCB );
              pSpeedCB.setMaximumRowCount( 3 );
              pSpeedLabel = new JLabel( " Processor Speed " );
              selectPanel2.add( pSpeedLabel );
              selectPanel2.add( pSpeedCB );          
              selectPanel3 = new JPanel();
              selectPanel3.setLayout( new FlowLayout() );
              // setup RAM RadioButtons
              ramRB256 = new JRadioButton( "256 MB", false );
              ramRB512 = new JRadioButton( "512 MB", false );
              selectPanel3.add( ramRB256 );     
                 selectPanel3.add( ramRB512 );
         //This is where the prob is. the last added panel shows up ignoring the previously added panel
              //add( selectPanel3 );
              add( selectPanel2 );
              add( selectPanel3 );
         } // end of contructor WindowsClass()
    } // end of WindowsClass
    // FileName: WindowsClassMain.java
    // Compile: javac WindowsClassMain.java WindowsClass.java
    import javax.swing.JFrame;
    public class WindowsClassMain extends JFrame
         public static void main( String args[] )
              WindowsClass window = new WindowsClass();
              window.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              window.setSize( 450, 250 );
              window.setVisible( true );
         } //end of main()
    } // end of WindowsClassMain class

    Thanks a lot. It did work but now I am running into another problem.
    I am trying to attach more stuff to my selectPanel3 but it just adds stuff right after another and runs out the window. I want Additional Accessories checkBoxes to go on the next page but it shows right next to the RAM radioButtons.
    Please help.
    Thanks a bunch for your time.
    // FileName: WindowsClass.java
    import javax.swing.*;
    import java.awt.*;
    import java.util.*;
    public class WindowsClass extends JFrame
         //initialize combo radio button vars
         private JPanel selectPanel1;
         private JTextField enterName;
         private JLabel nameLabel;
         private JPanel selectPanel2;
         private JLabel processorLabel;
         private JComboBox processorCB;
         private String pCB[] = { "Pentium 4", "Celeron", "AMD", "Intel Centrino"};
         private JLabel hardDiskLabel;
         private JComboBox hardDiskCB;
         private String hdCB[] = { "30 GB", "40 GB", "60 GB" };
         private JLabel pSpeedLabel;
         private JComboBox pSpeedCB;
         private String psCB[] = { "1.8 GHz", "2.2 GHz", "2.8 GHz" };
         private JPanel selectPanel3;
         private JLabel ramLabel;
         private JRadioButton ramRB256;
         private JRadioButton ramRB512;
         private JLabel addAccessory;
         private JCheckBox inkJetPrinter;
         private JCheckBox iWLAN;
         // constructor          
         public WindowsClass()
              super( "Computer Configuration Window" );
              selectPanel1 = new JPanel();
              selectPanel1.setLayout( new FlowLayout() );
              nameLabel = new JLabel( "Please enter your name: " );
              enterName = new JTextField(10);     
              selectPanel1.add( nameLabel );
              selectPanel1.add( enterName );
              add( selectPanel1, BorderLayout.NORTH );
              selectPanel2 = new JPanel();
              selectPanel2.setLayout( new GridLayout( 3, 2, 5, 5 ) );
              processorLabel = new JLabel( " Processor" );
              // setup Processor JComboBox and display 4 rows
              processorCB = new JComboBox( pCB );
              processorCB.setMaximumRowCount( 4 );
              selectPanel2.add( processorLabel );
              selectPanel2.add( processorCB );
              hardDiskLabel = new JLabel( " Hard Disk" );
              // setup Hard Disk JComboBox and display 3 rows
              hardDiskCB = new JComboBox( hdCB );
              hardDiskCB.setMaximumRowCount( 4 );
              selectPanel2.add( hardDiskLabel );
              selectPanel2.add( hardDiskCB );
              // setup Processor Speed JComboBox and display 3 rows
              pSpeedCB = new JComboBox( psCB );
              pSpeedCB.setMaximumRowCount( 3 );
              pSpeedLabel = new JLabel( " Processor Speed " );
              selectPanel2.add( pSpeedLabel );
              selectPanel2.add( pSpeedCB );          
              selectPanel3 = new JPanel();
              selectPanel3.setLayout( new FlowLayout() );
              // setup RAM RadioButtons
              ramLabel = new JLabel( " RAM " );
              ramRB256 = new JRadioButton( "256 MB", false );
              ramRB512 = new JRadioButton( "512 MB", false );
              selectPanel3.add( ramLabel );
              selectPanel3.add( ramRB256 );     
                 selectPanel3.add( ramRB512 );
              addAccessory = new JLabel( "Additional Accessories" );
              inkJetPrinter = new JCheckBox( "Ink Jet Printer" );
              iWLAN = new JCheckBox( "Inbuilt Wireless LAN" );
              selectPanel3.add( addAccessory );
              selectPanel3.add( inkJetPrinter );
              selectPanel3.add( iWLAN );
              //add( selectPanel3 );
              //add( selectPanel2 );
              //add( selectPanel3 );
              getContentPane().add( selectPanel2,BorderLayout.WEST);
              getContentPane().add( selectPanel3,BorderLayout.EAST);
         } // end of contructor WindowsClass()
    } // end of WindowsClass

  • Problem with JFrame , please help !

    hello , all !
    I define a JFrame1 as ancestor
    I set the JFrame's contentPane Layout to borderLayout ,
    and add some component in south , north , and add a menu , in its constructor
    then I define a new JFrame2 inherit from JFrame1, I also add a Jpanel component
    to contentPane center in its constructor !
    but something a wrong , I can't see the Jpanel , only see the components which add in JFrame1?
    this is why ?
    thanks
    /* source code */
    public class JFrame1{
    public JFrame1(){
    try {
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    private void jbInit() throws Exception {
    contentPane = (JPanel) this.getContentPane();
    contentPane.setLayout(borderLayout1);
    statusBar.setBorder(BorderFactory.createEtchedBorder());
    statusBar.setText("Hello , Young follow! ");
    contentPane.add(statusBar, BorderLayout.SOUTH);
    toolbar = new Toolbar_DataEntry(this);
    contentPane.add(toolbar, BorderLayout.NORTH);
    menubar = new Menu_DataEntry(this);
    this.setJMenuBar(menubar);
    public class JFrame2 extends JFrame1 {
    public JFrame2() {
    try {
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    /**Component initialization*/
    private void jbInit() throws Exception {
    contentPane = (JPanel) this.getContentPane();
    JPanel bodyPane = new JPanel();
    bodyPane.setDataModule(queryDataSet1);
    queryDataSet1.Opendatabase();
    bodyPane.setBorder(null);
    this.setTitle("Frame Title");
    bodyPane.setBounds(new Rectangle(4, 5, 427, 114));
    contentPane.setPreferredSize(bodyPane.getPreferredSize());
    contentPane.setMinimumSize(bodyPane.getMinimumSize());
    Frame_Resize();

    The problem is that the constructor for JFrame2 does not automatically call the constructor for JFrame1. Therefore the JFrame1 constructor never gets called.
    You must do this yourself with the super() method.
    public JFrame2() {
    super();
    try {
    jbinit();
    catch( Exception e )
    e.printStackTrace();
    Remember that this rule applies to all descendent classes.

  • Drawing and some layout help for a simple control: thin lines and application start

    I am trying to create a new, simple control. The control should act as a grouping marker much like that found in the Mathematica notebook interface. It is designed to sit to the right of a node and draw a simple bracket. The look of the bracket changes depending on whether the node is logically marked open or closed.
    After looking at some blogs and searching, I tried setting the snapToPixels to true in the container holding the marker control as well as the strokewidth but I am still finding that the bracket line is too thick. I am trying to draw a thin line. Also, I am unable to get the layout to work when the test application is first opened. One of the outer brackets is cut-off. I hardcoded some numbers into the skin just to get something to work.
    Is there a better way to implement this control?
    How can I get the fine line drawn as well as the layout correct at application start?
    package org.notebook;
    import javafx.beans.property.BooleanProperty;
    import javafx.beans.property.IntegerProperty;
    import javafx.beans.property.SimpleBooleanProperty;
    import javafx.beans.property.SimpleIntegerProperty;
    import javafx.scene.control.Control;
    * Provide a simple and thin bracket that changes
    * it appearance based on whether its closed or open.
    public class GroupingMarker extends Control {
      private final static String DEFAULT_STYLE_CLASS = "grouping-marker";
      private BooleanProperty open;
      private IntegerProperty depth;
      public BooleanProperty openProperty() { return open; }
      public IntegerProperty depthProperty() { return depth; }
      public GroupingMarker(boolean open) {
      this();
      setOpen(open);
      public GroupingMarker() {
      open = new SimpleBooleanProperty(true);
      depth = new SimpleIntegerProperty(0);
      getStyleClass().add(DEFAULT_STYLE_CLASS);
      // TODO: Change to use CSS directly
      setSkin(new GroupingMarkerSkin(this));
      public boolean isOpen() {
      return open.get();
      public void setOpen(boolean flag) {
      open.set(flag);
      public int getDepth() {
      return depth.get();
      public void setDepth(int depth) {
      this.depth.set(depth);
    package org.notebook;
    import javafx.scene.Group;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.FillRule;
    import javafx.scene.shape.LineTo;
    import javafx.scene.shape.MoveTo;
    import javafx.scene.shape.Path;
    import com.sun.javafx.scene.control.skin.SkinBase;
    * The skin draws some simple lines on the right hand side of
    * the control. The lines reflect whether the control is considered
    * open or closed. Since there is no content, there is no
    * content handling code needed.
    public class GroupingMarkerSkin extends SkinBase<GroupingMarker, GroupingMarkerBehavior> {
      GroupingMarker control;
      Color lineColor;
      double shelfLength;
      double thickness;
      private Group lines;
      public GroupingMarkerSkin(GroupingMarker control) {
      super(control, new GroupingMarkerBehavior(control));
      this.control = control;
      lineColor = Color.BLUE;
      shelfLength = 5.0;
      thickness = 1.0;
      init();
      * Attached listeners to the properties in the control.
      protected void init() {
      registerChangeListener(control.openProperty(), "OPEN");
      registerChangeListener(control.depthProperty(), "DEPTH");
      lines = new Group();
      repaint();
      @Override
      protected void handleControlPropertyChanged(String arg0) {
      super.handleControlPropertyChanged(arg0);
        @Override public final GroupingMarker getSkinnable() {
            return control;
        @Override public final void dispose() {
        super.dispose();
            control = null;
        @Override
        protected double computePrefHeight(double arg0) {
        System.out.println("ph: " + arg0);
        return super.computePrefHeight(arg0);
        @Override
        protected double computePrefWidth(double arg0) {
        System.out.println("pw: " + arg0);
        return super.computePrefWidth(40.0);
         * Call this if a property changes that affects the visible
         * control.
        public void repaint() {
        requestLayout();
        @Override
        protected void layoutChildren() {
        if(control.getScene() != null) {
        drawLines();
        getChildren().setAll(lines);
        super.layoutChildren();
        protected void drawLines() {
        lines.getChildren().clear();
        System.out.println("bounds local: " + control.getBoundsInLocal());
        System.out.println("bounds parent: " + control.getBoundsInParent());
        System.out.println("bounds layout: " + control.getLayoutBounds());
        System.out.println("pref wxh: " + control.getPrefWidth() + "x" + control.getPrefHeight());
        double width = Math.max(0, 20.0 - 2 * 2.0);
        double height = control.getPrefHeight() - 4.0;
        height = Math.max(0, control.getBoundsInLocal().getHeight()-4.0);
        System.out.println("w: " + width + ", h: " + height);
        double margin = 4.0;
        final Path VERTICAL = new Path();
        VERTICAL.setFillRule(FillRule.EVEN_ODD);
        VERTICAL.getElements().add(new MoveTo(margin, margin)); // start
        VERTICAL.getElements().add(new LineTo(margin + shelfLength, margin)); // top horz line
        VERTICAL.getElements().add(new LineTo(margin + shelfLength, height - margin)); // vert line
        if(control.isOpen()) {
        VERTICAL.getElements().add(new LineTo(margin, height - margin)); // bottom horz line
        } else {
        VERTICAL.getElements().add(new LineTo(margin, height-margin-4.0));
        //VERTICAL.getElements().add(new ClosePath());
        VERTICAL.setStrokeWidth(thickness);
        VERTICAL.setStroke(lineColor);
        lines.getChildren().addAll(VERTICAL);
        lines.setCache(true);
    package org.notebook;
    import com.sun.javafx.scene.control.behavior.BehaviorBase;
    public class GroupingMarkerBehavior extends BehaviorBase<GroupingMarker> {
      public GroupingMarkerBehavior(final GroupingMarker control) {
      super(control);
    package org.notebook;
    import javafx.application.Application;
    import javafx.scene.Node;
    import javafx.scene.Scene;
    import javafx.scene.control.Label;
    import javafx.scene.control.TextArea;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.layout.VBox;
    import javafx.stage.Stage;
    public class TestGroupingMarker extends Application {
      public static void main(String args[]) {
      launch(TestGroupingMarker.class, args);
      @Override
      public void start(Stage stage) throws Exception {
      VBox vbox = new VBox();
      BorderPane p = new BorderPane();
      VBox first = new VBox();
      first.getChildren().add(makeEntry("In[1]=", "my label", 200.0, true));
      first.getChildren().add(makeEntry("Out[1]=", "the output!", 200.0, true));
      p.setCenter(first);
      p.setRight(new GroupingMarker(true));
      vbox.getChildren().add(p);
      vbox.getChildren().add(makeEntry("In[2]=", "my label 2", 100.0, false));
      Scene scene = new Scene(vbox,500,700);
      scene.getStylesheets().add(TestGroupingMarker.class.getResource("main.css").toExternalForm());
      stage.setScene(scene);
      stage.setTitle("GroupingMarker test");
      stage.show();
      protected Node makeEntry(String io, String text, double height, boolean open) {
      BorderPane pane2 = new BorderPane();
      pane2.setSnapToPixel(true);
      Label label2 = new Label(io);
      label2.getStyleClass().add("io-label");
      pane2.setLeft(label2);
      TextArea area2 = new TextArea(text);
      area2.getStyleClass().add("io-content");
      area2.setPrefHeight(height);
      pane2.setCenter(area2);
      GroupingMarker marker2 = new GroupingMarker();
      marker2.setOpen(open);
      pane2.setRight(marker2);
      return pane2;

    The test interfaces are already defined for you - the 3rd party session bean remote/local interfaces.
    It is pretty trivial to create implementations of those interfaces to return the test data from your XML files.
    There are a number of ways to handle the switching, if you have used the service locator pattern, then I would personally slot the logic in to the service locator, to either look up the 3rd party bean or return a POJO test implementation of the interface according to configuration.
    Without the service locator, you are forced to do a little more work, you will have to implement your own test session beans to the same interfaces as the 3rd party session beans.
    You can then either deploy them instead of the 3rd party beans or you can deploy both the test and the 3rd party beans under different JNDI names,and use ejb-ref tags and allow you to switch between test and real versions by changing the ejb-link value.
    Hope this helps.
    Bob B.

  • Newbie Layout Help Needed

    I am normally an After Effects and Premiere Pro user but have been forced to volunteer for help on a Dreamweaver project. 
    The site is built on the template: HTML, 1 column fixed, centered, header and footer.  I want to be able to insert a photo the width of the main column, 960 px I think.  Then, under that photo, I want to insert 4 photos with different widths, between 150 and 200 pixels wide.  I will need to update this from time to time and the quantity and sizes of the photos will be different each time.  If "Draw AP Div" worked like I expected it to, it would be simple: draw boxes and insert images.  However, as you know, it's not going to be that easy.  I have read the formatting101 page and searched the forum but I guess I don't know enough to know what to search for.
    Is there a way to place images in the way I want to?  Do I need a plug-in?   I need to where to start. 

    You don't need APDivs for this.  If you want the secondary images to be evenly spaced on the page, use CSS floats & margins.
    http://alt-web.com/DEMOS/3-CSS-boxes.shtml
    If you don't need them evenly spaced, simply insert optimized images into your layout.  Be sure to resize images beforehand in your graphics editor so that their combined widths will fit inside the layout.
    <p style="text-align"center">
    <img src="top-image.jpg" width="xx" height="xx" alt="description">
    </p>
    <p style="text-align:center">
    <img src="image1.jpg" width="xx" height="xx" alt="description">  
    <img src="image2.jpg" width="xx" height="xx" alt="description">  
    <img src="image3.jpg" width="xx" height="xx" alt="description">  
    <img src="image4.jpg" width="xx" height="xx" alt="description">
    </p>
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/

  • Button and image layout help.

    It is me again. I need some more help. I want to put the four buttons at the south border, and I want to put the image at the North Center. Now I want them obviously to be on the same panel. I would also like to add them all at once like in my code. Is there an override mechanism so that I can just put the image at the NORTH CENTER and keep the four buttons at the south border?
            QuizPanel = new JPanel();
            QuizPanel.add(label);  // I want this at the north center
            QuizPanel.add(button1);
            QuizPanel.add(button2);
            QuizPanel.add(button3);
            QuizPanel.add(button4);
            add(QuizPanel,BorderLayout.SOUTH);
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    * @author Matt
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class mario {
         * @param args the command line arguments
        public static void main(String[] args) {
            // TODO code application logic here
            EventQueue.invokeLater(new Runnable()
                public void run()
                    QuizFrame frame = new QuizFrame();
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.setVisible(true);
    class QuizFrame extends JFrame
        public QuizFrame()
            setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT);
            ImageIcon icon = new ImageIcon("C:\\users\\Matt\\Documents\\mario2.gif");
            JLabel label    =  new JLabel();
            label.setIcon(icon);
            JButton button1 = new JButton("one");
            JButton button2 = new JButton("two");
            JButton button3 = new JButton("three");
            JButton button4 = new JButton("four");
            QuizPanel = new JPanel();
            QuizPanel.add(label);
            QuizPanel.add(button1);
            QuizPanel.add(button2);
            QuizPanel.add(button3);
            QuizPanel.add(button4);
            add(QuizPanel,BorderLayout.SOUTH);
            QuizLabel = new JLabel("This is a test",JLabel.CENTER);
            add(QuizLabel,BorderLayout.CENTER);
        private JPanel QuizPanel;
        private JLabel QuizLabel;
        private static final int DEFAULT_WIDTH = 300;
        private static final int DEFAULT_HEIGHT = 200;
    }       

    I ignored some of the constraints of what you 'wanted' to do. Mostly because they were silly.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.net.URL;
    public class mario {
         * @param args the command line arguments
        public static void main(String[] args) {
            // TODO code application logic here
            EventQueue.invokeLater(new Runnable()
                public void run()
                    QuizFrame frame = new QuizFrame();
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.setVisible(true);
    class QuizFrame extends JFrame
        public QuizFrame()
            JLabel label    =  null;
            try {
                    URL url = new URL("http://forums.sun.com/im/bronze-star.gif");
                    ImageIcon icon = new ImageIcon(url);
                    label    =  new JLabel(icon,JLabel.CENTER);
            } catch(Exception continueWithoutIcon) {
                    label    =  new JLabel();
            JButton button1 = new JButton("one");
            JButton button2 = new JButton("two");
            JButton button3 = new JButton("three");
            JButton button4 = new JButton("four");
            QuizPanel = new JPanel();
            add(label, BorderLayout.NORTH);
            QuizPanel.add(button1);
            QuizPanel.add(button2);
            QuizPanel.add(button3);
            QuizPanel.add(button4);
            add(QuizPanel,BorderLayout.SOUTH);
            QuizLabel = new JLabel("This is a test",JLabel.CENTER);
            add(QuizLabel,BorderLayout.CENTER);
            pack();
        private JPanel QuizPanel;
        private JLabel QuizLabel;
    }       

  • GridBag or Flow Layout: Help Please!!!

    Requirement: Allow the user to input the amount of a mortgage and then select from a menu of mortgage loans: 7 years at 5.35%, 15 years at 5.5%, and 30 years at 5.75%. Use an array for the different loans. Display the mortgage payment amount. Then, list the loan balance and interest paid for each payment over the term of the loan. Allow the user to loopback and enter a new amount and make a new selection or quit.
    I have written the code so far that allows for the creation of the pane, texts, user entry, combobox, and buttons.
    My problem is that I cannot get it sorted out to look like a usable interface. I don't know if I should go with a GridBag Layout or a Flow Layout.
    I am using the GridBag Layout in this example, but obviously I am missing the correct procedure on how to do it.
    Can anyone give me a hand?
    My goal for the interface is to have the following fields set up in the pane to lay out like this:
    Mortgage ------ MortgageTF
    Loan ----- LoanCB
    Payment ----- PaymentTF
    Balance
    Compute----- Reset----- Exit
    Thank you for any assistance.
    Havok
    My written code is below:
    import javax.swing.*;
    import java.awt.*;
    public class MCalc002 extends JFrame
    public MCalc002()
    super("Mortgage Calculator");
    setSize(500, 800);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);
    Container pane = getContentPane();
    GridBagLayout gridBag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    pane.setLayout(gridBag);
    JLabel mortgage = new JLabel("Mortgage:");
    c.gridx = 0; c.gridy = 0;
    pane.add(mortgage);
    JLabel loan = new JLabel("Loan Menu:");
    c.gridx = 2; c.gridy = 2;
    pane.add(loan);
    JLabel payment = new JLabel("Monthly Payment:");
    c.gridx = 3; c.gridy = 3;
    pane.add(payment);
    JLabel balance = new JLabel("Loan Balance:");
    c.gridx = 4; c.gridy = 4;
    pane.add(balance);
    JTextField mortgageTF = new JTextField(10);
    c.gridx = 4; c.gridy = 4;
    pane.add(mortgageTF);
    JComboBox loanCB = new JComboBox();
    c.gridx = 5; c.gridy = 5;
    loanCB.addItem("Please Select");
    loanCB.addItem("7yrs @ 5.35%");
    loanCB.addItem("15yrs @ 5.5%");
    loanCB.addItem("30yrs @ 5.75%");
    pane.add(loanCB);
    JTextField paymentTF= new JTextField(10);
    c.gridx = 4; c.gridy = 4;
    pane.add(paymentTF);
    JButton compute = new JButton("Compute");
    c.gridx = 5; c.gridy = 5;
    pane.add(compute, c);
    JButton reset = new JButton("Reset");
    c.gridx = 6; c.gridy = 6;
    pane.add(reset, c);
    JButton exit = new JButton("Exit");
    c.gridx = 7; c.gridy = 7;
    pane.add(exit, c);
    setContentPane(pane);
    public static void main(String[] arguments)
    MCalc002 pb = new MCalc002();
    //EOF

    My problem is that I cannot get it sorted out to look
    like a usable interface. I don't know if I should go
    with a GridBag Layout or a Flow Layout.
    My goal for the interface is to have the following
    fields set up in the pane to lay out like this:
    Mortgage ------ MortgageTF
    Loan ----- LoanCB
    Payment ----- PaymentTF
    Balance
    Compute----- Reset----- Exit
    import javax.swing.*;
    import java.awt.*;
    public class MCalc002 extends JFrame {
        public MCalc002() {
            super("Mortgage Calculator");
            setSize(500, 800);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            Container pane = getContentPane();
            GridBagLayout gridBag = new GridBagLayout();
            GridBagConstraints c = new GridBagConstraints();
            pane.setLayout(gridBag);
            JLabel mortgage = new JLabel("Mortgage:");
            c.gridx = 0; c.gridy = 0;
            c.insets = new Insets(20,10,20,10);
            gridBag.setConstraints(mortgage, c);
            pane.add(mortgage);
            JLabel loan = new JLabel("Loan Menu:");
            c.gridx = 0; c.gridy = 1;
            c.insets = new Insets(20,10,20,10);
            gridBag.setConstraints(loan, c);
            pane.add(loan);
            JLabel payment = new JLabel("Monthly Payment:");
            c.gridx = 0; c.gridy = 2;
            c.insets = new Insets(20,10,20,10);
            gridBag.setConstraints(payment, c);
            pane.add(payment);
            JLabel balance = new JLabel("Loan Balance:");
            c.gridx = 0; c.gridy = 3;
            c.insets = new Insets(20,10,20,10);
            gridBag.setConstraints(balance, c);
            pane.add(balance);
            JTextField mortgageTF = new JTextField(10);
            c.gridx = 3; c.gridy = 0;
            c.insets = new Insets(20,10,20,10);
            gridBag.setConstraints(mortgageTF, c);
            pane.add(mortgageTF);
            JComboBox loanCB = new JComboBox();
            c.gridx = 3; c.gridy = 1;
            c.insets = new Insets(20,10,20,10);
            loanCB.addItem("Please Select");
            loanCB.addItem("7yrs @ 5.35%");
            loanCB.addItem("15yrs @ 5.5%");
            loanCB.addItem("30yrs @ 5.75%");
            gridBag.setConstraints(loanCB, c);
            pane.add(loanCB);
            JTextField paymentTF= new JTextField(10);
            c.gridx = 3; c.gridy = 2;
            c.insets = new Insets(20,10,20,10);
            gridBag.setConstraints(paymentTF, c);
            pane.add(paymentTF);
            JButton compute = new JButton("Compute");
            c.gridx = 0; c.gridy = 4;
            c.insets = new Insets(20,10,20,10);
            gridBag.setConstraints(compute, c);
            pane.add(compute, c);
            JButton reset = new JButton("Reset");
            c.gridx = 1; c.gridy = 4;
            c.insets = new Insets(20,10,20,10);
            gridBag.setConstraints(reset, c);
            pane.add(reset, c);
            JButton exit = new JButton("Exit");
            c.gridx = 3; c.gridy = 4;
            c.insets = new Insets(20,10,20,10);
            gridBag.setConstraints(exit, c);
            pane.add(exit, c);
            setContentPane(pane);
            setVisible(true);  // Generally speaking, this should be the last operation in setting up GUI components.
        public static void main(String[] arguments) {
            MCalc002 pb = new MCalc002();
    }

  • Report Layout Help

    Version 2.0
    I have a report that I'm having difficulities in getting a layout for. This report is a sales analysis that can be fiscal or calendar year. The look I'm after is:
    Account  Nov-05    Dec-05    Jan-06    Feb-06    Mar-06    Apr-06    May-06    Jun-06    Jul-06    Aug-06    2006 Total    2005 Total    Difference    Percent Inc/Dec
    Acct1    $9999.99  $9999.99  $9999.99  $9999.99  $9999.99  $9999.99  $9999.99  $9999.99  $9999.99  $9999.99  $99999.99     $99999.99     $9999.99      99.9Any help is greatly appreciated.
    Thanks,
    Joe

    John,
    1. Well, he is an extreme "joy" to work with. I'll admit that. Been in the managers office a few times.
    2. In the mark up that I provided above, August was the month that was selected from the "Select Month" drop down list. Since the "Calendar" checkbox was not selected, that meant that they wanted the beginning of the current fiscal year, Nov-05, to the selected month, in that example, Aug-06.
    I am taking care of the beginning and ending dates through date math. If you like I can provide that code too.
    I hope that was clear.
    Thanks,
    Joe

  • Simple css layout help

    Hey I know this is a piece of cake for you guys so help me
    out. I've got a simple layout going and set up at
    http://www.clark-imaging.com/ciiicomp/index.html
    and need your help. What is causing the weird white bands behind
    header and maincontent and footer and maincontent? There are no
    margin values assigned to the top and bottom of the header and
    footer, and a value of 0 won't make them go away. Also, how can I
    fix the footer div to the bottom of the window, so the main content
    area stretches with the window?
    Here's an
    image of the look I'm going for.
    Your responses are greatly appreciated.

    This will do what you want. View source code to see how it's
    built.
    http://alt-web.com/CSS2-1-column-fixed-width-centered.html
    Nancy O.
    Alt-Web Design & Publishing
    www.alt-web.com

  • Flow layout help please

    I am trying to position 3 buttons with 3 text fields underneath. I am using flowlayout but it puts it all on one line. I have tried grid layout too but this doesn't help.
    Is there anything I can do to split the buttons and text fields onto 2 separate lines?
    thanks

    I have tried grid layout too but this
    doesn't help.Yeah? hmm... it should work:
    setLayout(new GridLayout(2,3));
    getContentPane.add(button1);
    getContentPane.add(button2);
    getContentPane.add(button3);
    getContentPane.add(text1);
    getContentPane.add(text2);
    getContentPane.add(text3);

  • Scrolling, and Adaptive Layout help

    Hi guys, I am new to edge animate,
    I would like to know, like when a person scrolls its scrolls to a cirtain point seemlessly, not like when you are using a mouse, like blobk by block.
    also I would like to know more about adaptive layout, if anyone can help me more thorught skype,
    I would me really pleased, thank you
    my skype is Kevin2019170
    Thank you

    Well, only can help you with the background image...  put this code on document.compositionReady and window.resize events:
    var imageRatio = 1.7777; // Aspect 16:9, you can use any proportion depends of your image dimensions
    var sWidth = $(window).width()
    var sHeight = $(window).height()
    if ((sWidth / sHeight) > imageRatio) {
      sym.$("imgBackground").css("width", sWidth +"px");
      sym.$("imgBackground").css("height", sWidth/imageRatio +"px");
    else {
      sym.$("imgBackground").css("width", sHeight*imageRatio +"px");
      sym.$("imgBackground").css("height", sHeight +"px");

  • Dreamweaver CS5.5 Fluid Grid Layout Help!!!

    Needing help with What a fluid grid layout is, I hear that itll help my webpage be responsive and it will adjust for screen sizes depending on if your on a computer, phone or tablet. Can anyone link me to an Adobe TV tutorial for CS5.5? All I found was CC stuff and upgraded versions.

    Sorry but FluidGrids are not part of CS5 or CS5.5.  They didn't come on the scene until CS6 (12) & CC (13).
    If you're still interested in building responsive web sites without upgrading software, read this first:
    Introduction to CSS Media Queries
    http://www.adobe.com/devnet/dreamweaver/articles/introducing-media-queries.html
    To jump start your responsive web project, you can use one of the freely available Responsive Frameworks below:  Some people feel these are actually better than FluidGrid Layouts.
    Foundation Zurb
    http://foundation.zurb.com/templates.php
    Skeleton Boilerplate
    http://www.getskeleton.com/
    Initializr (HTML5 Boilerplate, Responsive or Bootstrap)
    http://www.initializr.com/
    DMX Zone's Bootstrap * free extension for DW *
    http://www.dmxzone.com/go/21759/dmxzone-bootstrap/
    Nancy O.

Maybe you are looking for

  • View attributes can not be retrieved. View instance not found or undefined

    Hi, I am creating a simple master detail OAF page. For this I have done following steps: 1. Created ParentEO and ChildEO 2. Created ParentVO with a transient attribute called "SelectFlag" with default value "Y" . 3. Created ChildVO 4. Created a UserV

  • My adobe creative cloud close's automatic

    Hello, Im busy with installing the programs from creative cloud for school, but when i open the creative cloud desktop installer it shuts down immediately. Yesterday the program does the same but today on school it worked but the internet on school i

  • Not a computer programer

    hi my lazy buddy wanted me to do this for him well hes my nephew 1.     Variable Naming Conventions. Explain whether each of the following is a valid variable name. a.     number b.     private c.     8ball d.     firstname e.     Last name f.     #n

  • Unable to open bookmarks in Adobe Reader 11 that were made in Adobe 10

    We are unable to open bookmarks in Adobe Reader 11 that were made in Adobe 10. The OS is Windows 7. Thanks for your help!

  • Requesting help-Schema creation and databinding

    We are using Livecycle ES 2, I am facing issues in traversing forms from one stage to another, forms are not holding datas from the previous stages. The steps which I followed are, 1) Created schema to define the fields and data types 2) Created two