« first day (1420 days earlier)      last day (3507 days later) » 

12:10 AM
Boo!
 
 
5 hours later…
Adi
4:59 AM
hii @ItachiUchiha
 
heya
 
Adi
Can u please tell me why we get this error : " The selection is not within valid module"
in eclipse
while running a project
 
when are you getting this ?
Have you tried deleting and re-installing the server
 
Adi
yes i did
@ItachiUchiha
hii @Kerppag
please help to solve my issue
 
5:17 AM
You need to add some information, as to what type of project is it, what AS are you using
 
Adi
5:46 AM
ok i M trying
 
hello every one..good morning
@itachiUchiha blog.timmattison.com/archives/2009/11/12/… follow this link you will get solution perfectly...
 
@JanakDhanani you have tagged the wrong person
 
ohk but you will get currect ans mean while on
 
6:07 AM
PCRE library in Java?
 
@unihedron explain you problem bro
@Unihedron Have you tried java.util.regex?
 
Need to run expressions in Java. Googled my eyes out but still can't find one.
Java util.regex.Pattern can only run Java regexp syntax, I need pcre @Jan
If no pcre lib for java already I will make one myself.
I thoroughly read Mastering Regular Expressions so I am sufficiently awake when I decided I need pcre instead of Java pattern, thanks for pointing it out regardless. :)
 
6:57 AM
anyone know about the zk framework here?
 
 
2 hours later…
9:10 AM
hi all
:O
 
 
1 hour later…
10:18 AM
hiya @Sabಠ_ಠ
 
 
2 hours later…
11:55 AM
hi
 
hiya
 
@Unihedron helios
 
Hi all
@Unihedron Hallo
Dude I'm freaking out
I have a JFrame with 2 Jpanels
one is a Grid and One is a BorderLayout
So I added both of them to my frame
but now I want my grid to do some functions and I can't get it to work :(
\
any one here? :(
I'm gonna cry :'(
 
@Sabಠ_ಠ post it here or in SO
 
That is rather vague. What do you need to do, and how are you trying to do it?
 
12:11 PM
2 days ago, by Unihedron
user image
 
@Kiheru I made a class with a grid
and extended Jpanel
Now I have another class myFrame which extends JFrame
in myFrame I have 2 JPanels
1 for the grid
one for out of game pawns
now the problem is when I play it's the grid class that's working
so basically myFrame just makes the grid class appear on the frame
myFrame.add(new grid());
so my problem is, in my grid class when I jump a pawn I want to make it appear in the out of game panel
which is located inside the myFrame
obviously I can't do that since myFrame isn't dynamic and just displays the panels
 
so, is the problem passing the event "game piece eaten" to the side panel?
 
So I'm trying to make a class which has a huge JPanel, put the grid and the outofgame panels in the same class and then it will work
Yep @kiheru exact
I could use a getter and setter but then the problem is it won't be dynamic
 
Ok. I'll describe the approach I'd use. That takes a bit space, so be patient.
 
okay :)
write it and i'll be back in 5minutes internet is so low in the library I'll get back to my dorm
brb 5 mints :)
ty in advance
 
12:16 PM
First, I'd define an interface for game events:

interface GameEventListener {
    void pieceEaten(GamePiece game);
    // add any other event you want to use
}
then, for the main game panel, declare a method for adding listeners:

private final List<GameEventListener> listeners = new ArrayList<GameEventListener>();

public void addGameEventListener(GameEventListener listener) {
    listeners.add(listener);
}
And a method to call, when a piece is eaten:

private void firePieceEaten(GamePiece piece) {
    for (GameEventListener listeners : listeners) {
        listener.pieceEaten(piece);
    }
}
Then, make the side panel implement GamePieceListener, and in the code where you create the main game panel, and the side panel, add the side panel as an event listener: mainPanel.addGameEventListener(sidePanel).
The advantage of the approach is that it keeps the panel implementations separate, so that they do not need to know anything about each others' implementations. You can also have more than one event listener for the game - say, if you want to play sounds on game events, you could implement another listener that plays sounds on those events, and add that to the listeners list.
(This is called the Observer Pattern; it's used quite extensively in swing as you may have noticed. There are a ton of add*Listener() methods in swing.)
 
Back
@kiheru I dunno how to make interfaces yet :/
 
I used GamePiece as a placeholder for something that describes the piece that was eaten. Replace with whatever is appropriate for your game
 
I tried to learn it it's kind of abstract
Wait lemme show you my grid which is the actual game
 
The interface definition I gave would compile just fine, except for the GamePiece part, which I said is a place holder
 
it's not commented yet but it's kind of self-commenting
and is there a way w/o using interfaces?
 
12:31 PM
@Sabಠ_ಠ Why not?
 
I don't know how to make and use interfaces yet
 
A good day to learn?
They're very useful
 
I know but it's the deadline today
I really wanted to learn interface last night but after sleeping 2 hours/day for the past 4 day I crashed
I put my heart into making that game and if that out of game worked it would have been flawless :(
 
You actually already implement an interface in your code. (the anonymous ActionListener you have)
 
ohh
i thought it was an anonymous class
so that code is the grid
now I have another class where I make the layout
and all i do is in that layout class is
JPanel x = new JPanel();
BoardGrid y = new BoardGrid();
 
12:35 PM
basically, to implement an interface for the side panel you just need to add:
`SidePanel extends JPanel implements GameEventListener`
the `implements` part there ^
 
x.add(y)
so when I play the game I fire up the GameEventListener and update the sidepanel
 
and add a
`public void pieceEaten(GamePiece piece)`
method
 
it's just like when I fire a button
example button.addActionListener(new Events())
where Events contains my methods
 
Similarly. The actionListener is an anonymous class, that implements the interface ActionListener
 
yep
but what's the format of an interface?
i know it starts
 
12:38 PM
implementing your own interfaces works the same way
 
interface Listerner{
but then I'm not sure what happens next
 
interface Name {
  // protected final String NAME = "Interface"; // define constants
  modifiers return-type function-name(signature); // end declaration
}
 
I wrote a working example of an interface in the longish description of the approach
 
Checking it now
 
Should had checked it the moment he posted it.
 
12:40 PM
Juste replace GamePiece with something that describes a piece in your design
 
if I manage to make that in 1 hour it's gonna be epicc
lemme backup what I already did and start
here's my game
the grid works flawlessly except for forcing a jump
but that doesn't matter since I can have my own game rules
but the sidebar is just a fixed image for now
public interface GameEventListener {

}
@kiheru I'm very confused :S
 
you'll need at least one method there to call for the interface to be useful for a listener
I used void pieceEaten(GamePiece game);
 
then I makethe method like I would make it in a class?
 
but as I said, replace GamePiece with something that identifies a piece in your design
 
it's just an imageicon
 
12:49 PM
In the side panel you'll want to implement the interface. For that you'll need the implements declaration, and the class needs to have the pieceEaten() method. Just like an ActionListener needs an actionPerformed() method
 
BoardGrid - Makes the Grid
GamePanel - makes the frame and the Layout; adds the BoardGrid, and makes the sidepanel(do I need a class for my side panel here since I just make it right in here)
Okay so I need a class for sidepanel and just add it in GamePanel
 
Well, you could also have an anonymous GameEventListener, which calls whatever method that updates the side panel
 
But the problem is when I add my sidepanel on my GamePanel at the beginning, will it get updated with the interface?
gimme a sc
sec*
pastebin.com/1kWUgYn8 // this is the panel that adds the grid and sidebar
//Display Out of game icons
                JPanel outOfGame = new JPanel();
                outOfGame.setPreferredSize(new Dimension(270,530));
                //outOfGame.setBackground(Color.RED);
                northPanel.add(outOfGame,BorderLayout.EAST);

                //White
                JPanel whitePane = new JPanel();
                whitePane.setPreferredSize(new Dimension(265,265));
                whitePane.setLayout(new BorderLayout());

                //whitePane.setBackground(Color.BLUE);
specifically this part
 
As in, you could do:
    mainPanel.addGameEventListener(new GameEventListener() {
        @Override
        public void pieceEaten(GamePiece piece) {
            updateSidePanel(piece);
        }
    }
That would avoid the need to learn implementing interfaces in named classes in such short time as you seem to have left.
 
mainPanel is my grid class right?
 
12:54 PM
As that's exactly the same approach as taken for the ActionListener
It's whatever implements the part of the game, where you can tell that a piece was eaten
 
okay
so it's BoardGrid
so where I check that that piece is eaten I just put this
 mainPanel.addGameEventListener(new GameEventListener() {
        @Override
        public void pieceEaten(GamePiece piece) {
            updateSidePanel(piece);
        }
    }
 
When a piece is eaten, you call firePieceEaten() as I defined in the original description
 
it's too complex I'm not getting it lemme read it again from top to bottom
 
that would be probably doJump() in your code
 
I tried it in there
but it says
make mainPanel an object
 mainPanel.addGameEventListener(new GameEventListener() {
        @Override
        public void pieceEaten(GamePiece piece) {
            updateSidePanel(piece);
        }
    }
when I added it
because all the stuff happen in the grid class in itself
 
12:59 PM
you don't have it by name mainPanel. Replace it by what you call the grid thingy
 
I didn't call it
I have a grid class which makes the grid and does all the stuff inside that class
then in my GamePanel(trial as in pastebin) I just add the BoardGrid inside a panel
Now I tried this
 addGameEventListener(new GameEventListener() {
							        @Override
							        public void pieceEaten(GamePiece piece) {
							            updateSidePanel(piece);
							        }
							    };
since it's in the same class
eclipse says The method addGameEventListener(new GameEventListener(){}) is undefined for the type BoardGrid
 
somewhere you must have a new BoardGrid() call. There you can assign it to a variable. use addGameEventListener() of that object
"eclipse says The method addGameEventListener(new GameEventListener(){}) is undefined for the type BoardGrid"
well, did you define the method?
for that too, I wrote a working implementation
 
So in the class where I add the newBoardGrid
BoardGrid board = new BoardGrid();
 
likely
 
JPanel boardSpace = new JPanel();
		boardSpace.setPreferredSize(new Dimension(530,530));
		boardSpace.setLayout(new BorderLayout());
		//boardSpace.setBackground(Color.RED);
		boardSpace.add(board, BorderLayout.CENTER) ;
i added the board in the layout class
in a Jpanel
 
1:03 PM
ok, so it becomes: board.addGameEventListener(new GameEventListener() {...
 
aha
 
BoardGrid still must have that method, obviously
 
so private void addGameEventListener in BoardGrid
 
probably public, if you're calling it outside BoardGrid
 
yep
but gamePane needs to implement the GameEventListener in that case
 
1:06 PM
refer to the implementation I wrote in the beginning. It maintains a list of listeners
 
Is there really no way to check if an Integer equals an int without (un)/boxing?
 
if number == number?
 
Some sort of type conversion must happen in any case. I'd compare to .intValue()
(cheaper than boxing. no allocations needed)
 
Cool will do. Currently it's already auto-unboxing on score == defscore.
 
that's probably equivalent code. would need to take a look at the byte code
is it so performance critical that it actually matters?
 
1:11 PM
Nope, just making a sanity check.
 
Oracle says .intValue() is used for the unboxing
 
Oh, thanks a lot!
Noob question: If ctn in for (def; repeat; ctn) evaluates to false before def or the code blocks runs, will the statement following for not run at all, or run once?
 
Good morning, Java!
 
hmm, I'd think the state after executing def is what matters. That's intuition, not reading JLS
 
Morning!
 
1:14 PM
Hey @Unihedron.
 
Thanks @kiheru, don't worry about it, I'll experiment quickly. :)
 
damn I can't get it @Kiheru
I think I need to calm down
there's 1.5 hours left
 
(Intuition, because the state of ctn is not necessarily defined before executing def, so it would seem weird to check it in the case it is defined)
@Sabಠ_ಠ do you get a particular error now?
 
actually trying to understand it
I made a new class and make my sidepanel in there
then in my main layout I added my sidepanel and my board grid separately to their sopt
Now I'll have to implement the actual listener
nterface GameEventListener {
    void pieceEaten(GamePiece game);
    // add any other event you want to use
}
what is GamePiece in this case?
 
It's something that describes a piece in your design. You could as well have something like void pieceEaten(Side side, PieceType type). So, just a method parameter(s) that are enough for the side panel to tell what kind of piece was eaten
Basically, just think of a method that updates the side panel when a piece is eaten; add the appropriate parameters
 
1:23 PM
So here's what I understood so far:
1. Create an interface
2. In my BoardGrid I need to use my GameEvent like I use an addactionListener
3. When this calls the gameevent listener, the sidebar gets updated since it implements it
So in my BoardGrid, I make a public method to know when the piece is eaten
this is used alongside my game event listener
so when a piece is eaten it fires the GameEventListener
 
on regards to 3, it gets called because it was added as a GameEventListener when you call addGameEventListener() (it needs to implement the interface to be used as a parameter to that method)
The board method firePieceEaten() does not need to be public. You just need to call it when a piece is eaten
 
aha
 
(the move is done in the board, so the fire method can be private)
 
But then How will the sidePanel know it needs to get updated?
Since all I did was make a frame and add both the board and sidepanel to it
 
because firePieceEaten() notifies all added GameEvenListeners. It does that by calling their pieceEaten() methods
 
1:28 PM
so basically when the game runs the two things are just on the board separately
So if sidepanel implements the GameEventListener it will auto update
 
This part:
private void firePieceEaten(GamePiece piece) {
    for (GameEventListener listeners : listeners) {
        listener.pieceEaten(piece);
    }
}
it also needs to be added with addGameEventListener(); that will add it to the listeners list used in the above code snippet
 
side panel needs this as well right?
@Override
	public void pieceEaten(GamePiece BoardGrid) {
		// do something

	}
 
So you need:
1. an interface
2. an implementation of the interface, that updates the side panel when `pieceEaten()` is called
3.a `addGameEventListener()` in BoardGrid
3.b add the interface implementation 2 using the method 3.a
4.a `firePieceEaten()` in BoardGrid
4b call `firePieceEaten()` in BoardGrid, when a piece is eaten
 
Okay. Let me try it now. I think I understand it
 
If you implement the interface in the side panel, it'll need to have the pieceEaten() method. I'd advice against passing the entire BoardGrid as a parameter though. That defeats the whole purpose of keeping the board and the panel separate
 
1:39 PM
Yeah I don't do that actually
In my GamePanel I just have this
    BoardGrid board = new BoardGrid();
   SidePanel pawnsOut = new SidePanel();
 
need to convert int to jobject in JNI
 
@VikasPatidar Integer.valueOf(1);
 
thanks I need in JNI C++
 
C++?

C++

Friendly conversation, including C++ talk — NOT the "Lounge"!
Tomorrow is the international programmers' day!
3
 
The way to create Integer in jni is probably invoking valueOf(int) of Integer
 
1:48 PM
I'm about to give up :(
It's just not right
 
What's wrong now?
 
I have my SidePanel, I Implemented the GameEventListener
Then in my GamePanel I added my eventListener for my SidePanel
 
as in board.addGameEventListener(sidePanel)?
 
yep
 
ok. seems fine this far
 
1:52 PM
The method addGameEventListener(SidePanel) is undefined for the type JPanel
This is what I get
//Display Out of game icons
		northPanel.addGameEventListener(pawnsOut);
		northPanel.add(pawnsOut,BorderLayout.EAST);
 
isn't board a BoardGrid?
 
Nop the Layout Board
ahh
Right
The method addGameEventListener(SidePanel) is undefined for the type BoardGrid
still the same though
of course I need a public method in BoardGrid
 
yup. The one I wrote should work fine
(it needs the listeners list; I wrote that above the addGameEventListener() implementation)
 
what does the list do btw?
 
it just stores all the added GameEventListeners. You only use one, but in principle you could add more (like one that plays sound when a piece is eaten)
 

« first day (1420 days earlier)      last day (3507 days later) »