HELP CHANGING LINE IN JAVA WITH LABELS

How to make two different information in two different row?

Page 1 of 1

3 Replies - 3434 Views - Last Post: 16 June 2007 - 01:05 AM Rate Topic: -----

#1 Angelsharmaonline   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 15-June 07

HELP CHANGING LINE IN JAVA WITH LABELS

Post icon  Posted 15 June 2007 - 03:31 PM

How to make StaffID on one row. I dont want all information in one row. How to change the line??? PLease help. I'm screwed. Please look at the image.


import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class LyceumFrame extends JFrame{
public LyceumFrame() {

JMenuItem F1 = new JMenuItem("New Staff Attendance");
JMenuItem F2 = new JMenuItem("Close Program");
JMenuItem F3 = new JMenuItem("Show Staff Register");
JMenuItem F4 = new JMenuItem("Request Technical Support");
F3.setEnabled(false);
JMenu menu1=new JMenu("File");
menu1.add(F1);
menu1.add(F2);
menu1.add(F3);
JMenuBar menubar = new JMenuBar();
JMenu menu2=new JMenu("Help");
menu2.add(F4);
menubar.add(menu1);
menubar.add(menu2);
setJMenuBar(menubar);


setTitle("Lyceum Model School Staff Attendance");
setSize(800,600);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);

Container pane = getContentPane();
FlowLayout flo = new FlowLayout(FlowLayout.LEFT);
pane.setLayout(flo);

JLabel StaffIdlevel = new JLabel("Staff ID Number: ", JLabel.LEFT);
JTextField staffId = new JTextField(7 );
JCheckBox present = new JCheckBox("Present");
JCheckBox absent  = new JCheckBox("Absent" );

JLabel staffdesignationlevel = new JLabel("Staff Designation: ", JLabel.RIGHT);
JComboBox staffdesignation = new JComboBox();
staffdesignation.addItem("Cleaner");
staffdesignation.addItem("Pre-Primary Level Teacher");
staffdesignation.addItem("Primary Level Teacher");
staffdesignation.addItem("Secondary Level Teacher");
staffdesignation.addItem("Board of Directors");
JButton submitdata = new JButton("SUBMIT");
pane.add(StaffIdlevel);
pane.add(staffId);
pane.add(present);
pane.add(absent);
pane.add(staffdesignationlevel);
pane.add(staffdesignation);
pane.add(submitdata);
setContentPane(pane);
}
public static void main(String[] arguments){
LyceumFrame lyc =  new LyceumFrame();
}
}
 

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: HELP CHANGING LINE IN JAVA WITH LABELS

#2 Liontrue1   User is offline

  • D.I.C Addict
  • member icon

Reputation: 48
  • View blog
  • Posts: 811
  • Joined: 20-May 06

Re: HELP CHANGING LINE IN JAVA WITH LABELS

Posted 15 June 2007 - 04:00 PM

Sadly, the \n character won't work in a JLabel. An example of how to bypass this would be:

mylabel.setText("<html>Line1<br>Line2");


The html tags won't appear and you will have a beautiful 2-line label! There is another "clean" way this can be done, but it would require digging in the UI manager which is a complex subject I don't master.
Was This Post Helpful? 0
  • +
  • -

#3 Angelsharmaonline   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 15-June 07

Re: HELP CHANGING LINE IN JAVA WITH LABELS

Posted 15 June 2007 - 10:52 PM

SADLY THE ABOVE SUGGESTED METHOD DONT WORK.
Was This Post Helpful? 0
  • +
  • -

#4 PennyBoki   User is offline

  • D.I.C Lover
  • member icon

Reputation: 55
  • View blog
  • Posts: 2,345
  • Joined: 11-December 06

Re: HELP CHANGING LINE IN JAVA WITH LABELS

Posted 16 June 2007 - 01:05 AM

Check out the java layouts, here is one of them.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1