Results 1 to 4 of 4
  1. #1
    neway003 is offline Member
    Join Date
    Nov 2010
    Posts
    1
    Rep Power
    0

    Post Please Help me to do a layout

    Hello here is the concept about my application



    Its my college project so Ican't use any IDE

    Jobs done by me on this project

    Created JFrame & set BorderLayout, JInternalFrame seperately
    Created a JMenuBar and set it as the default JMenuBar
    1.Created a JToolBar
    2.created a JDesktopPane
    Created JTable
    set BorderLayout to desktop pane and added the JTable to it (because need to show the Table every time and the Internal Frames can be opened above it
    3.Created JPanel (canbe used as status panel)

    added the componets 1,2,3 to content pane




    code is here I shorted it for discussion
    ///////////////////////////////////////
    import java.awt.*;
    import javax.swing.*;
    import java.util.*;
    import java.awt.event.*;
    import javax.swing.table.*;
    import javax.swing.UIManager;

    public class DoctorInfoSystem extends JFrame{
    JDesktopPane desktopPane;
    JMenuBar menuBar;
    JMenu FileMenu;
    JMenuItem MenuItemNew;
    JToolBar toolBar;
    JButton TbtnAddDoctor;
    JPanel Jp;
    //For table//
    Vector TableData, TableColumnName, TableRow;
    JTable OutPutTable;
    DefaultTableModel TableModel;
    JScrollPane TableScrollPane;

    public DoctorInfoSystem(){
    super("Doctor Information System");

    ////UI Manager//
    try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAn dFeelClassName());
    }
    catch(Exception e) {
    }

    //Main Part of the code//
    desktopPane = new JDesktopPane();
    desktopPane.setPreferredSize(new Dimension(1000,600));
    desktopPane.setOpaque(false);
    desktopPane.setLayout(new BorderLayout());

    //MenuBar//
    menuBar = new JMenuBar();
    FileMenu = new JMenu("File");
    MenuItemNew = new JMenuItem("Add New Doctor Info");
    FileMenu.add(MenuItemNew);
    menuBar.add(FileMenu);

    //ToolBar//
    toolBar = new JToolBar();
    TbtnAddDoctor = new JButton( new ImageIcon("addDoctor32.png"));
    FlowLayout toolBarLayout = new FlowLayout();
    toolBarLayout.setAlignment(FlowLayout.TRAILING);
    toolBar.setLayout(toolBarLayout);
    toolBar.setComponentOrientation(ComponentOrientati on.RIGHT_TO_LEFT);
    toolBar.add(TbtnAddDoctor);
    toolBar.setPreferredSize(new Dimension(1000,50));
    toolBar.setFloatable(false);

    //Table and Scrollpane//
    TableData = new Vector();
    TableColumnName = new Vector();
    TableModel = new DefaultTableModel();
    setColumnName();
    TableModel.setDataVector(TableData,TableColumnName );
    OutPutTable = new JTable(TableModel);
    OutPutTable.setAutoResizeMode(1);
    TableScrollPane = new JScrollPane(OutPutTable);
    TableScrollPane.setAutoscrolls(true);
    TableScrollPane.setPreferredSize(new Dimension(1000,600));

    //Adding Table to desktopPane//
    desktopPane.add(TableScrollPane,BorderLayout.CENTE R);


    //JPanel Code//
    Jp = new JPanel();
    Jp.setPreferredSize(new Dimension(1000,75));

    //Content Pane declaration //
    Container cp = getContentPane();
    cp.setLayout(new BorderLayout());

    //add components to container//
    cp.add(toolBar,BorderLayout.PAGE_START);
    cp.add(desktopPane,BorderLayout.CENTER);
    cp.add(Jp,BorderLayout.PAGE_END);

    //Frame settings//
    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize ();
    setBounds(0,0, screenSize.width, screenSize.height-40);
    setResizable(true);
    setVisible(true);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setJMenuBar(menuBar);
    setExtendedState(MAXIMIZED_BOTH);
    }

    //Table Column names//
    void setColumnName(){
    TableColumnName.addElement("Name");
    TableColumnName.addElement("Specialist in");
    TableColumnName.addElement("Consultation time");
    TableColumnName.addElement("Contact info");
    }

    //Main//
    public static void main (String[] args) {
    DoctorInfoSystem DIS = new DoctorInfoSystem();
    //JFrame Icon settings//
    DIS.setIconImage(new ImageIcon("ico.png").getImage());
    }
    }

  2. #2
    StormyWaters is offline Senior Member
    Join Date
    Feb 2009
    Posts
    307
    Rep Power
    6

    Default

    What problems are you seeing? What's the question?

  3. #3
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,017
    Rep Power
    10

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,455
    Rep Power
    20

    Default

    And lay off the lime green, it's annoying. Put the effort into finding out how to use the code tags instead of color tags.

    db

Similar Threads

  1. looking for a layout
    By imorio in forum AWT / Swing
    Replies: 3
    Last Post: 08-13-2010, 06:02 PM
  2. JFrame Layout
    By ŖΫ ỏ Ңόρę in forum New To Java
    Replies: 16
    Last Post: 06-16-2010, 02:48 AM
  3. Edit layout Layout please help me
    By manhtungtnk28@gmail.com in forum New To Java
    Replies: 4
    Last Post: 11-23-2009, 09:41 AM
  4. Stack layout
    By blue404 in forum SWT / JFace
    Replies: 0
    Last Post: 03-22-2009, 02:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •