Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.29 KB | None | 0 0
  1. package user;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.EventQueue;
  5.  
  6. import javax.swing.JFrame;
  7. import javax.swing.JPanel;
  8. import javax.swing.border.EmptyBorder;
  9. import javax.swing.text.JTextComponent;
  10. import javax.swing.JComboBox;
  11. import javax.swing.JTextField;
  12. import javax.swing.JLabel;
  13. import java.awt.Font;
  14. import java.awt.TextArea;
  15.  
  16. import javax.swing.JCheckBoxMenuItem;
  17. import javax.swing.JSplitPane;
  18. import javax.swing.JSeparator;
  19. import javax.swing.SwingConstants;
  20. import java.awt.Color;
  21. import javax.swing.JButton;
  22. import javax.swing.JTextPane;
  23. import javax.swing.JEditorPane;
  24. import javax.swing.JList;
  25. import javax.swing.JTextArea;
  26. import javax.swing.DefaultComboBoxModel;
  27. import java.awt.event.ActionListener;
  28. import java.awt.geom.Area;
  29. import java.sql.Connection;
  30. import java.sql.DriverManager;
  31. import java.sql.ResultSet;
  32. import java.sql.Statement;
  33. import java.awt.event.ActionEvent;
  34.  
  35. public class Dashboard extends JFrame {
  36.  
  37. private JPanel contentPane;
  38. private final JSeparator separator = new JSeparator();
  39. private JTextField titre_article;
  40. JTextArea test;
  41.  
  42. /**
  43. * Launch the application.
  44. */
  45. public static void main(String[] args) {
  46. EventQueue.invokeLater(new Runnable() {
  47. public void run() {
  48. try {
  49. Dashboard frame = new Dashboard();
  50. frame.setVisible(true);
  51. } catch (Exception e) {
  52. e.printStackTrace();
  53. }
  54. }
  55. });
  56. }
  57.  
  58. /**
  59. * Create the frame.
  60. */
  61. public Dashboard() {
  62. setBackground(Color.BLUE);
  63. setTitle("SupNews");
  64. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  65. setBounds(100, 100, 531, 447);
  66. contentPane = new JPanel();
  67. contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  68. setContentPane(contentPane);
  69. contentPane.setLayout(null);
  70.  
  71. JLabel lblNewArticle = new JLabel("New article");
  72. lblNewArticle.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 18));
  73. lblNewArticle.setBounds(181, 12, 109, 31);
  74. contentPane.add(lblNewArticle);
  75.  
  76. JLabel lblYour = new JLabel("Your articles");
  77. lblYour.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 18));
  78. lblYour.setBounds(26, 12, 122, 31);
  79. contentPane.add(lblYour);
  80. separator.setForeground(Color.BLACK);
  81. separator.setOrientation(SwingConstants.VERTICAL);
  82. separator.setBounds(161, 0, 27, 387);
  83. contentPane.add(separator);
  84.  
  85. JLabel lblTitle = new JLabel("Title");
  86. lblTitle.setFont(new Font("Times New Roman", Font.PLAIN, 17));
  87. lblTitle.setBounds(188, 57, 63, 19);
  88. contentPane.add(lblTitle);
  89.  
  90. titre_article = new JTextField();
  91. titre_article.setBounds(237, 54, 183, 22);
  92. contentPane.add(titre_article);
  93. titre_article.setColumns(10);
  94. //*******************************************************************************//
  95. JButton btnSave = new JButton("Save");
  96. btnSave.addActionListener(new ActionListener() {
  97. public void actionPerformed(ActionEvent arg0) {
  98.  
  99. try {
  100. // init
  101. String titre = titre_article.getText();
  102. String champ = test.getText();
  103.  
  104. Class.forName("com.mysql.jdbc.Driver");
  105. Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/supnews?useSSL=true","root","");
  106. Statement st =con.createStatement();
  107. st.executeUpdate("INSERT INTO article (Title, Content) VALUES (\'"+titre+"\', \'"+champ+"\')");
  108. }catch(Exception e) {System.out.print(e);}
  109. }
  110. //*******************************************************************************//
  111.  
  112. });
  113. btnSave.setBounds(438, 329, 63, 25);
  114. contentPane.add(btnSave);
  115.  
  116. JButton btnNewButton = new JButton("Preview");
  117. btnNewButton.setBounds(330, 329, 90, 25);
  118. contentPane.add(btnNewButton);
  119.  
  120. JButton btnNewButton_1 = new JButton("Add image...");
  121. btnNewButton_1.setBounds(175, 329, 115, 25);
  122. contentPane.add(btnNewButton_1);
  123.  
  124. JSeparator separator_1 = new JSeparator();
  125. separator_1.setForeground(Color.BLACK);
  126. separator_1.setBounds(-11, 385, 536, 15);
  127. contentPane.add(separator_1);
  128.  
  129. JList list = new JList();
  130. list.setBounds(8, 54, 140, 260);
  131. contentPane.add(list);
  132.  
  133. JTextArea area_text = new JTextArea();
  134. area_text.setBounds(175, 89, 326, 225);
  135. test = area_text;
  136. contentPane.add(area_text);
  137.  
  138. JButton del_article = new JButton("delete");
  139. del_article.setBounds(52, 329, 97, 25);
  140. contentPane.add(del_article);
  141. }
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement