code logs -> 2009 -> Mon, 07 Dec 2009< code.20091206.log - code.20091208.log >
--- Log opened Mon Dec 07 00:00:18 2009
00:05 McMartin [mcmartin@Nightstar-cd8a4fac.pltn13.sbcglobal.net] has quit [[NS] Quit: kernel upgrade]
00:09 McMartin [mcmartin@Nightstar-cd8a4fac.pltn13.sbcglobal.net] has joined #code
00:09 mode/#code [+o McMartin] by Reiver
00:17
< SmithKurosaki>
Hey. I am writing a java gui. I want to print the contents of a textfield to terminal, how do I do this? (println(????);) profit
00:17
< simon`>
System.out.println(string)
00:18
< SmithKurosaki>
(I have never done guis before, and I am pretty bad at java)
00:18
< SmithKurosaki>
Do I need to toString the textfield or something?
00:19
< simon`>
if you have a JTextField foo, you can do foo.getText()
00:19
< SmithKurosaki>
o.0
00:19
< simon`>
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/text/JTextComponent.html#get Text()
00:19
< SmithKurosaki>
(TY)
00:20
< simon`>
e.g. JTextField foo = new JTextField(); ...; System.out.println("I got this: " + foo.getText());
00:20
< SmithKurosaki>
mmk
00:21
< simon`>
SmithKurosaki, method to find out: look up the classes you want to know about. I usually just type "java classname" in google, and google gives me an outdated version of javadoc (1.4.2 gets more hits than 1.6.x)
00:21
< SmithKurosaki>
:woop:
00:21
< SmithKurosaki>
Heh
00:22
< simon`>
some methods are inherited, so getText isn't directly in JTextField's documentation, but it's linked to.
00:23
< SmithKurosaki>
ahh kk
00:23
< SmithKurosaki>
ty
00:55
< ToxicFrog>
Yes; look under "methods inherited from..." for stuff with likely-sounding names.
01:02 You're now known as TheWatcher[t-2]
01:03
< simon`>
I was guessing at something containing the word "text".
01:03
< simon`>
actually I started out looking for the word "value".
01:05 You're now known as TheWatcher[zZzZ]
01:21 Attilla_ [The.Attilla@FBC920.480E8C.EFFF82.B2CEA7] has quit [Ping timeout: 121 seconds]
01:23 Attilla [The.Attilla@FBC920.642D35.9A3E39.B3DA70] has joined #code
01:23 mode/#code [+o Attilla] by Reiver
01:30
< SmithKurosaki>
Comboboxes ;.;
01:31
< SmithKurosaki>
I am not sure how to write the Listener(s) for them
01:31
< SmithKurosaki>
I am also not sure if I have the setup correct or not
01:32
< SmithKurosaki>
http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html#unedita ble
01:32
< SmithKurosaki>
I am trying to use the uneditable box code as a template, but I am not understanding it well
01:34
< SmithKurosaki>
String [] cat_strings = {"Home", "School", "Other"};
01:34
< SmithKurosaki>
JComboBox catList = new JComboBox(cat_strings);
01:34
< SmithKurosaki>
petList.setSelectedIndex(1);
01:34
< SmithKurosaki>
petList.addActionListener(new ActionListener () {
01:34
< SmithKurosaki>
public void actionPerformed(ActionEvent e)
01:34
< SmithKurosaki>
{
01:34
< SmithKurosaki>
JComboBox catList = (JComboBox)e.getSource();
01:34
< SmithKurosaki>
String petName = (String)cb.getSelectedItem();
01:34
< SmithKurosaki>
}
01:34
< SmithKurosaki>
});
01:34
< SmithKurosaki>
I have that so far
01:34
< SmithKurosaki>
(I don't understand the ActionListener at all though
01:35
< simon`>
that's a hack-ish way to use them, too
01:35
< SmithKurosaki>
o.0o
01:36
< simon`>
ActionListener is an interface, meaning what you're doing is creating an instance of an anonymous class.
01:36
< SmithKurosaki>
Yes!
01:36
< SmithKurosaki>
I understand that
01:36
< SmithKurosaki>
(And I know how to create an anonymous class, so I am okay with that)
01:37
< simon`>
and they get triggered whenever the JComboBox emits an action signal.
01:37
<@McMartin>
Which is, IIRC, whenever the value changes.
01:38
< SmithKurosaki>
Yes
01:39
< simon`>
http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html#listene rs
01:39
< SmithKurosaki>
I think I have looked at that...
01:39
< simon`>
oh, that's where you have it from :P
01:40
< SmithKurosaki>
Yes
01:40
< SmithKurosaki>
It's rather confusing the me
01:40
< SmithKurosaki>
*to em
01:40
< simon`>
"Combo boxes also generate item events, which are fired when any of the items' selection state changes. Only one item at a time can be selected in a combo box, so when the user makes a new selection the previously selected item becomes unselected. Thus two item events are fired each time the user selects a different item from the menu. If the user chooses the same item, no item events are fired. "
01:41
< simon`>
which events do you expect to catch?
01:42
< SmithKurosaki>
The question does not really make sense
01:43
< SmithKurosaki>
Like, I know that you have to do something if the user selects a different option other than the one that is currently selected, but beyond that, I am lost
01:46
< simon`>
what do you have to do if the user selects a different option?
01:46
< SmithKurosaki>
In the context of the gui or the gui + the program that it will be attached to once it's done?
01:47
< SmithKurosaki>
In the context of the gui alone, it has to alter what option from the list is displayed when the list is hidden
01:47
< simon`>
doesn't it do that by default?
01:47
< SmithKurosaki>
I don't know
01:47
< SmithKurosaki>
Like I said, I have never written a gui before, and I suck at java
01:48
< SmithKurosaki>
When adding in the context of the program which I will be attaching, it toggles what kind of object is created
01:48
< simon`>
oh, you mean, you want the value of the combobox in a textarea and have it updated
01:48
< SmithKurosaki>
o.0
01:49
< SmithKurosaki>
I do not understand your qyuestion/statment
01:49
< simon`>
(my connection lags right now, but slow on responding)
01:49
< SmithKurosaki>
ahh kkk
01:49
< SmithKurosaki>
*kk
01:54
< SmithKurosaki>
JComboBox catList = (JComboBox)e.getSource();
01:54
< SmithKurosaki>
String petName = (String)cb.getSelectedItem();
01:55
< simon`>
what's cb?
01:55
< SmithKurosaki>
These two lines have me terribly confusd (they are part of the actionlistener)
01:55
< SmithKurosaki>
I am not sure (this is code straight from the code I am using as a base)
01:55
< simon`>
ah, shrug
01:55
< simon`>
public class ComboBoxDemo ... implements ActionListener {
01:55
< simon`>
. . .
01:55
< simon`>
petList.addActionListener(this) {
01:55
< simon`>
. . .
01:55
< simon`>
public void actionPerformed(ActionEvent e) {
01:55
< simon`>
JComboBox cb = (JComboBox)e.getSource();
01:55
< simon`>
String petName = (String)cb.getSelectedItem();
01:55
< simon`>
updateLabel(petName);
01:55
< simon`>
}
01:55
< SmithKurosaki>
Yes
01:55
< simon`>
. . .
01:55
< simon`>
}
01:56
< simon`>
so if you rename cb in one place, rename it in both.
01:56
< SmithKurosaki>
I wasn't planning on renaming it
01:56
< simon`>
oh
01:56
< simon`>
it just looked like you did.
01:57
< SmithKurosaki>
There is no info in JComboBox in the javadocs, I am not sure what the methods do
01:57
< SmithKurosaki>
(getSource and getSelectedItem)
01:58
< SmithKurosaki>
Like, I am not sure what I need to put in that listener, do I need to update the combobox or can I just leave it empty until I start to integrate my code to have it pick which object to create
01:58
< simon`>
e is the event object, you have to look for those methods in the ActionEvent class. they basically just return whichever object triggered the event, which you then typecast and call by some name
01:59
< simon`>
you could do that
01:59
< SmithKurosaki>
mmk
02:00
< simon`>
you'd probably want whichever routine creates the objects you are talking about in a separate location and then have this event listener call that.
02:07
< SmithKurosaki>
Yes
02:07
< SmithKurosaki>
(Which I will do after getting this to properly output stuff
02:07
< SmithKurosaki>
(to terminal)
02:07 * SmithKurosaki curses guis
02:09 * McMartin helps.
02:09
<@McMartin>
There are no good options, only less-bad ones.
02:09 Kazriko [kaz@Nightstar-e09690fa.client.bresnan.net] has joined #code
02:09 mode/#code [+o Kazriko] by Reiver
02:12
< SmithKurosaki>
Hr,
02:12
<@McMartin>
That said, Swing actually is the one that's been the least painful for me to code directly.
02:13
< SmithKurosaki>
When I print my labels, combobox and text fields, can I use getText() on all of them, or just textfields?
02:13
<@McMartin>
I don't know about comboboxes, but I'm pretty sure labels have getText().
02:14
<@McMartin>
The online Javadocs are excellent for questions like that; they list all the methods in each class and where they got them from.
02:14
< SmithKurosaki>
(I want to make sure it's collecting the data properly before fussing around with trying to integrate code
02:14
< SmithKurosaki>
Also, my n key appears to only work sparingly atm... ;.;
02:14
< SmithKurosaki>
(The javadocs have a habit of terribly overwhelming me)
02:15
<@McMartin>
Let me do a quick check.
02:15
<@McMartin>
For the question you directly asked, there are shortcuts.
02:15
< SmithKurosaki>
Cool
02:16
< SmithKurosaki>
Shortcuts? As long as I don't have to rewrite when I get to integrating my non-GUI code, then yay
02:16
<@McMartin>
Went to http://java.sun.com/javase/6/docs/api/ , went to javax.swing package, went to JLabel class, text searched for "getText()"
02:16
<@McMartin>
Found it in "Method Summary" instead of in "methods inherited from blah"
02:16
< SmithKurosaki>
Heh
02:17
< SmithKurosaki>
Cool
02:17
<@McMartin>
This means you can use it, but that you'd have to make sure it was a JLabel first (there's no relevant superclass that makes TextField and JLabel cousins.)
02:17
< SmithKurosaki>
TY :)
02:17
< SmithKurosaki>
Hmr
02:17
<@McMartin>
JComboBox, however, does not have that method...
02:17
< SmithKurosaki>
How the hell would I do that?
02:18
<@McMartin>
... did a search for String to see if that would help any, didn't get anything useful...
02:19 * SmithKurosaki sighs
02:19
< SmithKurosaki>
(I do not like java much at all)
02:20
<@McMartin>
... so I searched for "get" and looked through all those for something plausible, found getSelectedItem().
02:20
<@McMartin>
Turns out ComboBoxes can be loaded with all kinds of random things.
02:20
< SmithKurosaki>
Okay
02:20
< SmithKurosaki>
I tried to find out what getSelected item was for
02:20
<@McMartin>
I suspect the chain you'll want for debugging will be getSelectedItem().toString().
02:20
< SmithKurosaki>
I could not find it
02:21<~Reiver> Is this things picture smaller than a normal photo? http://www.firstin.co.nz/product.asp?ProdID=1464
02:21<~Reiver> 'normal photo' being 5" x 7"
02:21
< SmithKurosaki>
Can I use a default toString though? Or do I have to write one myself?
02:21
< SmithKurosaki>
??
02:22
<@McMartin>
So, getSelectedItem will return either something the user typed in (if editable) or something you previously registered as a choice with addItem(Object x).
02:22
<@McMartin>
I imagine in the latter case you were adding Strings, so toString() is basically just a cast.
02:22
<@McMartin>
(So default is fine)
02:22
<@McMartin>
I'm not positive, but I have to guess that custom user-entered stuff will have a sensible default toString as well.
02:22
<@McMartin>
getSelectedItem() returns "Object", which is to say, anything.
02:23
<@McMartin>
Calling toString() on the return will call whichever toString that class has. This is a subtle difference, sometimes, from C++
02:23
<@McMartin>
But if you haven't had to deal with C++'s virtual/nonvirtual distinction, we don't need to muddy those waters.
02:24
< simon`>
SmithKurosaki, just because JComboBoxes can be filled with all sorts of random objects doesn't mean you can't have an overview of which objects you put inthere. =)
02:25
< simon`>
e.g. you can typecast them to some common denominator
02:25
<@McMartin>
True, but I'd put two caveats on that
02:25
< SmithKurosaki>
Clarification: if an object inherits a method from something, that means I can use it without futting around with it?
02:25
<@McMartin>
Uuuuuusually.
02:26
<@McMartin>
What kind of "futting" are you thinking of?
02:26
<@McMartin>
And in what context?
02:26
< SmithKurosaki>
no C++
02:26
<@McMartin>
You're asking one of two things here and I can't tell which.
02:26
<@McMartin>
You should never need C++ ever when writing Java.
02:26
< SmithKurosaki>
I can just go Jbutton.settext() yes?
02:26
<@McMartin>
Yeah.
02:27
< simon`>
setText
02:27
< SmithKurosaki>
Cool, brb
02:28
< SmithKurosaki>
Next issue
02:28
<@McMartin>
If you're *using* a class, whether any given method is custom-overridden or inherited from a superclass should never matter.
02:29
<@McMartin>
And, indeed, if you think it's one of the superclasses, it *still* won't matter, because it will know which version to call (its own).
02:29
< SmithKurosaki>
I have 5 labels, 1 combo and 4 text fields that I wanted to split between labels and else, labels go in west section, box + fields go in center, it's only displaying the second last set
02:29
<@McMartin>
That's why you can have something of any type returned as an Object, stored in an Object variable, and toString() will do the right thing.
02:29
< SmithKurosaki>
wtc
02:30
<@McMartin>
(The other context is if you're *writing* a class, and whether you can rely on inherited behavior from your superclass will depend on what your subclass is doing.)
02:30
<@McMartin>
Oh, you're using a BorderLayout?
02:30
<@McMartin>
The BorderLayout only stores five widgets, IIRC, so if you put one thing in center and another thing in center the second thing added replaces the first.
02:31
<@McMartin>
You need to have a GridLayout or something in Center to make sure that part works.
02:31
<@McMartin>
BorderLayout is really more "menubar goes on north, actual window goes in Center."
02:31
<@McMartin>
Let me see how I did it in Blorple.
02:33
< simon`>
what's Blorple?
02:33
< simon`>
ah, googled it.
02:33
<@McMartin>
The only actually useful Swing program I've written~
02:34
<@McMartin>
And there I used nested JSplitPanes in a JFrame.
02:34
<@McMartin>
So that doesn't help.
02:34
<@McMartin>
Any given layout was a BorderLayout, but it only ever had one Widget in it *anyway*.
02:36
< SmithKurosaki>
Hrm
02:36
<@McMartin>
What you'd describing though sounds like GridLayout is what you want.
02:36
< SmithKurosaki>
I find it odd that it is displaying the second last added pair, (I think) and not the last pair
02:36
< SmithKurosaki>
(Sorry for afkness, was poking code)
02:37
<@McMartin>
Yeah, not sure what's going on there
02:37
< SmithKurosaki>
Grid does sound more useful, because then I don't need to stack frames, tes?
02:37
< SmithKurosaki>
*yes
02:37
<@McMartin>
Quite.
02:38
<@McMartin>
The main issue with GridLayout is that you can't have them be varying widths.
02:38
<@McMartin>
So you might want a border layout, with a gridlayout full of labels on the west side and a gridlayout full of textfields in the center; but I'm not sure how that can be made to guarantee they line up.
02:38
< SmithKurosaki>
After I get this part working, I need to write two more windows and then start combining the code I have already written into it
02:38
< SmithKurosaki>
In two hours
02:39 * simon` spent a day learning layout managers
02:39
< SmithKurosaki>
Hr
02:39
< SmithKurosaki>
Well, I only had today to work on it... ;.;
02:40
< SmithKurosaki>
And, I fell down the stairs this morning. It was not a good start to the day
02:44
<@McMartin>
Layout managers are pretty ;_;
02:44
< SmithKurosaki>
So, I am looking at the GridLayout, it is kind of confusing ;.;
02:44
< SmithKurosaki>
Java in general is relatively confusing to me
02:45
< SmithKurosaki>
http://java.sun.com/docs/books/tutorial/uiswing/examples/layout/GridLayoutDemoPr oject/src/layout/GridLayoutDemo.java
02:45
< SmithKurosaki>
Trying to figure this out
02:46
<@McMartin>
There's a bunch of silliness going on all at once in there.
02:46
<@McMartin>
Try this: http://blorple.svn.sourceforge.net/viewvc/blorple/src/java/net/sf/blorple/gui/La uncherConfig.java?revision=73&view=markup
02:46
<@McMartin>
Starting at line 42.
02:47
<@McMartin>
It's a JPanel, it passes in a GridLayout(rowCount,columnCount) to its superclass constructor
02:47
<@McMartin>
Then it just keeps calling add() with widgets and it fills the thing up.
02:47
<@McMartin>
Left to right, top to bottom, in that order.
02:56
<@McMartin>
SpringLayout looks like what all the serious GUI kits use, but it also looks like it's intended to be automatically generated by a GUI editing tool (which all the serious toolkits *also* do: Glade, Qt Designer, Interface Builder)
02:58
< SmithKurosaki>
Heh
02:59
<@McMartin>
Anyway, GridLayout is ugly but it's very straightforward to set up; that constructor just constructs widgets in a loop and throws 'em in.
03:00
< SmithKurosaki>
So, I have 5 labels in one section, and then a combo and 4 textfields in another, so do I just go BorderLayout.add(GridLayout(1,5))?
03:00
< SmithKurosaki>
And then add to the grid?
03:00
< SmithKurosaki>
(I have a feeling I did something wrong there
03:01
< SmithKurosaki>
*frame.add(GridLayout(x,y), BorderLayout.WEST)?
03:03
< SmithKurosaki>
Hmm. Is gridlayout indexed by 1 or 0?
03:03
< simon`>
GridLayout gl = new GridLayout(1,5); frame.setLayout(gl); frame.add(combobox1); frame.add(combobox2); ...
03:03
< SmithKurosaki>
frame = JFrame
03:03 AbuDhabi [annodomini@Nightstar-06734d82.adsl.tpnet.pl] has quit [[NS] Quit: I walked 14.4 km in 2 hours 5 minutes, thereby beating the Google Maps estimate of such a journey by 50 minutes. On a winter night, in the rain and drunk. I have no idea who the time estimates are callibrated for.]
03:04
< SmithKurosaki>
o.0
03:04
< simon`>
JFrame frame = new JFrame(...) yes
03:04 * SmithKurosaki confuion\
03:04
< SmithKurosaki>
Let my tyoe something
03:04
< SmithKurosaki>
frame.add(new GridLayout(1,5), BorderLayout.WEST);
03:04
< SmithKurosaki>
This look legal to people?
03:05
< SmithKurosaki>
Ok, wait, shit
03:05
< SmithKurosaki>
While this may actually be legal, I can't access it
03:06
< SmithKurosaki>
(after this_
03:08 gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has quit [[NS] Quit: Z?]
03:08
< SmithKurosaki>
You can't add to the Gridlayout by going like frame.add(var, gl)?
03:09
< SmithKurosaki>
o.-0
03:09
< SmithKurosaki>
I missed the setlayout line
03:09
< simon`>
oh, I think what you want is frame.add(new JPanel(new GridLayout(1,5), BorderLayout.WEST);
03:09
< SmithKurosaki>
:waugh:
03:09
< SmithKurosaki>
What now?
03:10 * SmithKurosaki is very confused
03:10
< simon`>
well, you can't just add a layout manager to a subsection within another layout manager. you have to first add a container in, say, SOUTH of a BorderLayout, and within that container define a new layout manager.
03:11
< SmithKurosaki>
;.;
03:11
< SmithKurosaki>
So,
03:12
< SmithKurosaki>
I have the JFrame and the BorderLayout atm
03:12
< simon`>
let's say your main window uses BorderLayout and has two parts, one with a bunch of comboboxes and one with a bunch of labels, five each. we could place the comboboxes to the left and the labels to the right.
03:12
< SmithKurosaki>
Now, I need to have JFrame, JPanel, BorderLayout and GridLayout?
03:12
< SmithKurosaki>
(First is bottom on stack_
03:12
< simon`>
that'd be an option
03:13
< SmithKurosaki>
That isn't quite what I am up to, but go on (I am using all 5 border sections)
03:13
< SmithKurosaki>
For reference, I am using W/C for Labels + combo/tct
03:13
< simon`>
well, the point with having sub-containers is that layout managers like BorderLayout quickly run out of addressable areas.
03:13
< SmithKurosaki>
*txt
03:13
< SmithKurosaki>
:(
03:14
< SmithKurosaki>
Oh wait, I misinterpreted that
03:14
< SmithKurosaki>
I read that as 'the stuff you want to do is going to kill your comp's memory)
03:14
< simon`>
you only have five, so if you want more than five objects in your screen (and you want them to stretch differently than how BorderLayout does), you need a sub-container like a JPanel, give it its own layout manager and stuff things inside it.
03:14
< SmithKurosaki>
Not, the borderlayout can handle so much
03:15
< SmithKurosaki>
Hrm
03:15
< SmithKurosaki>
Would it maybe make more sense to switch the panel and the borderlayout?
03:16
< SmithKurosaki>
(W/C/E are the only sections that need multi-object support)
03:16
< simon`>
e.g. leftpanel = new JPanel(new GridLayout(1,5)); rightpanel = new JPanel(new GridLayout(1,5)); leftpanel.add(cb1); ...; rightpanel.add(lbl1); ...; mainwindow.add(leftpanel, BorderLayout.WEST); mainwindow.add(rightpanel, BorderLayout.EAST);
03:17
< simon`>
BorderLayout is usually nice to have in your main window, which I think is why it's the default.
03:18
< SmithKurosaki>
The code variables has me confused
03:18
< SmithKurosaki>
I get leftpanel / rpanel = new jpan(new gl())
03:18
< SmithKurosaki>
But lp.add and mainwindow.add??
03:19
< SmithKurosaki>
Where did the args for lp/rp and mainwindow come from?
03:19
< simon`>
yes. consider mainwindow (which is a JFrame object) a container and leftpanel and rightpanel (which are JPanel objects) as sub-containers
03:19
< SmithKurosaki>
mmk
03:19
< SmithKurosaki>
(what is cb1 and lbl1 though?
03:19
< SmithKurosaki>
The rest of it I grok now
03:19
< simon`>
they're just random graphical objects. comboboxes, labels, whatever.
03:20
< SmithKurosaki>
mk
03:21
< simon`>
so instead of adding these large amounts of graphical objects directly to the main window, which uses a BorderLayout and therefore has only five addressable places to put stuff, you add a sub-container (JPanel) to one of those areas, give the sub-container another layout manager to handle its own graphical elements, and add stuff to the subcontainer.
03:21
< SmithKurosaki>
ok. So let's see if I grok this
03:22
< SmithKurosaki>
JFrame has BorderLayout. W/C/E will all get a JPanel in them which will contain a Gridlayout
03:22 Vornicus [vorn@ServerAdministrator.Nightstar.Net] has joined #code
03:22 mode/#code [+o Vornicus] by Reiver
03:23
< SmithKurosaki>
I am not sure how to access the parts of the gridlayout though. Or will it just add each thing you add to it in sequence?
03:23
< simon`>
exactly
03:23
< simon`>
you can study each layout manager in detail
03:24
< simon`>
there's a whole bunch that are useful for different purposes.
03:24
< SmithKurosaki>
I don't really have time to do that right now
03:24
< SmithKurosaki>
Maybe after exams
03:24
< simon`>
well, GridLayout is useful for a fixed number of elements in a grid. it'll fill the grid out systematically as McMartin explained.
03:25
< SmithKurosaki>
kk
03:29 Attilla [The.Attilla@FBC920.642D35.9A3E39.B3DA70] has quit [[NS] Quit: ]
03:30
< SmithKurosaki>
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JPanel.html#JPanel()
03:30
< SmithKurosaki>
I just want a straight up JPanel, which constructor do I use, the noargs?
03:31
< SmithKurosaki>
Or, can I specify the gridlayout in one of them?
03:31
< SmithKurosaki>
mv,
03:31
< SmithKurosaki>
nxm
03:31
< SmithKurosaki>
>.< nvm
03:38
< SmithKurosaki>
My code just went boom :(
03:39
< SmithKurosaki>
http://lua.pastey.net/129877 <- errors
03:39
< SmithKurosaki>
http://lua.pastey.net/129878 <- code
03:42
< simon`>
SmithKurosaki, which line in your file is the problematic one judging from the error?
03:42
< SmithKurosaki>
I have no clue
03:42
< SmithKurosaki>
I suck at java
03:42
< SmithKurosaki>
And error stuff in general
03:42
< simon`>
it prints a callstack, so you have to find the place in this callstack that is relevant to your code.
03:43
< simon`>
...
03:43
< simon`>
8 at HelloWorldSwing.createAndShowGUI(HelloWorldSwing.java:31)
03:43
< simon`>
9 at HelloWorldSwing.access$000(HelloWorldSwing.java:5)
03:43
< SmithKurosaki>
Well, the HelloWorldSwing ones in that case
03:44
< simon`>
what happens on line 31?
03:44
< simon`>
frame.add(label_cat, leftpanel);
03:45
< SmithKurosaki>
Yea, wtf
03:45
< simon`>
so yeah, I can see how this ought to translate into "In the JFrame 'frame', add the element 'label_cat' to the area denoted 'leftpanel'", since that's how it would work if the area denoted were e.g. BorderLayout.SOUTH.
03:46
< SmithKurosaki>
Okay...
03:46
< simon`>
what you want to do, however, is add label_cat to leftpanel and add leftpanel to frame.
03:46
< SmithKurosaki>
o.0
03:46
< simon`>
that extra argument to add() is quite restrictive.
03:47
< SmithKurosaki>
so, frame.add(leftpanel.add(label))?
03:47
< simon`>
err
03:47
< SmithKurosaki>
No stacking?
03:47
< simon`>
as I demonstrated earlier, I'd do: leftpanel.add(label1); leftpanel.add(label2); ... frame.add(leftpanel)
03:48
< SmithKurosaki>
ahh ll
03:48
< simon`>
just imagine .add() is glue
03:48
< SmithKurosaki>
kk
03:48
< SmithKurosaki>
Good way to look at it
03:50
< simon`>
for stacking to work, add() would have to 'return this()', which I don't think it does.
03:50
< SmithKurosaki>
ahh
03:50
< SmithKurosaki>
hmr
03:50
< SmithKurosaki>
Issue
03:50
< SmithKurosaki>
(Don't know if this is true in java or not)
03:51
< SmithKurosaki>
Wait, nvm
04:00
< SmithKurosaki>
IT'S ALIVE! It's just row long, not column long
04:01
< simon`>
cool
04:01
< simon`>
are you turning something in, or is this practice for an exam?
04:01
< SmithKurosaki>
It's due in a little less than an hour
04:02
< simon`>
you are at least better off than another person I saw on IRC earlier who asked if there were any quick guides to C++, since he had an exam 12 hours later. :-)
04:02
< simon`>
ow!
04:02
< Namegduf>
Haha.
04:02
< SmithKurosaki>
I still have to make two more of these + tie my code into it though
04:02
< SmithKurosaki>
Feel like helping anyone?
04:02
< SmithKurosaki>
:p
04:02
< simon`>
I haven't helped already?! :)
04:03
< SmithKurosaki>
I mean making a gui
04:03
< SmithKurosaki>
(Thank you though :))
04:03
< SmithKurosaki>
Anyways
04:03 * SmithKurosaki tries to get at least part of this done
04:03
< SmithKurosaki>
I need to write one that gives me a menu
04:03
< simon`>
a JMenu?
04:04
< SmithKurosaki>
It needs to be a dropdown within a JFrame or something
04:04 GeekSoldier [Rob@Nightstar-e86e3e0d.ip.cablemo.net] has quit [Client closed the connection]
04:04 GeekSoldier [Rob@Nightstar-e86e3e0d.ip.cablemo.net] has joined #code
04:04
< SmithKurosaki>
This needs to launch the window I have been working on, or a search window or quit
04:04
< SmithKurosaki>
But that is all it really needs to do
04:06
< SmithKurosaki>
hMM
04:08
< SmithKurosaki>
Okay, that works -- menu
04:08
< SmithKurosaki>
Time to do menu or integrate my code into this thing
04:08
< SmithKurosaki>
Wait, I need a reset button!
04:14
< SmithKurosaki>
So, I just go label.setText(""); ?
04:14
< SmithKurosaki>
*label = textfield
04:14
< SmithKurosaki>
(I want to blank them)
04:15
< simon`>
that's one way.
04:15
< SmithKurosaki>
Better way, you have?
04:16 * SmithKurosaki has lots of pain in wrist, argh
04:16
< simon`>
.setVisible(false)
04:16
< SmithKurosaki>
o.0
04:16
< SmithKurosaki>
so, textfield.setVisible(false)?
04:16
< SmithKurosaki>
:woop:
04:19
< SmithKurosaki>
I wasn't expecting them to disappear
04:19
< SmithKurosaki>
Do I need to recreate them in that listener then?
04:20
< simon`>
I don't think visibility makes them unlistened to, etc.
04:20
< SmithKurosaki>
o.0
04:20
< SmithKurosaki>
It makes them disappear
04:20
< SmithKurosaki>
(I don't understand what you mean by that)
04:21
< simon`>
just .setVisible(true) whenever you want to see them again.
04:21
< simon`>
when they disappear, do they realign existing elements so that they get pushed around?
04:21
< SmithKurosaki>
no
04:21
< SmithKurosaki>
They also don't clear the data in them
04:22
< SmithKurosaki>
I think I am just going to blank them with setText
04:22
< simon`>
sure thing
04:23
< SmithKurosaki>
That works
04:23
< SmithKurosaki>
I should probably attach this now
04:24
< SmithKurosaki>
(How the hell do I attach a gui and non-gui code?)
04:24
< SmithKurosaki>
Also, how do I make a gui menu?
04:24 * SmithKurosaki goes to look at JMenu
04:24
< simon`>
"attach code"? not sure what that means.
04:25
< SmithKurosaki>
I have code that I wrote before
04:25
< SmithKurosaki>
I am writing the gui for said code
04:25
< SmithKurosaki>
Do I leave the gui as a seperate class file, or intermingle it with the class it will interact with, or?
04:28
< simon`>
you should definitely separate your GUI code from your model
04:28
< SmithKurosaki>
mmk
04:29
< simon`>
when I write java apps, I try to keep within MVC (model, view, control). this way, I could easier replace either without touching the two other.
04:29
< SmithKurosaki>
Should I have all my gui in one file?
04:29
< simon`>
depends on how big it is
04:29
< SmithKurosaki>
3 windows
04:29
< simon`>
if you find out you need to define a lot of properties, they should have their own class in their own file
04:30
< SmithKurosaki>
Menu window launches the one I just wrote, or one that is very similar, but does slightly differnt things
04:30
< SmithKurosaki>
Mabe
04:30
< SmithKurosaki>
idk
04:30
< simon`>
I usually have MainWindow which extends JFrame and contains most of my GUI stuff. if any of my subcomponents or other windows take too much or define their own classes, they naturally end up in their own files.
04:30
< simon`>
you have a window for displaying a menu?
04:31
< SmithKurosaki>
Not yet, but my add gui is big enough to require seperation
04:35
< SmithKurosaki>
But, please, explain this menu stuff to me
04:37
< SmithKurosaki>
(I have 15 mins to try to get this working more)
04:39
< SmithKurosaki>
Also
04:39
< SmithKurosaki>
I had a cmd menu already, how can I get it to call the gui for the one section of the program?
04:40
< SmithKurosaki>
(I have if cmd = 'add', call Add().) Is there a way to say if cmd == 'add', call guifile?
04:40
< SmithKurosaki>
Well, AddGUI.main?
04:41
< simon`>
http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html
04:41
< simon`>
JMenus are quite simple
04:42
< simon`>
just scroll down and see their sample code.
04:44 SmithKurosaki [Smith@Nightstar-f933638e.dsl.teksavvy.com] has quit [Connection closed]
04:47 SmithKurosaki [Smith@Nightstar-f933638e.dsl.teksavvy.com] has joined #code
04:48
< SmithKurosaki>
Sorry TF
04:48
< SmithKurosaki>
Back (all my progs froze on me)
04:49
< SmithKurosaki>
Anyways, how do you access the mains of other classes, is what I put legal/.
04:54
< SmithKurosaki>
This thing is due now
04:54
< SmithKurosaki>
;.;
04:54
< SmithKurosaki>
No time for menu for me
05:09
< SmithKurosaki>
Oh well
05:09
< SmithKurosaki>
I didn't get to get it working like I would have liked
05:09
< SmithKurosaki>
If I can at least get a 50 on it, I am happy
05:12 dmlandrum [darren@Nightstar-d7184406.sfldmi.sbcglobal.net] has quit [[NS] Quit: Leaving]
05:13
< SmithKurosaki>
Thanks a lot for the help guys1
06:07 Vornicus [vorn@ServerAdministrator.Nightstar.Net] has quit [[NS] Quit: Leaving]
06:09 Vornicus [vorn@ServerAdministrator.Nightstar.Net] has joined #code
06:09 mode/#code [+o Vornicus] by Reiver
06:22 Derakon is now known as Derakon[AFK]
06:35 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has joined #code
07:06 Reiver [reaverta@ServerAdministrator.Nightstar.Net] has quit [Ping timeout: 121 seconds]
07:18 Reiver [reaverta@ServerAdministrator.Nightstar.Net] has joined #code
07:18 mode/#code [+qo Reiver Reiver] by ChanServ
08:46 You're now known as TheWatcher
08:57 Vornicus is now known as Vornicus-Latens
09:17 Vornicus-Latens [vorn@ServerAdministrator.Nightstar.Net] has quit [[NS] Quit: ]
09:19 * McMartin finishes coding the Weasel Decaffeination Logic in his I7 WIP.
09:19 Rhamphoryncus [rhamph@Nightstar-a62bd960.abhsia.telus.net] has quit [Client exited]
09:28 Tarinaky [Tarinaky@Nightstar-b414d71e.adsl.virginmedia.net] has quit [Ping timeout: 121 seconds]
09:35
<@TheWatcher>
... 'weasel decaffeination logic' wut
09:39
<@McMartin>
There are weasels.
09:39
<@McMartin>
You need to deny them caffeine.
09:41 Tarinaky [Tarinaky@Nightstar-71676ad2.adsl.virginmedia.net] has joined #code
09:56
<@TheWatcher>
I... see.
09:57 gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has joined #code
09:58 MyCatSchemes [mycatverbs@Nightstar-f43ca811.blueyonder.co.uk] has quit [Ping timeout: 121 seconds]
10:26 Attilla [The.Attilla@FBC920.642D35.9A3E39.B3DA70] has joined #code
10:26 mode/#code [+o Attilla] by Reiver
10:26 AnnoDomini [annodomini@Nightstar-06734d82.adsl.tpnet.pl] has joined #code
10:26 mode/#code [+o AnnoDomini] by Reiver
10:40 MyCatSchemes [mycatverbs@Nightstar-3b2c2db2.bethere.co.uk] has joined #code
10:47
< MyCatSchemes>
http://www.cateringblog.co.uk/food-and-drink/new-products/weasel-poo-latte-anyon e.html
10:54
< gnolam>
So... has Google officially switched to the shitty DHTML bling, or was it just to get rid of me personally?
11:05
< MyCatSchemes>
Google's officially switched to the shitty DHTML bling.
11:07 stan [stan@Nightstar-3b2c2db2.bethere.co.uk] has joined #code
11:07 stan [stan@Nightstar-3b2c2db2.bethere.co.uk] has left #code []
11:08
<@AnnoDomini>
Is that why the page fades in?
11:12
<@TheWatcher>
Yeah
11:15
< gnolam>
Guess I'll continue to use Bing then.
11:15
< gnolam>
I find the fade extremely distracting.
11:16
< gnolam>
And with absolutely no redeeming qualities.
11:16 * TheWatcher never uses google's front page anyway, searches via browser url bar
12:21 Tarinaky [Tarinaky@Nightstar-71676ad2.adsl.virginmedia.net] has quit [Ping timeout: 121 seconds]
12:35 Tarinaky [Tarinaky@Nightstar-dd02a5ca.adsl.virginmedia.net] has joined #code
13:03 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has quit [Client closed the connection]
13:49 Tarinaky [Tarinaky@Nightstar-dd02a5ca.adsl.virginmedia.net] has quit [Ping timeout: 121 seconds]
14:03 Tarinaky [Tarinaky@Nightstar-a2067533.adsl.virginmedia.net] has joined #code
14:54 Tarinaky [Tarinaky@Nightstar-a2067533.adsl.virginmedia.net] has quit [Ping timeout: 121 seconds]
15:08 Tarinaky [Tarinaky@Nightstar-af6393e8.adsl.virginmedia.net] has joined #code
15:32 AbuDhabi [annodomini@Nightstar-360d7405.adsl.tpnet.pl] has joined #code
15:34 AnnoDomini [annodomini@Nightstar-06734d82.adsl.tpnet.pl] has quit [Ping timeout: 121 seconds]
15:34 Attilla [The.Attilla@FBC920.642D35.9A3E39.B3DA70] has quit [Connection reset by peer]
15:35 Attilla [The.Attilla@FBC920.642D35.9A3E39.B3DA70] has joined #code
15:35 mode/#code [+o Attilla] by Reiver
16:54 Vornicus [vorn@ServerAdministrator.Nightstar.Net] has joined #code
16:54 mode/#code [+o Vornicus] by Reiver
17:02 Rhamphoryncus [rhamph@Nightstar-a62bd960.abhsia.telus.net] has joined #code
18:06 Syloqs_AFH [Syloq@NetworkAdministrator.Nightstar.Net] has joined #code
18:07 Syloqs_AFH is now known as Syloqs-AFH
18:20 Derakon[work] [Derakon@Nightstar-d44d635e.ucsf.edu] has joined #code
18:20
< Derakon[work]>
That's how I like to start the morning: a quick verification/bugfix cycle, then pushing the code to production and saving a backup to the remote repo. :)
18:25 Attilla [The.Attilla@FBC920.642D35.9A3E39.B3DA70] has quit [Connection reset by peer]
18:26 Attilla [The.Attilla@FBC920.642D35.9A3E39.B3DA70] has joined #code
18:26 mode/#code [+o Attilla] by Reiver
18:30
< Derakon[work]>
Reiv, why don't we have a proper chanop system here?
18:30
< Derakon[work]>
It'd be nice if I could e.g. switch nicks and tell chanserv to op me.
18:31 NSGuest44130 [c0cb88fe@Nightstar-14e5d099.mibbit.com] has joined #code
18:32 NSGuest44130 is now known as Finale
18:32 Finale is now known as NSGuest47323
18:32 NSGuest47323 is now known as Seraph
18:35 Seraph is now known as Finale
18:56 You're now known as TheWatcher[afk]
18:58 Tarinaky [Tarinaky@Nightstar-af6393e8.adsl.virginmedia.net] has quit [Connection closed]
18:59 MyCatSchemes [mycatverbs@Nightstar-3b2c2db2.bethere.co.uk] has quit [Ping timeout: 121 seconds]
19:07
< Derakon[work]>
Latest fixed bug: changed loadMosaic to actually load the mosaic, instead of saving the mosaic. Required change: "mosaicState.view.save(filename)" => "mosaicState.view.load(filename)"
19:08
< Finale>
LOL
20:28
< Derakon[work]>
I can't help but think there's a better way to get "the smallest power of 2 that is above this number" than this, but, barring code style problems, I can't think of an alternate approach: http://paste.ubuntu.com/336793/
20:31
< AbuDhabi>
Have you tried logarithms?
20:31
< gnolam>
Well, you could go at it mathematically 2^ceil(x).
20:31 You're now known as TheWatcher
20:31
< gnolam>
+,
20:31
< gnolam>
And there are tricks with ORing and bit shifts in C, but I'm guessing those aren't available to you.
20:32
< gnolam>
Err
20:32
< Derakon[work]>
Oh, log, yeah. That's what I wanted.
20:32
< gnolam>
2^ceil(log2(x)) I meant
20:32
< gnolam>
And grammar like Yoda I have today.
20:34
< Derakon[work]>
ONE-LINER'D!
20:34
< Derakon[work]>
return (2**math.ceil(math.log(width, 2)), 2**math.ceil(math.log(height, 2)))
20:34
< Derakon[work]>
(Replacing "nx" with "width", etc.)
20:39
< Finale>
http://www.overheardinnewyork.com/archives/021041.html
20:43 EvilDarkLord [jjlehto3@Nightstar-f1ccbb45.hut.fi] has quit [Ping timeout: 121 seconds]
20:44 EvilDarkLord [jjlehto3@Nightstar-f1ccbb45.hut.fi] has joined #code
21:19
< Derakon[work]>
I just love finding code that would crash the program if it were ever run, which it fortunately never is.
21:20
< Derakon[work]>
For example, this reference to a function named "appendMosaic" which is not defined anywhere.
21:22
< Derakon[work]>
Fortunately, it is blocked by an "if foo != None: " if statement.
21:23
< Derakon[work]>
(which a) should be "if foo is not None", and b) should be removed entirely since foo is apparently always None)
21:33
< Derakon[work]>
...why does this class need 31 member variables? ;_;
21:34
<@McMartin>
:science:
21:34
<@McMartin>
But sometimes it happens.
21:34
< Derakon[work]>
Including m_nImg, m_nImgs, m_w, m_h, m_hideTheseImages, m_moreMaster_enabled...
21:35
< Derakon[work]>
(In fact, there are more than 31 member variables, since I've converted some of them away from using the m_* naming scheme)
21:42
< Rhamphoryncus>
And lo', Guido did invent self., and refuse to budge despite all the whining about verbosity, and it was good
21:42
< Derakon[work]>
\o/
21:43
<@McMartin>
self. was present in ObjC and Smalltalk before Python~
21:47
< Derakon[work]>
Mmph...I can see that, once I've fixed the code style issues in this file, I'm going to have to work on fixing the incestuous relationship it has with another code file.
21:47
< Derakon[work]>
Lots of referring to member variables from outside of the class going on...
21:48
< Finale>
lol
21:48
< Finale>
that's more of a polyamorous relationship. XD
21:49 * Derakon[work] replaces m_noColor with shouldUseColor, discovers that every if statement reads as "if not self.m_noColor".
21:49
< Derakon[work]>
Way to invert your boolean names, Sebastian!
21:53
< Derakon[work]>
...and why are you prefacing an iteration over a list with a check to see if the list is non-empty?
22:06
< Finale>
http://www.overheardintheoffice.com/archives/010373.html
22:12 * gnolam flails at his surface normals.
22:33
< Derakon[work]>
"Why do we have member variables for when the zoom changes and when the size changes? What does it mean for "size" to change, anyway? Oh, I see. The size changing one is unused. Right, out you go.
22:34
<@TheWatcher>
>.<
22:55
< SmithKurosaki>
Does anyone understand the theory behind late binding in java?
22:58
< ToxicFrog>
Late binding means it doesn't decide what method to call until runtime.
22:59
< ToxicFrog>
So if you have, say, an Animal variable which actually holds a Cat, and you call its .getAge() method, it will call Cat.getAge() and not Animal.getAge()
22:59
< SmithKurosaki>
Ahh
22:59
< ToxicFrog>
Even though the variable is an Animal, it will look at the actual object at runtime, see that it's a Cat, and do the right thing.
22:59
< SmithKurosaki>
It's what allows for overriding!
22:59
< ToxicFrog>
If it were early binding, it would decide at compile time
22:59
< ToxicFrog>
So if you had an Animal, calling .getAge() on it would call Animal.getAge() even if it's actually a Cat or a Bird or what have you at runtime.
23:00
< SmithKurosaki>
Ahh
23:00
< SmithKurosaki>
So, if java was early binding, inheritence and overriding wouldn't be possible right?
23:00
< SmithKurosaki>
(I am studying for my java exam)
23:01
< ToxicFrog>
It would be possible, but it would be harder to use properly
23:02
< ToxicFrog>
You could always go, say: ((Cat)foo).getAge() - but now you need to know that it's a Cat, rather than letting the runtime know and handle the rest for you.
23:06
<@Vornicus>
the later the binding the easier it is to program; the earlier the binding the faster method lookup is.
23:27
< Derakon[work]>
Also, the later the binding, the harder it is to write the compiler/interpreter. ?.?
23:27
< Derakon[work]>
(Side note: I just found a set of five functions that are entirely unused. Woot!)
23:29 Attilla [The.Attilla@FBC920.642D35.9A3E39.B3DA70] has quit [Ping timeout: 121 seconds]
23:29 Attilla [The.Attilla@FBC920.642D35.9A3E39.B3DA70] has joined #code
23:29 mode/#code [+o Attilla] by Reiver
23:32 * Derakon[work] tracks down the use of a member field to some external module, runs into "vs.viewer.m_moreGlLists_enabled[vs._gfx2_last] = 0"
23:32
< Derakon[work]>
I think it's time to take a break for a bit.
23:34 AbuDhabi [annodomini@Nightstar-360d7405.adsl.tpnet.pl] has quit [[NS] Quit: We are tired, we cannot touch ground!]
23:43 Vornicus [vorn@ServerAdministrator.Nightstar.Net] has quit [[NS] Quit: Leaving]
23:45 Vornicus [vorn@ServerAdministrator.Nightstar.Net] has joined #code
23:45 mode/#code [+o Vornicus] by Reiver
23:45 You're now known as TheWatcher[T-2]
23:50 You're now known as TheWatcher[zZzZ]
--- Log closed Tue Dec 08 00:00:19 2009
code logs -> 2009 -> Mon, 07 Dec 2009< code.20091206.log - code.20091208.log >