1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
public ResultPanel() {
GridBagConstraints resultsConstraints = new GridBagConstraints();
resultsConstraints.fill = GridBagConstraints.BOTH;
resultsConstraints.gridx = 0;
resultsConstraints.gridy = 0;
resultsConstraints.weightx = 1;
resultsConstraints.weighty = 0;
resultsConstraints.insets = new Insets(3, 10, 3, 3);
GridBagConstraints detailsConstraints = new GridBagConstraints();
detailsConstraints.fill = GridBagConstraints.BOTH;
detailsConstraints.gridx = 1;
detailsConstraints.gridy = 0;
detailsConstraints.weightx = 1;
detailsConstraints.weighty = 0;
detailsConstraints.insets = new Insets(3, 10, 3, 3);
GridBagConstraints listConstraints = new GridBagConstraints();
listConstraints.fill = GridBagConstraints.BOTH;
listConstraints.gridx = 0;
listConstraints.gridy = 1;
listConstraints.weightx = 1;
listConstraints.weighty = 1;
listConstraints.insets = new Insets(3, 3, 3, 3);
GridBagConstraints textAreaConstraints = new GridBagConstraints();
textAreaConstraints.fill = GridBagConstraints.BOTH;
textAreaConstraints.gridx = 1;
textAreaConstraints.gridy = 1;
textAreaConstraints.weightx = 1;
textAreaConstraints.weighty = 1;
textAreaConstraints.insets = new Insets(3, 3, 3, 3);
this.setLayout(new GridBagLayout());
this.add(getJTextPane(), resultsConstraints);
this.add(getJTextPane1(), detailsConstraints);
this.add(getJTextArea(), textAreaConstraints);
this.add(getScroller(), listConstraints);
}
private JScrollPane getScroller() {
if(scroller == null) {
scroller = new JScrollPane(getJList(),
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scroller.setPreferredSize(getJList().getPreferredSize());
}
return scroller;
}
private JTextPane getJTextPane() {
if (jTextPane == null) {
jTextPane = new TextPane("Résultats");
Dimension dim = new Dimension();
dim.height = 20;
dim.width = (int) (MainWindow.prefSize.width * 0.25);
jTextPane.setPreferredSize(dim);
}
return jTextPane;
}
private JTextPane getJTextPane1() {
if (jTextPane1 == null) {
jTextPane1 = new TextPane("Détails");
Dimension dim = new Dimension();
dim.height = 20;
dim.width = (int) (MainWindow.prefSize.width * 0.25);
jTextPane.setPreferredSize(dim);
}
return jTextPane1;
}
private JTextArea getJTextArea() {
if (jTextArea == null) {
jTextArea = new JTextArea();
jTextArea.setEditable(false);
jTextArea.setLineWrap(true);
jTextArea.setWrapStyleWord(true);
Dimension dim = new Dimension();
dim.height = (int) (MainWindow.prefSize.height * coefHauteur);
dim.width = (int) (MainWindow.prefSize.width * 0.55);
jTextArea.setPreferredSize(dim);
}
return jTextArea;
}
private JList getJList() {
if (jList == null) {
jList = new JList();
Dimension dim = new Dimension();
dim.height = (int) (MainWindow.prefSize.height * coefHauteur);
dim.width = (int) (MainWindow.prefSize.width * 0.35);
jList.setPreferredSize(dim);
initiallistHeight = dim.height;
jList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
Result r = (Result) jList.getSelectedValue();
getJTextArea().setText(afficheResultat(r));
}
});
}
return jList;
} |
Partager