• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 20:39
CEST 02:39
KST 09:39
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL21] Ro16 Preview Pt2: All Star10Team Liquid Map Contest #22 - The Finalists16[ASL21] Ro16 Preview Pt1: Fresh Flow9[ASL21] Ro24 Preview Pt2: News Flash10[ASL21] Ro24 Preview Pt1: New Chaos0
Community News
2026 GSL Season 1 Qualifiers13Maestros of the Game 2 announced82026 GSL Tour plans announced14Weekly Cups (April 6-12): herO doubles, "Villains" prevail1MaNa leaves Team Liquid24
StarCraft 2
General
Maestros of the Game 2 announced Team Liquid Map Contest #22 - The Finalists MaNa leaves Team Liquid 2026 GSL Tour plans announced Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament 2026 GSL Season 1 Qualifiers GSL CK: More events planned pending crowdfunding RSL Revival: Season 5 - Qualifiers and Main Event Master Swan Open (Global Bronze-Master 2)
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
Mutation # 522 Flip My Base The PondCast: SC2 News & Results Mutation # 521 Memorable Boss Mutation # 520 Moving Fees
Brood War
General
ASL21 General Discussion Pros React To: ASL S21, Ro.16 Group C BGH Auto Balance -> http://bghmmr.eu/ [TOOL] Starcraft Chat Translator Data needed
Tourneys
[ASL21] Ro16 Group C [Megathread] Daily Proleagues [ASL21] Ro16 Group D [ASL21] Ro16 Group B
Strategy
Simple Questions, Simple Answers What's the deal with APM & what's its true value Any training maps people recommend? Fighting Spirit mining rates
Other Games
General Games
Diablo IV Nintendo Switch Thread Dawn of War IV Starcraft Tabletop Miniature Game General RTS Discussion Thread
Dota 2
The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread Russo-Ukrainian War Thread YouTube Thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [Req][Books] Good Fantasy/SciFi books Movie Discussion!
Sports
McBoner: A hockey love story 2024 - 2026 Football Thread Formula 1 Discussion Cricket [SPORT]
World Cup 2022
Tech Support
[G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
Sexual Health Of Gamers
TrAiDoS
lurker extra damage testi…
StaticNine
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1604 users

The Big Programming Thread - Page 818

Forum Index > General Forum
Post a Reply
Prev 1 816 817 818 819 820 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
December 19 2016 22:16 GMT
#16341
--- Nuked ---
Manit0u
Profile Blog Joined August 2004
Poland17731 Posts
Last Edited: 2016-12-20 16:00:00
December 20 2016 15:58 GMT
#16342
Holy crap! When did Rust get so much traction?

I remember that not so long ago people could barely compile anything in it and now dozens of big companies are using it for some critical parts of their operations. Mozilla is pretty big into it - not just taking it under its wings but also moving Firefox to it and developing new browser engine in it (to be released late 2017).

Videos posted by Mozilla Foundation show that some of their most senior devs consider it to be the new C++ but better.

Pretty amazing.
Time is precious. Waste it wisely.
RoomOfMush
Profile Joined March 2015
1296 Posts
December 20 2016 20:12 GMT
#16343
On December 21 2016 00:58 Manit0u wrote:
Holy crap! When did Rust get so much traction?

I remember that not so long ago people could barely compile anything in it and now dozens of big companies are using it for some critical parts of their operations. Mozilla is pretty big into it - not just taking it under its wings but also moving Firefox to it and developing new browser engine in it (to be released late 2017).

Videos posted by Mozilla Foundation show that some of their most senior devs consider it to be the new C++ but better.

Pretty amazing.

Although I really like many of the concepts of that language I absolutely hate the way it looks like. Its fugly in my opinion.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2016-12-21 01:02:39
December 21 2016 01:02 GMT
#16344
So I have absolutely no idea what I am doing but for some reason GUI in java is just incredibly confusing

All I want to do is draw a circle wherever I click on my jpanel.

Here is my code:

+ Show Spoiler +


import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class GraphGUI extends JPanel {

public static int x;
public static int y;

public static JFrame window = new JFrame();

/**
*
*/
private static final long serialVersionUID = 1L;

public void paintComponent(Graphics g) {
setSize(100, 100);
g.setColor(Color.red);
g.drawOval(x, y, 50, 50);
}

public GraphGUI() {

}

public static void main(String[] args) {
window.setSize(500, 500);
window.addMouseListener(m);
window.validate();
window.setVisible(true);

}

public static MouseListener m = new MouseListener() {

@Override
public void mouseClicked(MouseEvent e) {
if (e.getButton() == 1) {
x = e.getX();
y = e.getY();

GraphGUI g = new GraphGUI();
window.add(g);
window.revalidate();
}

}

@Override
public void mouseEntered(MouseEvent e) {
}

@Override
public void mouseExited(MouseEvent e) {
}

@Override
public void mousePressed(MouseEvent e) {
}

@Override
public void mouseReleased(MouseEvent e) {
}
};

}




I have no idea what exactly validate and revalidate do. But I've figured out I need them. It's all very confusing.

I've figured out my problem here is: g.drawOval(x, y, 50, 50);

It's the x and y variables. For some reason paintComponent isn't using an updated x and y (it should change when mouseclick happens..).

I know this because if I write g.drawOval(50, 50, 50, 50) then there is no problem and it draws my circle at 50,50.
So that's cool and all but I want to draw the damn circle where I click the mouse. So how in the world do I do that?
Aerisky
Profile Blog Joined May 2012
United States12129 Posts
Last Edited: 2016-12-21 03:48:44
December 21 2016 03:48 GMT
#16345
I'm pretty rusty and haven't worked with a GUI in Java before, but on first glance, the paintComponent method takes x,y, which you never set for the GraphGui object. In the mouseClicked method, you set x and y, then create a new GraphGui object, but you haven't set that GraphGui object's x and y attributes, so paintComponent doesn't know what x and y are I think?
Jim while Johnny had had had had had had had; had had had had the better effect on the teacher.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
December 21 2016 04:17 GMT
#16346
I don't think that should matter because they are static so they are the only ones of those variables, and they already belong to GraphGUI.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2016-12-21 08:55:28
December 21 2016 04:53 GMT
#16347
Unspecific to your problem but I remember similar problems in my class when people first encountered GUIs (I did GUI programming previously) and I see a lot of weird code that means you'll eventually start building strange solutions on top of it. I have a *small* thing for GUIs lol.

You're doing a weird thing where you keep adding GraphGUI/JPanels inside your JFrame. This should be a memory leak but still bad practice. You should just be updating an existing GraphGUI (if you're doing it like that) by revalidating it. You shouldn't be referencing the static window like this. You can just add the GraphGUI to your JFrame once in the main function.

Use a Point2D class if you want to represent a point in space. This lets you be more descriptive.

You're calling setSize inside the paintComponent which generally makes no sense. paintComponent should just paint the component. The size of the GraphGUI should just be the size of your window here. You would attempt to resize the window every time it paints. Do the setSize once wherever you initialize the GraphGUI.

You shouldn't have a static MouseListener. The MouseListener should be in the GraphGUI/JPanel, added in its constructor. You can also use a MouseAdapter to not have the empty Overrides.

Your specific problem is that revalidating the outer window doesn't propogate the invalidation to its inner windows. GUI systems work the other way. When you invalidate inner windows the invalidation propogate upwards to its parents.

I believe you also also want to call repaint, not just revalidate. The terminology is confusing but they affect layout vs redraw.

Lmk if that fixes things.
There is no one like you in the universe.
Aerisky
Profile Blog Joined May 2012
United States12129 Posts
December 21 2016 04:55 GMT
#16348
Ah derp, I didn't see the indentation correctly at all haha, my bad.

Blisse seems like he knows what he's talking about here though >.<
Jim while Johnny had had had had had had had; had had had had the better effect on the teacher.
mantequilla
Profile Blog Joined June 2012
Turkey781 Posts
December 21 2016 09:10 GMT
#16349
@travis welcome to the garbage dump world called javax.swing.*
Age of Mythology forever!
RoomOfMush
Profile Joined March 2015
1296 Posts
December 21 2016 11:21 GMT
#16350
There are several things wrong with your code travis.
First of all, you are creating a new JPanel with each click and you try to add it to your JFrame. This is a really bad idea. By default the content pane of a JFrame is a JPanel with a BorderLayout. The BorderLayout can only take 5 components to lay out, after that I would assume it will crash but perhaps the error will be silently ignored.

The next problem is that your paintComponent method in your JPanel mutates (your setSize call) the JPanel itself which is illegal in Swing. You are also not running your application on the EDT (EventDispatcherThread) which you are supposed to do in Swing.

Here is a working example:
+ Show Spoiler +
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class ClickWindow {

public static void main(String[] args) {
// all Swing applications must be started this way to
// make sure the application runs on the EventDispatcherThread (EDT)
// if the application does not run on the EDT the behavior of
// Swing is not defined
EventQueue.invokeLater(() -> new ClickWindow());
}

private final JFrame frame = new JFrame();

public ClickWindow() {
// make sure the JVM ends when the frame is closed
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// use some arbitrary size for testing
frame.setSize(640, 480);
// center the frame on screen
frame.setLocationRelativeTo(null);

// set our custom JPanel to be the content-pane (the root element) of our frame
frame.setContentPane(new ClickPanel());

// show the frame
frame.setVisible(true);
}

public static class ClickPanel extends JPanel {

private int x, y;

public ClickPanel() {
// A MouseAdapter is just an abstract class of MouseListener
// with empty implementations for all methods
addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
// we check for left-click
if (SwingUtilities.isLeftMouseButton(e)) {
// we take the X- and Y-coordinates from the event
x = e.getX();
y = e.getY();

// we need to repaint our ClickPanel
// when we want to draw a new dot
repaint();
}
}
});
}

public void paintComponent(Graphics g) {
// renders the border and background
super.paintComponent(g);
// renders our colored point
g.setColor(Color.RED);
g.drawOval(x, y, 50, 50);
}

}

}
RoomOfMush
Profile Joined March 2015
1296 Posts
December 21 2016 11:26 GMT
#16351
On December 21 2016 13:53 Blisse wrote:
You're doing a weird thing where you keep adding GraphGUI/JPanels inside your JFrame. This should be a memory leak but still bad practice.

There are no memory leaks in java (at least not at travis level). He is adding more components to his frame though and this WILL cause problems with his SceneGraph / GUI-Tree / DOM (whatever you want to call it in Swing).

On December 21 2016 13:53 Blisse wrote:
You should just be updating an existing GraphGUI (if you're doing it like that) by revalidating it.

Almost but not quite. Revalidating will do nothing in that case. What you want to do is repaint because the graphics have changed. Revalidation is only necessary when changing the GUI-Tree on the fly without using well-defined methods to do it. Its basically only needed when doing low-level manipulations. Even in that case an invalidate() is probably the better idea than a revalidate() but at that point even I get sometimes confused.
mantequilla
Profile Blog Joined June 2012
Turkey781 Posts
Last Edited: 2016-12-21 16:34:55
December 21 2016 16:32 GMT
#16352
this is a bit electronics related but since I have zero knowledge on it you guys may give me a start

my room is pretty far away from the door so often I can't hear the doorbell. Currently I'm abusing Skype to call from my cellphone near the door to my pc in my room when I am expecting someone. But it's not an optimal solution since it occupies my phone.

I borrowed a bare arduino uno from someone to fiddle with it. And found a simple project on the net that connects a mic to arduino, but it can only 'detect' a presence of sound, not transmit it.

what I need is a simplest circuit that can convert sound to analog signal to be supplied to arduino's analog inputs. From there I can figure out on my own the programming of arduino and a java program that will listen on my pc. All will run on lan
Age of Mythology forever!
phar
Profile Joined August 2011
United States1080 Posts
Last Edited: 2016-12-21 17:16:48
December 21 2016 17:15 GMT
#16353
The generic tech for converting a digital signal to audio is a DAC, and to sound it's, well, it's called a speaker, but you probably already knew that. Here's a simple ish guide:

https://www.google.com/amp/www.instructables.com/id/Arduino-Basics-Making-Sound/?amp_page=true?client=ms-android-google


Ahh fucking AMP links sorry.

Let me know if I'm misunderstanding something about your question.
Who after all is today speaking about the destruction of the Armenians?
Cyx.
Profile Joined November 2010
Canada806 Posts
December 21 2016 18:48 GMT
#16354
On December 21 2016 00:58 Manit0u wrote:
Holy crap! When did Rust get so much traction?

I remember that not so long ago people could barely compile anything in it and now dozens of big companies are using it for some critical parts of their operations. Mozilla is pretty big into it - not just taking it under its wings but also moving Firefox to it and developing new browser engine in it (to be released late 2017).

Videos posted by Mozilla Foundation show that some of their most senior devs consider it to be the new C++ but better.

Pretty amazing.

Mozilla were the people who started Rust if I'm not mistaken, though it's a lot bigger than them now. I kind of agree with the people who think it's basically a better C++, in the sense that it fills the same systems-programming niche as C++ but in a much more modern and safer way. Though I haven't used it for anything serious at all so take that with a grain of salt.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2016-12-21 21:03:03
December 21 2016 20:39 GMT
#16355
On December 21 2016 20:26 RoomOfMush wrote:
Show nested quote +
On December 21 2016 13:53 Blisse wrote:
You're doing a weird thing where you keep adding GraphGUI/JPanels inside your JFrame. This should be a memory leak but still bad practice.

There are no memory leaks in java (at least not at travis level). He is adding more components to his frame though and this WILL cause problems with his SceneGraph / GUI-Tree / DOM (whatever you want to call it in Swing).

Show nested quote +
On December 21 2016 13:53 Blisse wrote:
You should just be updating an existing GraphGUI (if you're doing it like that) by revalidating it.

Almost but not quite. Revalidating will do nothing in that case. What you want to do is repaint because the graphics have changed. Revalidation is only necessary when changing the GUI-Tree on the fly without using well-defined methods to do it. Its basically only needed when doing low-level manipulations. Even in that case an invalidate() is probably the better idea than a revalidate() but at that point even I get sometimes confused.


Yeah I kind of mixed up "memory leak" with "continually adding useless objects to the tree". Also I realized my mistake at the end of the post but didn't fix the mistake in the middle. :D

Totally untested code and not to standards like mush

+ Show Spoiler +


public class GraphGUI extends JPanel {

private Point circleLocation = null;

@Override
public void paintComponent(Graphics g) {
if (circleLocation != null) {
g.setColor(Color.red);
g.drawOval(circleLocation.x, circleLocation.y, 50, 50);
}
}

public GraphGUI() {
addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getButton() == 1) {
circleLocation = new Point(e.getX(), e.getY());
repaint();
}
}
})
}

public static void main(String[] args) {
JFrame window = new JFrame();
window.setSize(500, 500);
window.setVisible(true);
window.add(new GraphGUI());
window.revalidate();
}
}

There is no one like you in the universe.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2016-12-21 21:49:43
December 21 2016 20:51 GMT
#16356
wow thanks guys

and mush, that tutorial was very clear, thank you so much.
the one thing in it I have questions about though is paintComponent and Graphics.

So, I believe paintComponent is a method that components have that we are overriding here to specify what it should do
But what is Graphics? Is it just some parameter that repaint is passing to paintComponent behind the scenes? What is the point of Graphics?

Like, why doesn't paintComponent look like this: (i know this doesn't work, I just don't understand what the role of Graphics is)


public void paintComponent() {
this.setColor(blah blah)
this.drawOval(blah blah)
}
mantequilla
Profile Blog Joined June 2012
Turkey781 Posts
December 21 2016 21:04 GMT
#16357
On December 22 2016 02:15 phar wrote:
The generic tech for converting a digital signal to audio is a DAC, and to sound it's, well, it's called a speaker, but you probably already knew that. Here's a simple ish guide:

https://www.google.com/amp/www.instructables.com/id/Arduino-Basics-Making-Sound/?amp_page=true?client=ms-android-google


Ahh fucking AMP links sorry.

Let me know if I'm misunderstanding something about your question.


noo noo I won't be making sound using arduino

it will be like this

microphone circuit sends analog signal to arduino
arduino processes it if necessary and sends data over lan to my pc
a program on my pc will play the sound

I'm only asking about the first part (listening to sound). Rest I can figure out.
Age of Mythology forever!
RoomOfMush
Profile Joined March 2015
1296 Posts
Last Edited: 2016-12-21 21:30:43
December 21 2016 21:28 GMT
#16358
On December 22 2016 05:51 travis wrote:
wow thanks guys

and mush, that tutorial was very clear, thank you so much.
the one thing in it I have questions about though is paintComponent and Graphics.

So, I believe paintComponent is a method that components have that we are overriding here to specify what it should do
But what is Graphics? Is it just some parameter that repaint is passing to paintComponent behind the scenes? What is the point of Graphics?

Like, why doesn't paintComponent look like this: (i know this doesn't work, I just don't understand what the role of Graphics is)

public void paintComponent() {
this.setColor(blah blah)
this.drawOval(blah blah)
}

Graphics is an interface used to render all kinds of graphics to screen. There can be different implementations of graphics which could even be implemented with native code; perhaps in C or C++. Conceptually a Graphics object is similar to an OpenGL context. It saves state like clipping, colors, blend modes, etc and offers methods of drawing primitive shapes or text.

In Swing each component can call the repaint() method which will notify the EventDispatcherThread (EDT) that the component would like to be repainted. The EDT will then, at some point in the near future, call the paintComponent method of the component and pass a valid Graphics object for the parameter. The paintComponent method is not necessarily called once for every call to repaint. Its perfectly possible (and generally the case), that the EDT will ignore successive calls to repaint() before paintComponent has been called. How the Graphics object is constructed, whether its always the same, whether different Components will get the different Graphics objects or not, etc are implementation details that you should not care about. They may differ in future versions of Swing (although it is highly unlikely that Swing will ever get any major updates since JavaFX was just released).

In general you should never save the Graphics object you get in paintComponent in an attribute. You should also never use the Graphics object outside of the paintComponent method for that particular component. Consider it to be temporary and only used within that one painting action.

There is also an option of doing the usual while-true loop and rendering to the graphics context directly if you prefer the old-school style. You will lose much of Swings functionality if you do this though.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
December 21 2016 21:36 GMT
#16359
So what I want to do now is paint a new circle at each spot i click, but keep the old ones too.

Is the best way to do that to save my x and y coordinates into a 2d array, and then iterate through them in paintComponent to paint all the circles? (seems a bit awkward).

RoomOfMush
Profile Joined March 2015
1296 Posts
Last Edited: 2016-12-21 21:43:54
December 21 2016 21:39 GMT
#16360
On December 22 2016 05:39 Blisse wrote:
Show nested quote +
On December 21 2016 20:26 RoomOfMush wrote:
On December 21 2016 13:53 Blisse wrote:
You're doing a weird thing where you keep adding GraphGUI/JPanels inside your JFrame. This should be a memory leak but still bad practice.

There are no memory leaks in java (at least not at travis level). He is adding more components to his frame though and this WILL cause problems with his SceneGraph / GUI-Tree / DOM (whatever you want to call it in Swing).

On December 21 2016 13:53 Blisse wrote:
You should just be updating an existing GraphGUI (if you're doing it like that) by revalidating it.

Almost but not quite. Revalidating will do nothing in that case. What you want to do is repaint because the graphics have changed. Revalidation is only necessary when changing the GUI-Tree on the fly without using well-defined methods to do it. Its basically only needed when doing low-level manipulations. Even in that case an invalidate() is probably the better idea than a revalidate() but at that point even I get sometimes confused.


Yeah I kind of mixed up "memory leak" with "continually adding useless objects to the tree". Also I realized my mistake at the end of the post but didn't fix the mistake in the middle. :D

Totally untested code and not to standards like mush

+ Show Spoiler +


public class GraphGUI extends JPanel {

private Point circleLocation = null;

@Override
public void paintComponent(Graphics g) {
if (circleLocation != null) {
g.setColor(Color.red);
g.drawOval(circleLocation.x, circleLocation.y, 50, 50);
}
}

public GraphGUI() {
addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getButton() == 1) {
circleLocation = new Point(e.getX(), e.getY());
repaint();
}
}
})
}

public static void main(String[] args) {
JFrame window = new JFrame();
window.setSize(500, 500);
window.setVisible(true);
window.add(new GraphGUI());
window.revalidate();
}
}


A few suggestions:

Instead of doing:
circleLocation = new Point(e.getX(), e.getY());

you can do:
circleLocation = e.getPoint();


I would highly recommend doing:
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

after creating your JFrame. The default value is JFrame.HIDE_ON_CLOSE which will not dispose the frame and not end any timers. This can turn out really bad when your JVM keeps running in the background without any visible frames. In that situation you would need to kill the process manually to end the program.

The call to
window.setVisible(true);

should also be the very last thing you do in your code. If you do it this way you will never need to pack, validate, revalidate or invalidate your JFrame. The frame will automatically validate when it is set to visible.

Instead of adding teh GraphGUI to your frame you can also set it to be the contentPane of the frame. The add-method will simply add your new JPanel to the current contentPane which means you have 2 panels but only one is really used.


And remember to start Swing on the EventDispatcherThread (EDT) in your main-method. If you dont do it you will eventually run into BIG trouble when developing a larger application. I didnt do it once and I ran into random bugs that could never be reproduced but kept happening every now and then. It was usually graphical glitches or lost inputs. I later found out that I didnt run the application on the EDT and the errors were due to undefined behavior of Swing when not running on the EDT. You certainly dont want that to happen in later stages of developement.

On December 22 2016 06:36 travis wrote:
So what I want to do now is paint a new circle at each spot i click, but keep the old ones too.

Is the best way to do that to save my x and y coordinates into a 2d array, and then iterate through them in paintComponent to paint all the circles? (seems a bit awkward).


Dont use an array, use an ArrayList instead since it will automatically resize as needed. The iterating in paintComponent is the correct thing to do.
Prev 1 816 817 818 819 820 1032 Next
Please log in or register to reply.
Live Events Refresh
Replay Cast
00:00
2026 GSL Season 1: Qualifiers
CranKy Ducklings99
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
NeuroSwarm 187
ProTech130
SpeCial 106
RuFF_SC2 79
StarCraft: Brood War
Britney 14359
GuemChi 3864
Artosis 627
Dota 2
monkeys_forever509
Counter-Strike
tarik_tv3798
pashabiceps1512
fl0m1110
taco 435
Super Smash Bros
hungrybox924
Other Games
summit1g9328
C9.Mang0466
JimRising 454
ViBE118
Fnx 116
Maynarde81
Trikslyr56
Mew2King53
Organizations
Other Games
gamesdonequick923
BasetradeTV266
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 12 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Doublelift3042
Other Games
• imaqtpie995
Upcoming Events
The PondCast
9h 21m
KCM Race Survival
9h 21m
WardiTV Map Contest Tou…
10h 21m
Gerald vs herO
Clem vs Cure
ByuN vs Solar
Rogue vs MaxPax
ShoWTimE vs TBD
OSC
14h 21m
CranKy Ducklings
23h 21m
Escore
1d 9h
RSL Revival
1d 16h
Replay Cast
1d 23h
WardiTV Map Contest Tou…
2 days
Universe Titan Cup
2 days
Rogue vs Percival
[ Show More ]
Ladder Legends
2 days
uThermal 2v2 Circuit
2 days
BSL
2 days
Sparkling Tuna Cup
3 days
WardiTV Map Contest Tou…
3 days
Ladder Legends
3 days
BSL
3 days
Replay Cast
3 days
Replay Cast
4 days
Wardi Open
4 days
Afreeca Starleague
4 days
Soma vs hero
Monday Night Weeklies
4 days
Replay Cast
4 days
Afreeca Starleague
5 days
Leta vs YSC
Replay Cast
6 days
Replay Cast
6 days
Liquipedia Results

Completed

Proleague 2026-04-22
RSL Revival: Season 4
NationLESS Cup

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
StarCraft2 Community Team League 2026 Spring
WardiTV TLMC #16
Nations Cup 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026

Upcoming

Escore Tournament S2: W4
Acropolis #4
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
2026 GSL S2
RSL Revival: Season 5
2026 GSL S1
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
BLAST Rivals Spring 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.