about buiding GUIs


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: about buiding GUIs

  1. #1
    Join Date
    Oct 2002
    Posts
    1

    Unhappy about buiding GUIs

    Hey everyone,

    I was working on small program for building GUIs,
    the progam that I was working on has LIST and TEXTAREA and three buttons below them. Here is my problem:

    I was trying to incorprate a scrolbar into the LIST,but somehow I am unable to achieve that because I am new to java, Can anyone tell me how I can achieve my goal ? here is the code developed so far :

    Code:
    code
    
    
    import java.awt.*;
    import java.awt.event.*;
     import javax.swing.JList;
     import javax.swing.JPanel;
     import javax.swing.JLabel;
     import javax.swing.*;
    
    
     import javax.swing.JFrame;
     import javax.swing.DefaultListModel;
     import java.awt.event.WindowAdapter;
     import java.awt.event.WindowEvent;
     
     import javax.swing.JMenu;
     import javax.swing.JMenuItem;
     import javax.swing.JMenuBar;
    
    public class NurseSystem extends JFrame
    {
          
    	public NurseSystem()
    	{
    	    JMenuBar menuBar = new JMenuBar();
           JMenu fileMenu = new JMenu("File");
           JMenu editMenu = new JMenu("Edit");
           
           //add sub menus
           JMenuItem newFileItem = new JMenuItem("New");
           JMenuItem openFileItem = new JMenuItem("open");
           
           JMenuItem addFileItem = new JMenuItem("Add");
           JMenuItem ModifyFileItem = new JMenuItem("Modify");
           JMenuItem deleteFileItem = new JMenuItem("Delete");
          
           //file submenu
           fileMenu.add(newFileItem);
           fileMenu.add(openFileItem);
           //add edit submenu
           editMenu.add(addFileItem);
           editMenu.add(ModifyFileItem);
           editMenu.add(deleteFileItem);
           
            //Add the menus to the menubar
           menuBar.add (fileMenu);
           menuBar.add (editMenu);
           
           //add the menubar to the application window
           setJMenuBar (menuBar);
           
           //Name and Detailed labels 
          JLabel label1 = new JLabel("                                     ");
          JLabel label2 = new JLabel("                                      ");
     
          JLabel nurseName = new JLabel("Nurse Name",JLabel.LEFT);
          JLabel detailedInfo = new JLabel("Detailed Information");
          
          //Create a LIst
    
           //set component layout
    	    FlowLayout layout = new FlowLayout();
    	    Container mainWindow = getContentPane();
    	    mainWindow.setLayout (layout);
    	    //add labels to the main Window
    	    mainWindow.add(nurseName);
    	    mainWindow.add(label1);
    	    mainWindow.add(label2);
    	    mainWindow.add(detailedInfo);
    	
    
    	 
    	
    
          
    	
    		this.addWindowListener	(new WindowAdapter(){
    			public void windowClosing(WindowEvent e){
    				dispose();
    				System.exit(0);
    			}
    		});
    	}
    	
    	public static void main(String args[])
    	{
    	   System.out.print("Nurse System");
    		NurseSystem f = new NurseSystem();
    		f.setSize(500,400);
    		f.show();
    	} 
    }

  2. #2
    Join Date
    Sep 2002
    Posts
    16
    To add scroll bars to a control:
    Code:
    JTextArea textBox = new JTextArea();
    JScrollPane myPane = newJScrollPane(textBox);
    Jayceepoo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center