Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How adjust the boxes to come in one by one order


package hospitalmanagement;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Label;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;

public class HospitalRooms extends JFrame {

JScrollPane scrollpane;
Properties props = null;

public HospitalRooms() throws IOException {
super("JScrollPane Demonstration");
setSize(450, 500);
setDefaultCloseOperation(EXIT_ON_CLOSE);
init();
setVisible(true);
getData();
}

public void getData() throws IOException {
File file = new File("");
String separator = System.getProperty("file.separator");
props = new Properties();
FileInputStream fis = null;
try {
fis = new FileInputStream(file.getAbsolutePath() + separator + "resources" + separator + "resource.properties");

props.load(fis);
} catch (IOException e) {
e.printStackTrace();
} finally {
fis.close();
}
}

public void init() {
setSize(350,550);
setResizable(false);

JPanel p = new JPanel(new GridLayout(0,3,2,5));
scrollpane = new JScrollPane(p);
//scrollpane.setBounds(15, 50, 300, 400);
scrollpane.setPreferredSize(new Dimension(340,100));
getContentPane().add(scrollpane,BorderLayout.WEST);

// String NumberOfBeds = props.getProperty("NumberOfBeds");
// int beds = Integer.parseInt(NumberOfBeds);
// System.out.println("Beds" + beds);
Label label1 = new Label();
label1.setBounds(30, 5, 150, 24);
//label1.setBounds(200, 5, 150, 24);
label1.setText("Room Number");
p.add(label1);

Label label2 = new Label();
label2.setBounds(200, 5, 150, 24);
label2.setText("Number of Beds");
p.add(label2);
/* if (NumberOfBeds.equals("0") || NumberOfBeds.equals(" ")) {
label1.setBounds(150, 5, 150, 24);
label1.setText("NO ROOMS AVILABLE");
}*/


int j = 0;

for (int i = 0; i < 100; i++) {

JTextField t = new JTextField();
// t.setBounds(200, 30+j , 200, 24);
p.add(t);

Label label = new Label();
//label.setBounds(200, 30 + j, 20, 24);
label.setText(":");
p.add(label);

JTextField t1 = new JTextField();
// t1.setBounds(180, 30 + j, 100, 24);
p.add(t1);


j = j + 30;


}

}

public static void main(String args[]) throws IOException {
new HospitalRooms();
}
}

ROOM NUMBER ROOMS AVILABLE
textbox : textbox
textbox : textbox
textbox : textbox

output should b in this format.Please help me trying a lot to solve this.
Posted
Updated 17-Jan-12 19:38pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900