001    /**
002     * RestaurantsConnector.java
003     * jCOLIBRI2 framework. 
004     * @author Juan A. Recio-García.
005     * GAIA - Group for Artificial Intelligence Applications
006     * http://gaia.fdi.ucm.es
007     * 23/06/2007
008     */
009    package jcolibri.test.test13.gui;
010    
011    import java.awt.Color;
012    import java.awt.Dimension;
013    import java.awt.HeadlessException;
014    import java.awt.Rectangle;
015    import java.awt.SystemColor;
016    
017    import javax.swing.BorderFactory;
018    import javax.swing.JDialog;
019    import javax.swing.JEditorPane;
020    import javax.swing.JLabel;
021    import javax.swing.JPanel;
022    import javax.swing.JScrollPane;
023    import javax.swing.JTextField;
024    import javax.swing.border.BevelBorder;
025    import javax.swing.border.Border;
026    import javax.swing.border.TitledBorder;
027    
028    /**
029     * Swing dialog to show the result of the recommendation.
030     * @author Juan Antonio Recio García
031     * @version 1.0
032     */
033    
034    public class ResultFrame extends JDialog {
035    
036        private static final long serialVersionUID = 1L;
037    
038        JLabel jLabel1 = new JLabel();
039    
040            JLabel logo = new JLabel();
041    
042            JScrollPane jScrollPane1 = new JScrollPane();
043    
044            JPanel jPanel1 = new JPanel();
045    
046            Border border1;
047    
048            TitledBorder titledBorder1;
049    
050            JPanel jPanel2 = new JPanel();
051    
052            Border border2;
053    
054            TitledBorder titledBorder2;
055    
056            JEditorPane queryTextPane = new JEditorPane();
057    
058            JLabel jLabel2 = new JLabel();
059    
060            JTextField restaurant = new JTextField();
061    
062            JLabel jLabel3 = new JLabel();
063    
064            JScrollPane jScrollPane2 = new JScrollPane();
065    
066            JEditorPane AddressTextPane = new JEditorPane();
067    
068            JLabel jLabel4 = new JLabel();
069    
070            JScrollPane jScrollPane3 = new JScrollPane();
071    
072            JEditorPane descriptionTextPane = new JEditorPane();
073    
074            public ResultFrame(String query, String restaurant, String address,
075                            String description) throws HeadlessException {
076                    try {
077                            jbInit();
078                            java.awt.Dimension screenSize = java.awt.Toolkit
079                                            .getDefaultToolkit().getScreenSize();
080                            setBounds((screenSize.width - this.getWidth()) / 2,
081                                            (screenSize.height - this.getHeight()) / 2, getWidth(),
082                                            getHeight());
083                            this.queryTextPane.setText(query);
084                            this.restaurant.setText(restaurant);
085                            this.AddressTextPane.setText(address);
086                            this.descriptionTextPane.setText(description);
087                            this.setVisible(true);
088                    } catch (Exception e) {
089                            e.printStackTrace();
090                    }
091            }
092    
093            public static void main(String[] args) throws HeadlessException {
094                    ResultFrame resultFrame1 = new ResultFrame("query", "restaurant",
095                                    "address", "description");
096                    resultFrame1.setVisible(true);
097            }
098    
099            private void jbInit() throws Exception {
100                    border1 = BorderFactory.createBevelBorder(BevelBorder.LOWERED,
101                                    Color.white, Color.white, new Color(124, 124, 124), new Color(
102                                                    178, 178, 178));
103                    titledBorder1 = new TitledBorder(BorderFactory.createLineBorder(
104                                    Color.black, 1), "Result");
105                    border2 = BorderFactory.createLineBorder(SystemColor.controlText, 1);
106                    titledBorder2 = new TitledBorder(border2, "Query");
107                    jLabel1.setFont(new java.awt.Font("Dialog", 1, 16));
108                    jLabel1.setForeground(Color.blue);
109                    jLabel1.setText("jCOLIBRI Chef Recommendation");
110                    jLabel1.setBounds(new Rectangle(100, 11, 271, 29));
111                    this.getContentPane().setBackground(Color.white);
112                    this.getContentPane().setLayout(null);
113                    logo.setText("");
114                    logo.setBounds(new Rectangle(291, 203, 138, 283));
115                    logo.setIcon(new javax.swing.ImageIcon(jcolibri.util.FileIO.findFile("jcolibri/test/test13/gui/chef.jpg")));
116                    jScrollPane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
117                    jScrollPane1.setBounds(new Rectangle(9, 21, 404, 41));
118                    jPanel1.setBackground(Color.white);
119                    jPanel1.setBorder(titledBorder1);
120                    jPanel1.setBounds(new Rectangle(15, 132, 256, 345));
121                    jPanel1.setLayout(null);
122                    jPanel2.setBackground(Color.white);
123                    jPanel2.setBorder(titledBorder2);
124                    jPanel2.setBounds(new Rectangle(14, 44, 423, 76));
125                    jPanel2.setLayout(null);
126                    queryTextPane.setEditable(false);
127                    queryTextPane.setText("");
128                    jLabel2.setText("Restaurant");
129                    jLabel2.setBounds(new Rectangle(9, 19, 214, 20));
130                    restaurant.setText("");
131                    restaurant.setBounds(new Rectangle(7, 42, 237, 23));
132                    restaurant.setEditable(false);
133                    restaurant.setBackground(Color.white);
134                    jLabel3.setBounds(new Rectangle(9, 74, 214, 20));
135                    jLabel3.setText("Address");
136                    jScrollPane2
137                                    .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
138                    jScrollPane2.setBounds(new Rectangle(7, 98, 234, 40));
139                    jLabel4.setBounds(new Rectangle(9, 149, 214, 20));
140                    jLabel4.setText("Description");
141                    jScrollPane3
142                                    .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
143                    jScrollPane3
144                                    .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
145                    jScrollPane3.setVerifyInputWhenFocusTarget(true);
146                    jScrollPane3.setBounds(new Rectangle(8, 173, 233, 163));
147                    AddressTextPane.setText("");
148                    AddressTextPane.setEditable(false);
149                    descriptionTextPane.setText("");
150                    descriptionTextPane.setEditable(false);
151                    this.getContentPane().add(jPanel1, null);
152                    this.getContentPane().add(logo, null);
153                    this.getContentPane().add(jPanel2, null);
154                    jPanel2.add(jScrollPane1, null);
155                    this.getContentPane().add(jLabel1, null);
156                    jScrollPane1.getViewport().add(queryTextPane, null);
157                    jPanel1.add(restaurant, null);
158                    jPanel1.add(jLabel2, null);
159                    jPanel1.add(jLabel3, null);
160                    jPanel1.add(jScrollPane2, null);
161                    jScrollPane2.getViewport().add(AddressTextPane, null);
162                    jPanel1.add(jScrollPane3, null);
163                    jPanel1.add(jLabel4, null);
164                    jScrollPane3.getViewport().add(descriptionTextPane, null);
165                    this.setSize(new Dimension(465, 515));
166            }
167    
168    }