As what was stated on the header I want to implement either a "paint" or "eraser" function whichever feature more convenient for user to edit paint/censor unwanted parts of a photo displayed on a imageview before uploading it to a server in the edited format and a redo function if user makes a mistake while editing? How do I come about doing it, I've read relevant topics on Canvas, or FingerPaint but still puzzled on how to implement it based on the scenario in this link [here](https://drive.google.com/file/d/0B2rvGRbu0A83LU1pQjRicnNFS0U/view)? Thanks for any help rendered! idImage = (ImageView)findViewById(R.id.idImage); Bitmap bitmap = null; bitmap …

Member Avatar
Member Avatar
+0 forum 1

i am confuse about `paint()` method in applet .The confusion is that paint method is getting object as parameter of Graphics class like this `public void paint(Graphics g)` and i read that the Graphics class is an abstract class then how we create object of Graphics class and now you will say that g in Graphics g is reference not actual object and we can create reference of abstract class i know this but g is a reference not object then how can we call a class member with reference object same like this `g.drawString("hello world",15,30)` this is out of …

Member Avatar
Member Avatar
+0 forum 12

Hi. I have a JFrame with a JLayeredPane. On the first layer there is a table, then above it there is black transparent layer that allows me options and what-not. I animate the arrival of this transparent layer. However when I do this the panel seems to loose it's transparency, that is until I interact with the base layer, THEN I see through the transparent layer again. Sometimes, when I start interacting with the textfield or button on the transparent level, it starts displaying pieces and bits of the lower layer on the Transparent layer. Am I missing the need …

Member Avatar
Member Avatar
+0 forum 2

import java.awt.Point; import javax.swing.*; import java.awt.Graphics; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapter; import javax.swing.JPanel; public class painttest extends JPanel { private int pointCount = 0; private Point[] points = new Point[1000]; public painttest(){ addMouseMotionListener(new MouseMotionAdapter() {public void MouseDragged(MouseEvent event){ if(pointCount<points.length) {points[ pointCount ] = event.getPoint(); // find point ++pointCount; // increment number of points in array repaint(); }}});} public void paintComponent( Graphics g ) { super.paintComponent( g ); // clears drawing area // draw all points in array for ( int i = 0; i < pointCount; i++ ) g.fillOval( points[i].x,points[i].y , 4, 4 ); } // end method paintComponent } Hello. …

Member Avatar
Member Avatar
+0 forum 2

Hi All, Im still finding it hard to understand Paint method, Almost all websites i had gone thru, they are showing examples of how to use it in an applet. I just cant understand on how to use it in a GUI application by extending Jframe object. Here is one example, i want to create an oval shape Button to use it in my program. Im starting my program in this way, package painttest; import Javax.swing.*; import Java.awt.* public class PaintTest extends JFrame { private JButton oval; private static final int HEIGHT = 400; private static final int WIDTH = …

Member Avatar
Member Avatar
+0 forum 2

Hi All, I have a doubt in paint method of the Component Class. I know how to use that in Applet but im finding it hard to use it in GUI app. Im posting my code here, please edit it to make the program use paint method to render any GUI component. Be it any Component, any Rendering, i just want a push up on how to use that method. Thanks import java.awt.event.ActionEvent; import javax.swing.*; import java.awt.*; import java.awt.event.ActionListener; import java.text.DecimalFormat; public class MetricConversion extends JFrame{ private static final int WIDTH = 400; private static final int HEIGHT = 400; …

Member Avatar
Member Avatar
+0 forum 5

I have been looking over past exam papers for revision for an upcoming uni exam for Java and one of the questions was, asking for code to add to a given abacus program to make the grid display 3 counters in each column of a 10x6. e.g. as soon as the JPanel opens. So far the current program enables the user to click in each column and add counters to each column, so you can do this manually but it is not the way to do it as when its run there are no counters present in the abacus grid. …

Member Avatar
Member Avatar
+0 forum 4

Hello! I am using for the first time the JTabbedPane. The problem that I have is that I want to apply the paint method only for the first tab, but it also paints the second one. How can I solve this problem?

Member Avatar
Member Avatar
+0 forum 1

Just a simple Jython code to test drawing on the canvas.

Member Avatar
+3 forum 0

Hi, i'm making a server client piant program that send what is painted on the server to the client(and vice versa). this program is supposed to use instruction based transmission of the image. i have a server client program that sends what is drawn on the server to the client but it uses image based tranmission of the image and i'm not sure how to change this from image based to instruction based. (I made the image based sending first because this is part of my homework and the image based program is worth more points. needless to say i …

Member Avatar
Member Avatar
+0 forum 4

I have this paint program and i'm having a very silly problem. I'm trying to set the paint area to west position using border layout but when i do that it doesn't show up when i run the program. if i set it in the center it shows up. everything works fine except that i need the paint area to be set west because something else needs to go in the center position. i know the answer is staring me in the face but i just cant figure it out. I put a comment in the code where the problem …

Member Avatar
Member Avatar
+0 forum 2

Hi everyone, I was writing a program to show visually some vectors I was implementing with Java but I ran into an issue. My program has 3 classes, a driver, a Vector class and a VectorDisplay. The driver and vector class are self explanatory, but here is the code. Driver: import phys.*; import java.util.*; public class Driver { public static Vector1 vect1 = new Vector1(50, 70); public static void dispVectStats() { vect1.dispVect(); vect1.drawVect(); } public static void main(String[] args) { System.out.print("\f"); dispVectStats(); } } Vector: package phys; import java.util.*; public class Vector1 { private int x; private int y; public …

Member Avatar
Member Avatar
+0 forum 3

Am trying to draw image on jpanel or jlabel when button is been click on, so i added actionperformed on my button as follows. private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: Image imag = new ImageIcon(this.getClass().getResource("img/top_bg.jpg")).getImage(); showPix1.setLayout(new BorderLayout()); showPix1.add(new paintPhotos(imag,20,20), BorderLayout.CENTER); } I have a separate class called paintPhotos that extends jLabel as follows package myApp; import java.awt.*; import javax.swing.*; public class paintPhotos extends javax.swing.JLabel { public Image img; int w; int h; public paintPhotos(Image img, int w, int h) { this.img = img; this.w = w; this.h = h; System.out.println("am paintclass"); } @Override public …

Member Avatar
Member Avatar
+0 forum 7

Ok so basically I want to know how I can paint multiple items to the screen without using all of my laptop CPU power. I was thinking that it may be possible to arrange the items as a bitmap and then paint that bitmap to the screen but im not entirely sure how to go about doing this so would value any help that can be given. Thanks in advance for your replies

Member Avatar
Member Avatar
+0 forum 4

I have this code and I have been trying to figure it out for a while now but i cant get it to work .My basicproblem is I cant get the paint part or the programme to work properly. I have done several paint programmes in the past but i seem to have forgotten how to make them properly ,anyway heres the code import java.awt.*; import java.awt.event.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import javax.imageio.ImageIO; import javax.swing.*; public class Javamark102 extends JPanel{ static JFrame rem; static Javamark102 soho= new Javamark102(); static JFileChooser save; static JFileChooser open; …

Member Avatar
Member Avatar
+0 forum 1

Hi, could some one look over my code I by myself dont get where the flaw is. It should paint 1 cube at a time but now it runs all the code through and paints all at once. package net.viped; import java.awt.Color; import java.awt.Graphics; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import javax.swing.JFrame; import javax.swing.JPanel; class Tetris extends JPanel { private int[][] occupied = new int[10][20]; public Tetris() { addKeyListener(new ListenKeys()); setFocusable(true); initGame(); } public void initGame() { for (int i = 0; i < occupied.length; i++) { for (int j = 0; j < 20; j++) { occupied[i][j] = 0; } } …

Member Avatar
Member Avatar
+0 forum 2

In a previous thread i had described a problem i had to transfer a frame or panel and all it's components as an image into a buffered image. I thought i had found the solution but it seems i am doing something wrong. In line 162 i call the method Bimage(lines 87 - 92) to do this job.But what i get is just the background of the panel and not what is drawn on it.I used try { ImageIO.write(bimage, "jpg", new File("C:/bimagepaint.jpg")); } catch (IOException e){ } to find out what this method produces. Any suggestions? package game; import java.awt.*; …

Member Avatar
Member Avatar
+0 forum 1

hi, I'm currently building a game and stuck at the paintComponent method. I'm trying to add 3 graphic buttons to the JPanel but the paintComponent does not execute (all I get is gray window) here's my code : public class TwinMoonTowers extends JPanel implements ActionListener{ private class TMTMenu extends MouseAdapter{ private Icon start, shop, quit; private Icon main_bg; public TMTMenu (){ System.out.println("starting menu..."); start = new Icon(TMTConstant.START_SOURCE, TMTConstant.START_COORD_X, TMTConstant.START_COORD_Y); shop = new Icon (TMTConstant.SHOP_SOURCE, TMTConstant.SHOP_COORD_X, TMTConstant.SHOP_COORD_Y); quit = new Icon (TMTConstant.EXIT_SOURCE, TMTConstant.EXIT_COORD_X, TMTConstant.EXIT_COORD_Y); main_bg = new Icon (TMTConstant.MAIN_MENU_BG, 0, 0); } @Override public void mousePressed(MouseEvent me){ int x = me.getX(); …

Member Avatar
+0 forum 0

Hey all, I have been wanting to make a cool game in jave such as a fighting game starting off simple with drwing stick figures :). But i was wondering why there are so many java games created in Japplet why not use swing- i know there are games out there that do but why dont all?

Member Avatar
Member Avatar
+0 forum 2

Hi, i need a source code in assembly that make paint imvironment such as windows paint...not so profetionally like that...just when i drag a shape such as rectangle and drop this, draw a big rectangle. i want execute this code in c ... thanks ...

Member Avatar
Member Avatar
+0 forum 4

hi. i'm trying to make a program that will connect two points that i click in my JPanel. i'm trying to connect the two points with a line. i displayed the values of my (x1, y1) and (x2,y2) coordinates whenever i click using the mouse and there is no error in the values. but when the line is displayed, it the line doesn't seem to follow the coordinates i specify but instead outputs in a different location and is distorted. most of the lines will appear to be cut by something, i think it's the rectangle created by the line …

Member Avatar
Member Avatar
+0 forum 2

My objective is actually [B]extremely[/B] simple, but I just don't know how to do it. I want to put some swing components on top of graphics which fills the entire screen. That's it. And I can't figure out how to do it... Some other side-questions that I would love to be answered: For double-buffering, which is better for performance: BufferedImage or VolatileImage? Which is better for display (consistent graphics, no flashing whatsoever)? Why does JFrame seem to handle graphics better than Frame (without adding a Thread.sleep() function in a Frame class, the graphics flash [when double-buffering with VolatileImage]. When I …

Member Avatar
Member Avatar
+0 forum 1

Hey guys, I have just finished a very simplistic game where the object of the game is to move out of the way of a falling block. Still only version 1 so don't expect much but your welcome to have a go and post any feedback on this thread. Looking to see if there's anything people would like to see added to it Thanks

Member Avatar
Member Avatar
+0 forum 1

I am trying to load a background in full screen mode, but when i run my program the screen is just white. Can someone point me to the reason why? [CODE]import java.awt.*; import javax.swing.*; public class DrawComponents { GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice device = env.getDefaultScreenDevice(); GraphicsConfiguration gc = device.getDefaultConfiguration(); Image bg = new ImageIcon("stewie.jpg").getImage(); public void run(){ setFrame(); loadImages(); try{Thread.sleep(5000);} catch(Exception e){} System.exit(0); } public void setFrame(){ JFrame frame = new JFrame(gc); frame.setUndecorated(true); frame.setResizable(false); frame.setIgnoreRepaint(true); device.setFullScreenWindow(frame); device.setDisplayMode(new DisplayMode(800, 600, 32, 0)); } public void loadImages(){ bg = new ImageIcon("stewie.jpg").getImage(); } public void paint(Graphics g) { g.drawImage(bg, 400, 300, null); …

Member Avatar
Member Avatar
+0 forum 3

I am trying to write a multi-window text editor. I have a Page Control containing 20 pages, and each page (tab sheet) contains an instance of my editor. Which works mostly ok, except I sometimes get weird results when painting my editor window. The attached code is a greatly cut-down version (which isn't a text editor any more, just a TWinControl that paints a single line of text) to illustrate the problem. Sometimes the message text is displayed correctly, and sometimes (i.e. for some tabs) either the message doesn't show at all or it appears in the wrong place or …

Member Avatar
Member Avatar
+0 forum 4

Hi all, This is my first post here so please bear with me. I am trying to get my QGraphicsView widget to output as an image. I have the following code. [CODE] def outputImg(self,dir=None): if dir == None: dir = os.getcwd() img = QtGui.QImage(self.size()) print img.isNull() # This == True painter = QtGui.QPainter(img); # Error here when init calls the begin() method self.render(painter); img.save(os.path.join(dir,'img.png')); [/CODE] The error i get is the following: QPainter::begin: Paint device returned engine == 0, type: 3 I realize this is because img.isNull() == True from doing some research I'm just not sure how to correct …

Member Avatar
Member Avatar
+0 forum 1

Hey here's my code for functioning like MS Paint. But JLabels are just not visible. Please Help. [CODE] import java.awt.event.*; import javax.swing.*; import java.awt.*; import java.awt.image.*; public class MSPaint { JFrame frame; JPanel panel; Painting paint = new Painting(); public MSPaint() { frame = new JFrame("MS Paint"); frame.setSize(1024,768); panel = new JPanel(); frame.getContentPane().add(panel); panel.setLayout(new BorderLayout()); panel.add(paint); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setVisible(true); paint.getComponent(0).requestFocus(); } public void init() { } public static void main(String[] args) { MSPaint msp = new MSPaint(); } } class Painting extends JPanel implements MouseListener, ActionListener, MouseMotionListener { Raster r; int x1, y1, x2, y2; boolean point = true, circle, line, …

Member Avatar
Member Avatar
+0 forum 2

Hello everyone on Daniweb!:) I'm all new with working with swing and I'm having some problems making my paint method work:/. Atm I'm just tryin to make it write a ball, which I can control into different directions. Right now there is quite alot of unnecessary stuff in my code but please don't bother about that:P. Here's the code: [CODE]import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.lang.*; import java.awt.event.KeyEvent.*; import java.awt.event.KeyListener.*; import java.awt.Graphics.*; public class Boll { JFrame frame=new JFrame("hej"); JLabel panel=new JLabel(); private int x=250, y=250; private boolean ball=true; private boolean jump=false; private final int MAXX=500, MAXY=500; private int …

Member Avatar
Member Avatar
+0 forum 14

I'm creating a silly game, and the first thing I want to make is to tell you "You Lose" if the all that you control with the mouse is not inside the frame. I created a JComponent and every 20 milliseconds it is repainted (A thread does that). Inside it, I detect if the ball is inside the the frame, an if it's not, I just call a method that puts a JOptionPane that says "You Lose", and then exits the program. the problem is, since the JComponent is repainted every 20 milliseconds, loads of JOptionPane messages star to appear. …

Member Avatar
Member Avatar
+0 forum 6

In class my teacher ran a program similar to this one. When I attempt to run this from home I get a message saying "No main classes found". I know there should be a main in the program but he ran a similar program without it. Just trying to get some insight on how to run this. This is basically just a program that makes a checkerboard pattern then it draws the checkers on top. [CODE]package checkers1; import java.awt.*; public class Checkers1 { static int columns = 8; int rows = 8; int sizeofsquare = 50; void maketheboard(Graphics g) { …

Member Avatar
Member Avatar
+0 forum 4

The End.