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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
|
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
public class IHMbase extends JFrame implements ActionListener {
private static final int LEFT = 0;
private JPanel panel1;
private JPanel panel2;
private JPanel panel3;
private JPanel panel4;
private JPanel panel5;
private JPanel panel6;
private JMenuBar menuBar;
private JMenu fichier;
private JMenu editer;
private JMenu aide;
private JMenuItem ouvrir;
private JMenuItem quitter;
private JMenuItem ajouter;
private JMenuItem retirer;
private JMenuItem modifier;
private JMenuItem aPropos;
private JMenuItem menuAide;
private JButton bOuvrir;
private JButton bQuitter;
private JButton bAjouter;
private JButton bRetirer;
private JButton bModifier;
private JButton bEnregistrer;
private JTextField jtf;
private Font police;
private JScrollPane scroll;
private static int nFils = 0;
private static String nomFils = "vide";
private static List<FilRss> listFils;
private static JRadioButton rb;
public IHMbase(){
initComponents();
}
public static void setListFils(List<FilRss> f){
listFils = f;
}
public List<FilRss> getListFils(){
return listFils;
}
public static void setNomFils(String s){
nomFils = s;
}
public static String getNomFils(){
return nomFils;
}
public static void setNFils(int i){
nFils = i;
}
public static int getNFils(){
return nFils;
}
private void initComponents() {
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
this.setTitle("INF 1420 Travail Noté 4");
this.setSize(450,421);
this.setLocationRelativeTo(null);
this.setResizable(true);
this.setAlwaysOnTop(false);
menuBar = new JMenuBar();
fichier = new JMenu("Fichier");
ouvrir = new JMenuItem("Ouvrir");
this.fichier.add(ouvrir);
quitter = new JMenuItem("Quitter");
this.fichier.add(quitter);
this.menuBar.add(fichier);
editer = new JMenu("Editer");
ajouter = new JMenuItem("Ajouter");
this.editer.add(ajouter);
retirer = new JMenuItem("Retirer");
this.editer.add(retirer);
modifier = new JMenuItem("Modifier");
this.editer.add(modifier);
this.menuBar.add(editer);
aide = new JMenu("Aide");
aPropos = new JMenuItem("À propos");
this.aide.add(aPropos);
menuAide = new JMenuItem("Menu aide");
this.aide.add(menuAide);
this.menuBar.add(aide);
this.setJMenuBar(menuBar);
panel2 = new JPanel();
bOuvrir = new JButton("Ouvrir");
bQuitter = new JButton("Quitter");
bAjouter = new JButton("Ajouter");
bRetirer = new JButton("Retirer");
bModifier = new JButton("Modifier");
bEnregistrer = new JButton("Enregistrer");
this.panel2.setLayout(new FlowLayout(LEFT,10,10));
this.panel2.setBackground(Color.WHITE);
this.panel2.setPreferredSize(new Dimension(450,40));
this.panel2.add(bOuvrir);
bOuvrir.addActionListener(this);
this.panel2.add(bAjouter);
bAjouter.addActionListener(this);
this.panel2.add(bRetirer);
bRetirer.addActionListener(this);
this.panel2.add(bModifier);
bModifier.addActionListener(this);
panel3 = new JPanel();
this.panel3.setLayout(new FlowLayout(LEFT,10,10));
this.panel3.setPreferredSize(new Dimension(450,40));
this.panel3.setBackground(Color.WHITE);
jtf = new JTextField("Nouvel URL");
police = new Font("Arial", Font.BOLD, 14);
this.jtf.setFont(police);
this.jtf.setPreferredSize(new Dimension(250, 30));
this.jtf.setForeground(Color.BLACK);
this.panel3.add(jtf);
this.panel3.add(bEnregistrer);
bEnregistrer.addActionListener(this);
panel4 = new JPanel();
panel6 = new JPanel();
this.panel4.setPreferredSize(new Dimension(450,300));
this.panel4.setBackground(Color.WHITE);
this.panel4.setBorder(BorderFactory.createTitledBorder("Liste des fils RSS"));
this.panel6.setLayout(new BoxLayout(panel6,BoxLayout.PAGE_AXIS));
for (int i = 0; i < nFils; i++) {
FilRss fr = new FilRss(listFils.get(i));
nomFils = fr.getItem();
JRadioButton rb = new JRadioButton(nomFils);
rb.addActionListener(this);
this.panel6.add(rb);
}
scroll = new JScrollPane(panel6);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
this.panel4.add(scroll, BorderLayout.CENTER);
this.scroll.setPreferredSize(new Dimension(430,250));
this.panel4.add(scroll);
panel5 = new JPanel();
this.panel5.setPreferredSize(new Dimension(450,41));
this.panel5.setBackground(Color.WHITE);
this.panel5.setLayout(new FlowLayout(FlowLayout.RIGHT));
bQuitter = new JButton("Quitter");
this.panel5.add(bQuitter);
bQuitter.addActionListener(this);
panel1 = new JPanel();
this.panel1.setLayout(new BoxLayout(panel1,BoxLayout.PAGE_AXIS));
this.panel1.setPreferredSize(new Dimension(450,421));
this.panel1.add(panel2);
this.panel1.add(panel3);
this.panel1.add(panel4);
this.panel1.add(panel5);
this.getContentPane().add(panel1);
pack();
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == bOuvrir){
new IHMlecture().setVisible(true);
}
else if(e.getSource() == bQuitter){
System.exit(DISPOSE_ON_CLOSE);
}
else if(e.getSource() == bAjouter){
new IHMajouter().setVisible(true);
}
else if(e.getSource() == bRetirer){
new IHMretirer().setVisible(true);
}
else if(e.getSource() == bModifier){
new IHMmodifier().setVisible(true);
}
else if(e.getSource() == bEnregistrer){
}
else if(e.getSource() == rb){
//Main.setFilOuvert(((JRadioButton)e.getSource()).getText());
}
}
} |
Partager