Hi,
I am trying to create a specific user interface according to certain specifications given to me... I have figured out how to put the panels together and I have everything almost where I want it.
I am having a lot of trouble figuring out how to make my schedule button a more reasonable size and also with bringing the JTextFields closer to their corresponding labels. If you compile this you will see how the two JTextFields are way too far away from their labels and the schedule button is way bigger than needed. Also the time JLabel is off to the left too far, I would like it more centered in the leftPanel. Any help would be much appreciated. thanks.
private JTextField startAddress = new JTextField(10); private JTextField endAddress = new JTextField(10); private JList hourDisplay = new JList(); private JList minDisplay = new JList(); private JScrollPane minPane = new JScrollPane(minDisplay); private JTextArea itinDisplay = new JTextArea(22,50); private JScrollPane itinPane = new JScrollPane(itinDisplay); private JButton scheduleB = new JButton("Schedule"); JLabel itin = new JLabel("Itinerary"); JLabel start = new JLabel("Start:"); JLabel end = new JLabel("End:"); JLabel status = new JLabel("blah blah blah"); final static int maxGap = 20; private double hour = 00; private double min = 00; JLabel time = new JLabel("time: " + hour + min); public static final int WIDTH = 1000; public static final int HEIGHT = 850; public static final int hourLINES = 40; public static final int charPerLine = 10; public static final int minLINES = 40; private JPanel mainPanel = new JPanel(); private JPanel leftPanel = new JPanel(); private JPanel rightPanel = new JPanel(); private JPanel southPanel = new JPanel(); private JPanel entryPanel = new JPanel(); private JPanel timePanel = new JPanel(); private JPanel buttonPanel = new JPanel(); private JPanel itinPanel = new JPanel(); private JPanel mapPanel = new JPanel(); public BusAppFrame() { super("Bus Application"); setSize(WIDTH, HEIGHT); setBackground(Color.DARK_GRAY); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); entryPanel(); timePanel(); southPanel(); itinPanel(); mapPanel(); mainPanel.setLayout(new BorderLayout()); leftPanel.setLayout(new BorderLayout()); rightPanel.setLayout(new BorderLayout()); leftPanel.add(entryPanel, BorderLayout.NORTH); leftPanel.add(timePanel, BorderLayout.CENTER); leftPanel.add(southPanel, BorderLayout.SOUTH); rightPanel.add(itinPanel, BorderLayout.NORTH); mainPanel.add(leftPanel, BorderLayout.WEST); mainPanel.add(rightPanel, BorderLayout.EAST); status.setBorder(BorderFactory.createLineBorder(Color.black)); mainPanel.add(status, BorderLayout.SOUTH); this.getContentPane().add(mainPanel); } private void entryPanel(){ entryPanel.setLayout(new GridLayout(3,1)); entryPanel.add(start); entryPanel.add(startAddress); entryPanel.add(end); entryPanel.add(endAddress); entryPanel.add(timeOfDep); } private void timePanel(){ timePanel.setLayout(new GridLayout(1,2)); hourDisplay.setBorder(BorderFactory.createLineBorder(Color.black)); minDisplay.setBorder(BorderFactory.createLineBorder(Color.black)); hourDisplay.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); minDisplay.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); timePanel.add(hourDisplay); timePanel.add(minDisplay); } private void southPanel(){ southPanel.setLayout(new BorderLayout()); //status.setBorder(BorderFactory.createLineBorder(Color.black)); southPanel.add(scheduleB, BorderLayout.CENTER); //southPanel.add(status, BorderLayout.PAGE_END); } private void itinPanel(){ itinPanel.setLayout(new BorderLayout()); itinPanel.add(itin, BorderLayout.NORTH); itinPanel.add(itinPane, BorderLayout.AFTER_LINE_ENDS); } public static void main(String[] args) { BusAppFrame obj = new BusAppFrame(); obj.setVisible(true); }