Advertisement
TrodelHD

Untitled

Mar 14th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. package Spiel;
  2.  
  3. import java.awt.BasicStroke;
  4. import java.awt.Color;
  5. import java.awt.Container;
  6. import java.awt.Font;
  7. import java.awt.event.ActionEvent;
  8. import java.awt.event.ActionListener;
  9.  
  10. import javax.swing.JButton;
  11. import javax.swing.JColorChooser;
  12. import javax.swing.JFrame;
  13. import javax.swing.JPanel;
  14. import javax.swing.JScrollPane;
  15. import javax.swing.JSlider;
  16. import javax.swing.JTextArea;
  17. import javax.swing.event.ChangeEvent;
  18. import javax.swing.event.ChangeListener;
  19.  
  20. public class MyPanelRater extends JPanel {
  21.  
  22. public Connection con;
  23.  
  24. public MyPanelRater() {
  25.  
  26. this.show();
  27. }
  28.  
  29. private static DrawAreaRater drawArea;
  30. private Color oldColor = Color.BLACK;
  31. private JButton send;
  32. private JTextArea log;
  33. private JScrollPane anzeige;
  34. public void show() {
  35. // create main frame
  36. JFrame frame = new JFrame("Raten");
  37. Container content = frame.getContentPane();
  38. //Set buttons Action listener
  39. ActionListener actionListener = new ActionListener() {
  40. public void actionPerformed(ActionEvent e) {
  41. if (e.getSource() == send) {
  42. JColorChooser colorChooser = new JColorChooser();
  43. Color c = colorChooser.showDialog(null, "color", oldColor);
  44. drawArea.setColor(c);
  45. oldColor = c;
  46. }
  47. }
  48. };
  49. //
  50. JPanel controls = new JPanel();
  51. addLog(frame);
  52. //send Button
  53. send = new JButton("send");
  54. send.setBounds(520, 410, 200, 30);
  55. send.addActionListener(actionListener);
  56. frame.add(send);
  57. // create draw area
  58. drawArea = new DrawAreaRater();
  59. drawArea.radius = 4;
  60. // add to content pane
  61. content.add(drawArea);
  62. //Setze Frame größe
  63. frame.setSize(740, 600);
  64. //Setze frame nicht größenverziebar
  65. frame.setResizable(false);
  66. // can close frame
  67. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  68. // show the swing paint result
  69. frame.setVisible(true);
  70.  
  71. // Now you can try our Swing Paint !!! Enjoy <img draggable="false" class="emoji" alt="😀" src="https://s.w.org/images/core/emoji/2.3/svg/1f600.svg">
  72. }
  73. private void addLog(JFrame controls) {
  74. Font font = new Font("Calibri", Font.BOLD, 20);
  75.  
  76. log = new JTextArea();
  77. log.setEditable(false);
  78. log.setFont(font);
  79. log.setForeground(new Color(0, 0, 0));
  80. String Text="Test";
  81. log.setText(Text);
  82. anzeige = new JScrollPane(log);
  83. anzeige.setBounds(520, 0, 200, 400);
  84. controls.add(anzeige);
  85.  
  86. }
  87. public static void drawLine(int radius, int oldX, int oldY, int currentX, int currentY,int r ,int g, int b){
  88. drawArea.drawLine(radius, oldX, oldY, currentX, currentY, r, g, b);
  89. }
  90. public static void clear(){
  91. drawArea.clear();
  92. }
  93.  
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement