Advertisement
Guest User

teste - Rui

a guest
Apr 17th, 2016
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.81 KB | None | 0 0
  1. package a6036.ruimendes;
  2.  
  3. import java.awt.EventQueue;
  4.  
  5. import javax.swing.JFrame;
  6. import javax.swing.JScrollPane;
  7. import java.awt.BorderLayout;
  8. import javax.swing.JPanel;
  9. import javax.swing.JToolBar;
  10. import javax.swing.JLabel;
  11. import javax.swing.JMenuBar;
  12. import javax.swing.JMenu;
  13. import javax.swing.JMenuItem;
  14. import javax.swing.JOptionPane;
  15.  
  16. import java.awt.CardLayout;
  17. import javax.swing.JTextField;
  18. import java.awt.Color;
  19. import javax.swing.SwingConstants;
  20. import java.awt.GridBagLayout;
  21. import java.awt.GridBagConstraints;
  22. import javax.swing.JComboBox;
  23. import javax.swing.JSpinner.DateEditor;
  24. import javax.swing.JSpinner;
  25.  
  26. import org.jdatepicker.impl.JDatePanelImpl;
  27.  
  28. import org.jdatepicker.impl.JDatePickerImpl;
  29. import org.jdatepicker.impl.UtilDateModel;
  30. import org.jdatepicker.util.JDatePickerUtil;
  31. import javax.swing.JTextPane;
  32. import javax.swing.DropMode;
  33. import javax.swing.JTable;
  34. import java.awt.GridLayout;
  35. import javax.swing.JButton;
  36. import javax.swing.BoxLayout;
  37. import java.awt.Insets;
  38. import java.awt.event.ActionListener;
  39. import java.text.DateFormat;
  40. import java.text.SimpleDateFormat;
  41. import java.time.LocalDate;
  42. import java.util.Date;
  43. import java.util.Properties;
  44. import java.awt.event.ActionEvent;
  45. import java.awt.Container;
  46.  
  47. public class Agenda1 {
  48.  
  49. private JFrame frame;
  50. private JTextField textEvento;
  51. private JTextField textTipo;
  52. private JTextField textHoraInicio;
  53. private JTextField textDuracao;
  54. private JTextField textLocal;
  55.  
  56. /**
  57. * Launch the application.
  58. */
  59. public static void main(String[] args) {
  60. EventQueue.invokeLater(new Runnable() {
  61. public void run() {
  62. try {
  63. Agenda1 window = new Agenda1();
  64. window.frame.setVisible(true);
  65. } catch (Exception e) {
  66. e.printStackTrace();
  67. }
  68. }
  69. });
  70. }
  71.  
  72. /**
  73. * Create the application.
  74. */
  75. public Agenda1() {
  76. initialize();
  77. }
  78.  
  79. /**
  80. * Initialize the contents of the frame.
  81. */
  82. private void initialize() {
  83. frame = new JFrame();
  84. frame.setBounds(100, 100, 450, 300);
  85. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  86. frame.getContentPane().setLayout(new CardLayout(0, 0));
  87.  
  88. JScrollPane scrollPane = new JScrollPane();
  89. frame.getContentPane().add(scrollPane, "name_7610722565189");
  90.  
  91. JPanel panelEditar = new JPanel();
  92. frame.getContentPane().add(panelEditar, "panelEditar");
  93. panelEditar.setLayout(new CardLayout(0, 0));
  94.  
  95. JScrollPane scrollPane_1 = new JScrollPane();
  96. frame.getContentPane().add(scrollPane_1, "name_7610739268910");
  97.  
  98. JMenuBar menuBar = new JMenuBar();
  99. frame.setJMenuBar(menuBar);
  100.  
  101. JMenu mnConsultar = new JMenu("Consultar");
  102. menuBar.add(mnConsultar);
  103.  
  104. JMenuItem mntmDia = new JMenuItem("Dia");
  105. mnConsultar.add(mntmDia);
  106.  
  107. JMenu mnEvento = new JMenu("Evento");
  108. menuBar.add(mnEvento);
  109.  
  110.  
  111. JMenuItem mntmEditar = new JMenuItem("Editar");
  112. mntmEditar.addActionListener(new ActionListener() {
  113.  
  114. public void actionPerformed(ActionEvent arg0) {
  115.  
  116. CardLayout card=(CardLayout)frame.getContentPane().getLayout();
  117. card.show(frame.getContentPane(), "panelEditar");
  118.  
  119.  
  120. }
  121. });
  122.  
  123. mnEvento.add(mntmEditar);
  124.  
  125.  
  126. JMenuItem mntmApagar = new JMenuItem("Apagar");
  127. mnEvento.add(mntmApagar);
  128.  
  129.  
  130.  
  131. JMenuItem mntmInserir = new JMenuItem("Inserir");
  132. mntmInserir.addActionListener(new ActionListener() {
  133. public void actionPerformed(ActionEvent e) {
  134. CardLayout card=(CardLayout)frame.getContentPane().getLayout();
  135.  
  136. card.show(frame.getContentPane(), "panelEvento");
  137. }
  138. });
  139. // mntmInserir.addActionListener(new ActionListener() {
  140. // public void actionPerformed(ActionEvent e) {
  141. // GridBagLayout panel=(GridBagLayout)frame.getContentPane().getLayout();
  142. // panel.add(frame.getContentPane(), "panelEvento");
  143. // }
  144. //});
  145. /*JMenuItem mntmConsultar = new JMenuItem("Consultar");
  146. mntmConsultar.addActionListener(new ActionListener() {
  147. public void actionPerformed(ActionEvent e) {
  148. preencheTabelaMovimentos();
  149. CardLayout card=(CardLayout)frame.getContentPane().getLayout();
  150. card.show(frame.getContentPane(), "panelConsultar");
  151. }
  152. });
  153.  
  154. */
  155. mnEvento.add(mntmInserir);
  156. JPanel panelConsultarDia = new JPanel();
  157. panelConsultarDia.setBackground(new Color(245, 255, 250));
  158. scrollPane.setViewportView(panelConsultarDia);
  159. GridBagLayout gbl_panelConsultarDia = new GridBagLayout();
  160. gbl_panelConsultarDia.columnWidths = new int[]{0, 0, 0, 0, 53, 102, 55, 0};
  161. gbl_panelConsultarDia.rowHeights = new int[]{0, 0, 0, 0, 0, 0};
  162. gbl_panelConsultarDia.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
  163. gbl_panelConsultarDia.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
  164. panelConsultarDia.setLayout(gbl_panelConsultarDia);
  165.  
  166.  
  167. UtilDateModel model = new UtilDateModel();
  168. LocalDate hoje=LocalDate.now();
  169. model.setDate(hoje.getYear(), hoje.getMonthValue()-1, hoje.getDayOfMonth());
  170. Properties p = new Properties();
  171. p.put("text.today", "Hoje");
  172. p.put("text.month", "Mês");
  173. p.put("text.year", "Ano");
  174. JDatePanelImpl datePanel = new JDatePanelImpl(model, p);
  175. JDatePickerImpl datePicker = new JDatePickerImpl(datePanel, new DateLabelFormatter1());
  176. GridBagConstraints gbc_datePicker = new GridBagConstraints();
  177. gbc_datePicker.insets = new Insets(0, 0, 5, 5);
  178. gbc_datePicker.gridx = 1;
  179. gbc_datePicker.gridy = 0;
  180. panelConsultarDia.add(datePicker, gbc_datePicker);
  181.  
  182. JButton btnSelecionar = new JButton("Selecionar");
  183. btnSelecionar.addActionListener(new ActionListener() {
  184. public void actionPerformed(ActionEvent arg0) {
  185. Date selectedDate = (Date) datePicker.getModel().getValue();
  186. DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
  187. String reportDate = df.format(selectedDate);
  188. }
  189. });
  190. GridBagConstraints gbc_btnSelecionar = new GridBagConstraints();
  191. gbc_btnSelecionar.insets = new Insets(0, 0, 5, 5);
  192. gbc_btnSelecionar.gridx = 2;
  193. gbc_btnSelecionar.gridy = 0;
  194. panelConsultarDia.add(btnSelecionar, gbc_btnSelecionar);
  195.  
  196.  
  197. /* no actionPerformed
  198. * Date selectedDate = (Date) datePicker.getModel().getValue();
  199. DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
  200. String reportDate = df.format(selectedDate);
  201. */
  202.  
  203. JPanel panelEvento = new JPanel();
  204. panelEvento.setBackground(Color.WHITE);
  205. frame.getContentPane().add(panelEvento, "panelEvento");
  206. GridBagLayout gbl_panelEvento = new GridBagLayout();
  207. gbl_panelEvento.columnWidths = new int[]{0, 92, 0, 0};
  208. gbl_panelEvento.rowHeights = new int[]{0, 0, 27, 27, 32, 28, 0};
  209. gbl_panelEvento.columnWeights = new double[]{0.0, 0.0, 1.0, Double.MIN_VALUE};
  210. gbl_panelEvento.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
  211. panelEvento.setLayout(gbl_panelEvento);
  212.  
  213. JLabel lblEvento = new JLabel("Evento");
  214. GridBagConstraints gbc_lblEvento = new GridBagConstraints();
  215. gbc_lblEvento.insets = new Insets(0, 0, 5, 5);
  216. gbc_lblEvento.gridx = 1;
  217. gbc_lblEvento.gridy = 1;
  218. panelEvento.add(lblEvento, gbc_lblEvento);
  219.  
  220. textEvento = new JTextField();
  221. GridBagConstraints gbc_textEvento = new GridBagConstraints();
  222. gbc_textEvento.insets = new Insets(0, 0, 5, 0);
  223. gbc_textEvento.fill = GridBagConstraints.HORIZONTAL;
  224. gbc_textEvento.gridx = 2;
  225. gbc_textEvento.gridy = 1;
  226. panelEvento.add(textEvento, gbc_textEvento);
  227. textEvento.setColumns(10);
  228.  
  229. JLabel lblTipo = new JLabel("Tipo");
  230. GridBagConstraints gbc_lblTipo = new GridBagConstraints();
  231. gbc_lblTipo.insets = new Insets(0, 0, 5, 5);
  232. gbc_lblTipo.gridx = 1;
  233. gbc_lblTipo.gridy = 2;
  234. panelEvento.add(lblTipo, gbc_lblTipo);
  235.  
  236. textTipo = new JTextField();
  237. GridBagConstraints gbc_textTipo = new GridBagConstraints();
  238. gbc_textTipo.insets = new Insets(0, 0, 5, 0);
  239. gbc_textTipo.fill = GridBagConstraints.HORIZONTAL;
  240. gbc_textTipo.gridx = 2;
  241. gbc_textTipo.gridy = 2;
  242. panelEvento.add(textTipo, gbc_textTipo);
  243. textTipo.setColumns(10);
  244.  
  245. JLabel lblHoraDeInicio = new JLabel("Hora de Inicio");
  246. GridBagConstraints gbc_lblHoraDeInicio = new GridBagConstraints();
  247. gbc_lblHoraDeInicio.insets = new Insets(0, 0, 5, 5);
  248. gbc_lblHoraDeInicio.gridx = 1;
  249. gbc_lblHoraDeInicio.gridy = 3;
  250. panelEvento.add(lblHoraDeInicio, gbc_lblHoraDeInicio);
  251.  
  252. textHoraInicio = new JTextField();
  253. GridBagConstraints gbc_textHoraInicio = new GridBagConstraints();
  254. gbc_textHoraInicio.insets = new Insets(0, 0, 5, 0);
  255. gbc_textHoraInicio.fill = GridBagConstraints.HORIZONTAL;
  256. gbc_textHoraInicio.gridx = 2;
  257. gbc_textHoraInicio.gridy = 3;
  258. panelEvento.add(textHoraInicio, gbc_textHoraInicio);
  259. textHoraInicio.setColumns(10);
  260.  
  261. JLabel lblDurao = new JLabel("Dura\u00E7\u00E3o");
  262. GridBagConstraints gbc_lblDurao = new GridBagConstraints();
  263. gbc_lblDurao.insets = new Insets(0, 0, 5, 5);
  264. gbc_lblDurao.gridx = 1;
  265. gbc_lblDurao.gridy = 4;
  266. panelEvento.add(lblDurao, gbc_lblDurao);
  267.  
  268. textDuracao = new JTextField();
  269. GridBagConstraints gbc_textDuracao = new GridBagConstraints();
  270. gbc_textDuracao.insets = new Insets(0, 0, 5, 0);
  271. gbc_textDuracao.fill = GridBagConstraints.HORIZONTAL;
  272. gbc_textDuracao.gridx = 2;
  273. gbc_textDuracao.gridy = 4;
  274. panelEvento.add(textDuracao, gbc_textDuracao);
  275. textDuracao.setColumns(10);
  276.  
  277. JLabel lblLocal = new JLabel("Local");
  278. GridBagConstraints gbc_lblLocal = new GridBagConstraints();
  279. gbc_lblLocal.insets = new Insets(0, 0, 0, 5);
  280. gbc_lblLocal.gridx = 1;
  281. gbc_lblLocal.gridy = 5;
  282. panelEvento.add(lblLocal, gbc_lblLocal);
  283.  
  284. textLocal = new JTextField();
  285. GridBagConstraints gbc_textLocal = new GridBagConstraints();
  286. gbc_textLocal.fill = GridBagConstraints.HORIZONTAL;
  287. gbc_textLocal.gridx = 2;
  288. gbc_textLocal.gridy = 5;
  289. panelEvento.add(textLocal, gbc_textLocal);
  290. textLocal.setColumns(10);
  291.  
  292.  
  293. }
  294.  
  295. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement