עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

שחזור ציור |java,swing

Featured Replies

פורסם

המשתמש מצייר על פנאל על ידי גרירת עכבר ועל ידי לחיצת קונטרול ורווח נפתחת לו חלונית שבה הוא בוחר את עובי,צבע,ומהירות שחזור הציור.

 

משום מה נוצר מצב בשחזור שישנה נקודה קטנה(filloval ) והיא רצה על כל נקודות מערך הציור ולא עושה כלום.

 

אשמח לעזרה,

import java.awt.BorderLayout;
import java.awt.Color;

import java.awt.Font;
import java.awt.Graphics;
import java.awt.Label;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.font.TextAttribute;
import java.text.AttributedString;
import java.util.ArrayList;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.Timer;

public class panel extends JPanel implements MouseMotionListener {
	private ArrayList<Point> arrPoints = new ArrayList<Point>();// array of
																// point
	private int stroke = 10;
	private Color color = Color.BLACK;
	private String str = "RECORDING..";
	private Font font = new Font(getName(), Font.ITALIC | Font.BOLD, 14);
	private int delay = 40;
	private boolean isRestore;
	private static int i = 0;
	private Timer timer = new Timer(delay, new ActionListener() {

		@Override
		public void actionPerformed(ActionEvent e) {

			repaint();

		}
	});

	/*********************************************/
	public panel() {
		this.addMouseMotionListener(this);
		this.setLayout(new BorderLayout());
		timer.start();
	}

	/*********************************************/
	public void setThickness(int thickLevel) {
		this.stroke = thickLevel;
		repaint();
	}

	public Color getColor() {
		return this.color;

	}

	public void setColor(Color color) {
		this.color = color;
		repaint();

	}

	public void restore() {
		isRestore = true;
		repaint();
	}

	public void setTimer(int delay) {
		this.delay = delay;
	}

	/*********************************************/
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		if (!isRestore)
			g.setColor(color.RED);
		else {
			this.str = "RESTORING...";
			g.setColor(color.BLACK);
		}
		g.setFont(font);
		g.drawString(str, 20, 20);
		g.setColor(getColor());
		if (!isRestore) {
			for (Point i : arrPoints) {
				g.fillOval(i.x, i.y, stroke, stroke);

			}
		} else {
			
			if (i < arrPoints.size()) {
				g.fillOval(arrPoints.get(i).x, arrPoints.get(i).y, stroke, stroke);
				i++;
			}
		}

	}

	@Override
	public void mouseDragged(MouseEvent e) {
		arrPoints.add(new Point(e.getX(), e.getY()));
		repaint();

	}

	@Override
	public void mouseMoved(MouseEvent e) {
		// TODO Auto-generated method stub

	}

}

 

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.