package interfaces.JGUI; import java.awt.*; public class HotelPanel extends Panel { Checkbox[] m_rating; Checkbox[] m_price; HotelPanel() { setLayout(new GridLayout(3, 1)); Panel p1, p2, p3; p2 = new Panel(); p2.setLayout(new FlowLayout(FlowLayout.LEFT)); p2.add(new Label("Rating: ")); m_rating = new Checkbox[5]; for (int i = 0; i < 5; i++) { p2.add(m_rating[i] = new Checkbox(" " + (i + 1))); } add(p2); p3 = new Panel(); p3.setLayout(new FlowLayout(FlowLayout.LEFT)); p3.add(new Label("Price: ")); m_price = new Checkbox[4]; p3.add(m_price[0] = new Checkbox(".. - $30")); p3.add(m_price[1] = new Checkbox("$30 - $60")); p3.add(m_price[2] = new Checkbox("$100 - $200")); p3.add(m_price[3] = new Checkbox("$200 - ..")); add(p3); //Add panels to the Applet. setLayout(new GridLayout(3, 1)); add(p2); add(p3); } public String getPredicate() { String predicate = new String(); String rating = new String(); int i; for (i = 0 ; i < 5 ; ++i) { if (m_rating[i].getState()) rating += " " + Globals.selectedTable + ".rating = " + i + " OR"; } if (rating.length() != 0) predicate += " (" + rating.substring(0, rating.length() - 3) + ") AND"; String price = new String(); for (i = 0 ; i < 4 ; ++i) { if (m_price[i].getState()) price += " " + Globals.selectedTable + ".price = " + i + " OR"; } if (price.length() != 0) predicate += " (" + price.substring(0, price.length() - 3) + ") AND"; return (predicate.length() == 0) ? predicate : predicate.substring(0, predicate.lastIndexOf(" ") + 1); } }