• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 11:35
CEST 17:35
KST 00:35
  • 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
[ASL22] Ro16 Preview: Rough Waters10[ASL22] Ro24 Preview: Siren's Call8[ASL22] Ro24 Preview: Summer's End9Serral wins HomeStory Cup 2915Serral wins Maestros of the Game 244
Community News
Weekly Cups (Aug 30-Sep 7): herO thrives amid growing schism10Official StarCraft website teases new content ahead of BlizzCon?132Stellar Fest TWO the Moon (Dec 16-20)9Weekly Cups (August 24-30): Patches' balance mod takes over3New 3v3 BGH Ladder (and more) on ShieldBattery!46
StarCraft 2
General
Balance hotfix patch 5.0.16b (July 16) Team Liquid Map Contest #22: Results and Winners Weekly Cups (Aug 30-Sep 7): herO thrives amid growing schism SC4ALL: II Winner will earn a spot at HSC 30! SC4ALL II: StarCraft 2 Player Announcement 7/8
Tourneys
RSL goes to London! 2026 Offline Finals Nov 21-22 KSL Week #92 IntoTheTV X SOOP SC2 League : Weekly & Monthly 2026 GSTL Announcement Sparkling Tuna Cup - Weekly Open Tournament
Strategy
[G] Having the right mentality to improve
Custom Maps
Nexus Wars 2021 GUIDE [M] (2) Industrial Park
External Content
Mutation # 542 The Ascended Mutation # 541 Binary Choice The PondCast: SC2 News & Results Mutation # 540 Dodge This
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ Official StarCraft website teases new content ahead of BlizzCon? Practice Partners (Official) Broodwar Prediction Market [D] Brainstorming a balance patch for Brood war
Tourneys
[ASL22] Ro16 Group A [ASL22] Ro16 Group B Escore Tournament - Season 3 Small VOD Thread 2.0
Strategy
Replay Review Process - What do you do? Simple Questions, Simple Answers Odyssey Mineral Stack Saturation Game Theory for Starcraft
Other Games
General Games
Nintendo Switch Thread EVE Corporation Diablo IV [Maplestory Hardcore] Let's Play~!! General RTS Discussion Thread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
[TL LoL EUW IHs] Teemo shall perish TSM pausing esports and CLG Dead
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Community Thread
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread European Politico-economics QA Mega-thread Trading/Investing Thread
Fan Clubs
MarineLorD Fan Club The Creator Fan Club The ShoWTimE Fan Club
Media & Entertainment
Movie Discussion!
Sports
Football (Soccer) Thread TeamLiquid Health and Fitness Initiative For 2023 MLB/Baseball 2023
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Northern Ireland Global Starcraft
Blogs
Virtual Romance, Real-Life C…
TrAiDoS
Regacy Esports:Our Goa…
regacyesports
Dreaming of BW patches (mod…
c3rberUs
LOCKPICKING NOOB
LUCKY_NOOB
Customize Sidebar...

Website Feedback

Closed Threads



Active: 6770 users

The Big Programming Thread - Page 567

Forum Index > General Forum
Post a Reply
Prev 1 565 566 567 568 569 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.
TMG26
Profile Joined July 2012
Portugal2017 Posts
January 20 2015 23:32 GMT
#11321
On January 21 2015 08:18 travis wrote:
I am trying to teach myself Java. At the moment I have 3 class files.

How do I call a specific method from one of the class files in a different class file? I don't want to call the whole thing.. I just want to call a specific method!

Is that not possible? Do I have to make yet another class?

I am sorry I know I am very noob. But this is not very intuitive.


This is like what I want to do

class1 {

main{
new class2();
}}


class2{

new method2()
}



class3{

method1(){
}

method2(){
}
}



I want to call method 2 from class 2. But it doesn't let me do that, it "cannot find symbol".

I don't want to do it by calling method1(which is named after class3), because then it runs everything in the class and I don't want to do everything.

I mean geeze do I need to make a separate class file any time I want to have a method I can call from another class?



I am sorry I know my terminology for all of this is horrible but it's confusing stuff to learn on your own.


you must import your classes.

 import MyClass;


Also use Code tags when pasting code.
Supporter of the situational Blink Dagger on Storm.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2015-01-20 23:46:09
January 20 2015 23:45 GMT
#11322
That wasn't really the issue. I am sorry, I was probably very confusing.

Anyways, my issue was that I was simply typing

{
new methodiwanttocall();
}


when apparently I should be using

{
classname newclassname = new classname();
newclassname.methodiwanttocall();
}



does it make sense to me nope.
but it works lol


also I don't know what you mean by use code tags
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2015-01-21 00:14:26
January 21 2015 00:13 GMT
#11323
code tags are bulletin board code. They allow you to indent and stuff to make the code readable.

{code]{/code] (except the first brackets should be straight brackets)

{
classname newclassname = new classname();
newclassname.methodiwanttocall();
}
I'll always be your shadow and veil your eyes from states of ain soph aur.
Toadesstern
Profile Blog Joined October 2008
Germany16350 Posts
Last Edited: 2015-01-21 01:29:55
January 21 2015 00:16 GMT
#11324
that's indeed somewhat confusing to read

the
 classname newclassname = new classname();

isn't really a new classname as in it's not a new name for it. It is a new classname though, as in you're creating an object of the blueprint you defined earlier, which makes everything a little confusing to read given that you're not using CamelCase and obviously having the word new in the syntax as well

So basicly when you write down your classes with all the attributes and methods it may have in there, you should consider it something like a blueprint. Like you could code an alarm clock and call the class AlarmClock with methods like setAlarm or snooze. That however is and will stay just that, a blueprint until you create a specific object of what you just coded.
You can later create alarm1, alarm2 as well as alarm3 and while they're all the same in design they are different objects. You can set the alarm on the first one to 7am and to 8am on the second one. That's what you're doing there.

So yes, the syntax for the first thing you did with just new *whatever* was wrong. Your correction changes it to how you properly set up a new variable in general: *type* *name* = *something* with *something* being your constructor for your class in this case. While syntactically correct like mentioned below, it shouldn't be what you want to do.
<Elem> >toad in charge of judging lewdness <Elem> how bad can it be <Elem> also wew, that is actually p lewd.
LaNague
Profile Blog Joined April 2010
Germany9118 Posts
Last Edited: 2015-01-21 01:15:34
January 21 2015 01:12 GMT
#11325
On January 21 2015 08:45 travis wrote:
That wasn't really the issue. I am sorry, I was probably very confusing.

Anyways, my issue was that I was simply typing

{
new methodiwanttocall();
}


when apparently I should be using

{
classname newclassname = new classname();
newclassname.methodiwanttocall();
}



does it make sense to me nope.
but it works lol


also I don't know what you mean by use code tags




your writing is not coherent, but i THINK what you need is a static method, which is a method that belongs to the class and not an instance of the class.


You need to read about the concepts of objetcs and methods, because

new methodiwanttocall();
classname newclassname = new classname();


makes no sense. It will help you understand java much more than trying to type the right letters.
Toadesstern
Profile Blog Joined October 2008
Germany16350 Posts
January 21 2015 01:21 GMT
#11326
Also would be good if you don't leave out stuff like return values and wether or not your methods are private. That could actually be a problem.
<Elem> >toad in charge of judging lewdness <Elem> how bad can it be <Elem> also wew, that is actually p lewd.
meatpudding
Profile Joined March 2011
Australia520 Posts
January 21 2015 03:44 GMT
#11327
On January 21 2015 08:32 TMG26 wrote:
Show nested quote +
On January 21 2015 08:18 travis wrote:
I am trying to teach myself Java. At the moment I have 3 class files.

How do I call a specific method from one of the class files in a different class file? I don't want to call the whole thing.. I just want to call a specific method!

Is that not possible? Do I have to make yet another class?

I am sorry I know I am very noob. But this is not very intuitive.


This is like what I want to do

class1 {

main{
new class2();
}}


class2{

new method2()
}



class3{

method1(){
}

method2(){
}
}



I want to call method 2 from class 2. But it doesn't let me do that, it "cannot find symbol".

I don't want to do it by calling method1(which is named after class3), because then it runs everything in the class and I don't want to do everything.

I mean geeze do I need to make a separate class file any time I want to have a method I can call from another class?



I am sorry I know my terminology for all of this is horrible but it's confusing stuff to learn on your own.


you must import your classes.

 import MyClass;


Also use Code tags when pasting code.


You don't call your classes. A class defines a type of object, and you then create instances of it. Once you have an instance you can call methods all day.

But there are exceptions, and if you don't want to create an instance of your class then you can use a static method.

Simply put, the difference is that when you have instances, calling a method will only act on that instance. If you have a static method, it can theoretically affect every instance of that class.
Be excellent to each other.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
January 21 2015 08:18 GMT
#11328
On January 21 2015 12:44 meatpudding wrote:
Show nested quote +
On January 21 2015 08:32 TMG26 wrote:
On January 21 2015 08:18 travis wrote:
I am trying to teach myself Java. At the moment I have 3 class files.

How do I call a specific method from one of the class files in a different class file? I don't want to call the whole thing.. I just want to call a specific method!

Is that not possible? Do I have to make yet another class?

I am sorry I know I am very noob. But this is not very intuitive.


This is like what I want to do

class1 {

main{
new class2();
}}


class2{

new method2()
}



class3{

method1(){
}

method2(){
}
}



I want to call method 2 from class 2. But it doesn't let me do that, it "cannot find symbol".

I don't want to do it by calling method1(which is named after class3), because then it runs everything in the class and I don't want to do everything.

I mean geeze do I need to make a separate class file any time I want to have a method I can call from another class?



I am sorry I know my terminology for all of this is horrible but it's confusing stuff to learn on your own.


you must import your classes.

 import MyClass;


Also use Code tags when pasting code.


You don't call your classes. A class defines a type of object, and you then create instances of it. Once you have an instance you can call methods all day.

But there are exceptions, and if you don't want to create an instance of your class then you can use a static method.

Simply put, the difference is that when you have instances, calling a method will only act on that instance. If you have a static method, it can theoretically affect every instance of that class.


I don't think that part is true. Class instances should be independent of what their static methods do. On the other hand, static variables do affect all instances of a class.
Manit0u
Profile Blog Joined August 2004
Poland17843 Posts
Last Edited: 2015-01-21 11:10:13
January 21 2015 09:30 GMT
#11329
Travis, please get yourself the "Thinking in Java" book

P. S.

https://github.com/The-Feminist-Software-Foundation/ToleranUX

What has the world come to? T_T
Time is precious. Waste it wisely.
meatpudding
Profile Joined March 2011
Australia520 Posts
January 21 2015 12:04 GMT
#11330
On January 21 2015 17:18 darkness wrote:
Show nested quote +
On January 21 2015 12:44 meatpudding wrote:
On January 21 2015 08:32 TMG26 wrote:
On January 21 2015 08:18 travis wrote:
I am trying to teach myself Java. At the moment I have 3 class files.

How do I call a specific method from one of the class files in a different class file? I don't want to call the whole thing.. I just want to call a specific method!

Is that not possible? Do I have to make yet another class?

I am sorry I know I am very noob. But this is not very intuitive.


This is like what I want to do

class1 {

main{
new class2();
}}


class2{

new method2()
}



class3{

method1(){
}

method2(){
}
}



I want to call method 2 from class 2. But it doesn't let me do that, it "cannot find symbol".

I don't want to do it by calling method1(which is named after class3), because then it runs everything in the class and I don't want to do everything.

I mean geeze do I need to make a separate class file any time I want to have a method I can call from another class?



I am sorry I know my terminology for all of this is horrible but it's confusing stuff to learn on your own.


you must import your classes.

 import MyClass;


Also use Code tags when pasting code.


You don't call your classes. A class defines a type of object, and you then create instances of it. Once you have an instance you can call methods all day.

But there are exceptions, and if you don't want to create an instance of your class then you can use a static method.

Simply put, the difference is that when you have instances, calling a method will only act on that instance. If you have a static method, it can theoretically affect every instance of that class.


I don't think that part is true. Class instances should be independent of what their static methods do. On the other hand, static variables do affect all instances of a class.


Yeah that is what I was getting at. If your method is static, it can only affect variables which are static. You can't change any non-static variables or call any non-static methods unless you specify the instance.

But if you have any instance, you can still use it to read or write a static variable, but all instances will be sharing the same value because it is static.
Be excellent to each other.
meatpudding
Profile Joined March 2011
Australia520 Posts
January 21 2015 12:12 GMT
#11331
On January 21 2015 18:30 Manit0u wrote:
Travis, please get yourself the "Thinking in Java" book

P. S.

https://github.com/The-Feminist-Software-Foundation/ToleranUX

What has the world come to? T_T


*chortle*
Be excellent to each other.
Warfie
Profile Joined February 2009
Norway2848 Posts
January 21 2015 13:25 GMT
#11332
On January 21 2015 18:30 Manit0u wrote:
Travis, please get yourself the "Thinking in Java" book

P. S.

https://github.com/The-Feminist-Software-Foundation/ToleranUX

What has the world come to? T_T

This is fucking hilarious
Just because a specific part of software is part of the kernel space at creation does not mean it would wish to identify as user space sometime later before its termination. [...] To alleviate this, ToleranUX replaces the outdated concept of "occupied virtual memory" with the ideal of "Suggestions of Space" (SoS).


Oh and that poor, poor Linux penguin turned transvesguin
FreeZer
Profile Joined January 2011
Sweden288 Posts
January 21 2015 13:51 GMT
#11333
How do websites implement like-systems? For logged in users I suppose you keep a table mapping users to liked items, but it seems like an awful lot of data to process every time someone views a likeable item. And what about non-logged in users? Do you track IP-addresses and map them the same way? Or do you just use session and not care about being able to like again when it expires?
Ahh Scept-- hey where did you come from?
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
January 21 2015 16:09 GMT
#11334
On January 21 2015 22:51 FreeZer wrote:
How do websites implement like-systems? For logged in users I suppose you keep a table mapping users to liked items, but it seems like an awful lot of data to process every time someone views a likeable item. And what about non-logged in users? Do you track IP-addresses and map them the same way? Or do you just use session and not care about being able to like again when it expires?


Depends a lot on the use-case.

If users can like a lot of stuff then a database stored solution that is checked when showing likeable items is a common option. When there are only a limited amount of likes then, for authenticated users, it's often read on session initialization (e.g. login) and then maintained in session and in storage simultaneously or updated on storage and then re-read from it into the session.

For users that are not logged in it's usually a session/cookie since IPs aren't unique for many users, especially in a target group that contains students that often use the website through the network of their university.

Without the use-case it's hard to say what the best solution would be.
Khalum
Profile Joined September 2010
Austria831 Posts
January 21 2015 16:32 GMT
#11335
On January 21 2015 18:30 Manit0u wrote:
Travis, please get yourself the "Thinking in Java" book

P. S.

https://github.com/The-Feminist-Software-Foundation/ToleranUX

What has the world come to? T_T


Haha great!
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
January 21 2015 21:26 GMT
#11336
ok I downloaded the free electronic version of thinking in java


in the meantime I have another java question
Let's say I am using drawstring to draw strings to a jpanel
the strings that I am drawing are variables
how do I go about having these strings properly format within the frame? right now, if the variable is a long string, it will just keep writing and writing on one line right off the frame. but i want it to wrap to the next line of the frame when that is appropriate
Vorenius
Profile Blog Joined December 2010
Denmark1979 Posts
January 21 2015 21:54 GMT
#11337
On January 22 2015 06:26 travis wrote:
ok I downloaded the free electronic version of thinking in java


in the meantime I have another java question
Let's say I am using drawstring to draw strings to a jpanel
the strings that I am drawing are variables
how do I go about having these strings properly format within the frame? right now, if the variable is a long string, it will just keep writing and writing on one line right off the frame. but i want it to wrap to the next line of the frame when that is appropriate

If you use a JTextPane the text should wrap by it self.

http://www.java2s.com/Code/Java/Swing-JFC/JTextPaneStylesExample1.htm
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
January 21 2015 22:44 GMT
#11338
ok thanks. new question

I am trying to place images symmetrically in my jframe
the images are 120 by 120. so i want a jframe with x width 400 so i can have a space of 10 pixels on either side of each image (120*3) and (10*4).

but jframe dimensions seem to include something else like the border around the frame or something because it just isn't lining up.

is there an easy way to set the dimensions of the INSIDE of my JFrame ?

I am guessing I am going to have to do something like put some component in there and make the frame size pack to that component (is my terminology right?).

But is there an easier way anyways?
Toadesstern
Profile Blog Joined October 2008
Germany16350 Posts
Last Edited: 2015-01-21 23:24:38
January 21 2015 23:16 GMT
#11339
On January 22 2015 07:44 travis wrote:
ok thanks. new question

I am trying to place images symmetrically in my jframe
the images are 120 by 120. so i want a jframe with x width 400 so i can have a space of 10 pixels on either side of each image (120*3) and (10*4).

but jframe dimensions seem to include something else like the border around the frame or something because it just isn't lining up.

is there an easy way to set the dimensions of the INSIDE of my JFrame ?

I am guessing I am going to have to do something like put some component in there and make the frame size pack to that component (is my terminology right?).

But is there an easier way anyways?


//edit//
actually no, link was right because it's just an extended version so putting that back in:
A Frame is a top-level window with a title and a border. The size of the frame includes any area designated for the border. The dimensions of the border area may be obtained using the getInsets method. Since the border area is included in the overall size of the frame, the border effectively obscures a portion of the frame, constraining the area available for rendering and/or displaying subcomponents to the rectangle which has an upper-left corner location of (insets.left, insets.top), and has a size of width - (insets.left + insets.right) by height - (insets.top + insets.bottom).

A frame, implemented as an instance of the JFrame class, is a window that has decorations such as a border, a title, and supports button components that close or iconify the window. Applications with a GUI usually include at least one frame. Applets sometimes use frames, as well.


http://docs.oracle.com/javase/tutorial/uiswing/components/frame.html
<Elem> >toad in charge of judging lewdness <Elem> how bad can it be <Elem> also wew, that is actually p lewd.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2015-01-21 23:32:16
January 21 2015 23:31 GMT
#11340
ok, I figured that was what was going on.

I figured out my solution, it was actually pretty simple. I was already painting the images to a jpanel and then adding that to my jframe anyways. What I needed to do was use
setPreferredSize(new Dimension(400, 600));
on my jpanel, and then use pack(); on my jframe so that the inner frame matched the jpanel! yay !
Prev 1 565 566 567 568 569 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 1h 25m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SpeCial 82
SHIN 74
MindelVK 26
StarCraft: Brood War
Britney 42227
Calm 6740
Shuttle 908
Leta 602
firebathero 486
Soma 439
Rush 309
Dewaltoss 98
910 80
Killer 71
[ Show more ]
Mong 63
Bonyth 60
Liquid`Ret 34
Rock 26
Hm[arnc] 18
SilentControl 11
Noble 5
Dota 2
qojqva3081
Dendi1539
syndereN493
420jenkins282
ODPixel212
Other Games
singsing1838
mouzStarbuck327
Hui .196
XaKoH 147
QueenE45
Rex34
Organizations
Other Games
EGCTV1335
[ Show 16 non-featured ]
StarCraft 2
• poizon28 73
• LUISG 31
• 3DClanTV 9
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• Migwel
StarCraft: Brood War
• FirePhoenix9
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 3584
League of Legends
• Jankos1879
• Nemesis1208
Other Games
• Shiphtur48
Upcoming Events
AI Arena Tournament
1h 25m
OSC
4h 55m
Sparkling Tuna Cup
18h 25m
WardiTV Invitational
19h 25m
ByuN vs Percival
Cure vs Classic
Shopify Rebellion Sundays
23h 25m
Spirit vs Mixu
Clem vs TBD
RSL Revival
1d
Serral vs Rogue
BlizzCon
1d 2h
IdrA vs MC
Replay Cast
1d 8h
Afreeca Starleague
1d 18h
Light vs JyJ
Soulkey vs hero
WardiTV Weekly
1d 19h
[ Show More ]
Monday Night Weeklies
2 days
Afreeca Starleague
2 days
Snow vs Shinee
Shine vs EffOrt
GSL
2 days
PiGosaur Cup
3 days
The PondCast
3 days
Kung Fu Cup
3 days
Replay Cast
4 days
KCM Race Survival
4 days
IntoTheTV X SOOP
4 days
Replay Cast
5 days
IntoTheTV X SOOP
5 days
Replay Cast
6 days
GSL
6 days
Liquipedia Results

Completed

Acropolis #5 - TRS
PiG Sty Festival 8.0
Big Dog Cup 2026 Div 1

Ongoing

KCM Race Survival 2026 Season 3
K-JUNGMAN
ASL Season 22
Super Anchor Qualifying S3
CSL 2026 AUTUMN (S22)
Acropolis #5
RSL Revival: Season 6
Calamity Invitational
FISSURE Playground #3
BLAST Open Fall 2026
Esports World Cup 2026
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
Stake Ranked Episode 3
XSE Pro League 2026

Upcoming

Blizzard Classic Cup 2026
Acropolis #5 - GSA
Acropolis #5 - GSB
Acropolis #5 - GSC
SC4ALL II: Brood War
HSC XXX
Stellar Fest 2: Lunar Cup
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
Blizzard Classic Cup 2026
PGL Major Singapore 2026
Stake Ranked Episode 6
BLAST Rivals Fall 2026
IEM Beijing 2026
Stake Ranked Episode 5
PGL Masters Bucharest 2026
1win Private Club #2
Thunderpick World Champ. '26
ESL Pro League Season 24
Stake Ranked Episode 4
1win Private Club #1
Logitech G Play Connect 2026
SL StarSeries Fall 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.