Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Spiel;
- import java.awt.BasicStroke;
- import java.awt.Color;
- import java.awt.Container;
- import java.awt.Font;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.JButton;
- import javax.swing.JColorChooser;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.JScrollPane;
- import javax.swing.JSlider;
- import javax.swing.JTextArea;
- import javax.swing.event.ChangeEvent;
- import javax.swing.event.ChangeListener;
- public class MyPanelRater extends JPanel {
- public Connection con;
- public MyPanelRater() {
- this.show();
- }
- private static DrawAreaRater drawArea;
- private Color oldColor = Color.BLACK;
- private JButton send;
- private JTextArea log;
- private JScrollPane anzeige;
- public void show() {
- // create main frame
- JFrame frame = new JFrame("Raten");
- Container content = frame.getContentPane();
- //Set buttons Action listener
- ActionListener actionListener = new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (e.getSource() == send) {
- JColorChooser colorChooser = new JColorChooser();
- Color c = colorChooser.showDialog(null, "color", oldColor);
- drawArea.setColor(c);
- oldColor = c;
- }
- }
- };
- //
- JPanel controls = new JPanel();
- addLog(frame);
- //send Button
- send = new JButton("send");
- send.setBounds(520, 410, 200, 30);
- send.addActionListener(actionListener);
- frame.add(send);
- // create draw area
- drawArea = new DrawAreaRater();
- drawArea.radius = 4;
- // add to content pane
- content.add(drawArea);
- //Setze Frame größe
- frame.setSize(740, 600);
- //Setze frame nicht größenverziebar
- frame.setResizable(false);
- // can close frame
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- // show the swing paint result
- frame.setVisible(true);
- // 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">
- }
- private void addLog(JFrame controls) {
- Font font = new Font("Calibri", Font.BOLD, 20);
- log = new JTextArea();
- log.setEditable(false);
- log.setFont(font);
- log.setForeground(new Color(0, 0, 0));
- String Text="Test";
- log.setText(Text);
- anzeige = new JScrollPane(log);
- anzeige.setBounds(520, 0, 200, 400);
- controls.add(anzeige);
- }
- public static void drawLine(int radius, int oldX, int oldY, int currentX, int currentY,int r ,int g, int b){
- drawArea.drawLine(radius, oldX, oldY, currentX, currentY, r, g, b);
- }
- public static void clear(){
- drawArea.clear();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement