Home » Web Development » Page 5

I am making a game, and whenever I'm going to press the new game
button, my canvas doesn't update, but my LinkedStack values have
already been updated. It's supposedly have shuffled the LinkedStack
values.



[EDIT]



-added a few parts in my code, and the main problem in my code is
that whenever I press new game, the nodes show the correct new value,
but whenever it is passed to paint(g) (or repaint()), the nodes still
houses the first values.



This is a part of my canvas code. (This class extends Canvas)



public class Solitaire extends Canvas{
public Solitaire(){
setSize(width, height);
//initializes specific LinkedStacks
//creates "cards"
}
public void paint(Graphics g){
Graphics2D g2d = (Graphics2D) g;
g.setColor(Color.WHITE);
g.clearRect(0, 0, width, height);
g.setColor(Color.BLACK);
paintSolitaire(g2d);
}
public void paintSolitaire(Graphics2D g2d){
int i=0;
int move=0;
LinkedStack temp=null;

ypos=0;
xpos=30;
while(i!=7){
ypos=220;
move=30;
temp=new LinkedStack();
while(tableau[i].peek()!=null){
temp.push(tableau[i].pop());
}

if(temp.peek()==null){
g2d.drawRect(xpos, ypos, 70, 95);
}
else{
tableauNode=temp.checkTop();
while(tableauNode!=null){
Card card=(Card)tableauNode.data;
if(card.getFaceUp()==true){
ypos=ypos+move;

g2d.drawImage(getImage("Deck/"+card.getImage()+".png"), xpos, ypos,
70, 95, null);
}
else if(card.getFaceUp()==false){
ypos=ypos+move;
g2d.drawImage(getImage("Deck/155.png"), xpos,
ypos, 70, 95, null);
}
else{
break;
}
tableauNode=tableauNode.link;
}
}
while(temp.peek()!=null){
tableau[i].push(temp.pop());
}
temp=null;
tableauNode=null;
i++;
xpos=xpos+100;
}
g2d.setFont(new Font("Dialog", Font.PLAIN, 30));
g2d.drawString(occurence, 800, 125);
}
public void update(){
repaint();
}
public void deal(){
//deals "cards" into specific LinkedStack
}
public void shuffle(){
//shuffles LinkedList nodes
}


This is part of my main class that implements JFrame. This block of
code executes once I press "New Game".



public class Main extends JFrame implements ActionListener{
private Solitaire solitaire;
private JPanel panel;
public Main(){
panel=new JPanel();
panel.setLayout(new BorderLayout());
panel.add(this.createMenuBar(), BorderLayout.NORTH);

solitaire=new Solitaire();

solitaire.shuffle();
solitaire.deal();
panel.add(solitaire, BorderLayout.CENTER);
add(panel);
pack();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
setResizable(false);
}
private JMenuBar createMenuBar(){
JMenuBar menuBar;
JMenu menu;
JMenuItem newGame;
menu=new JMenu("Menu");
menuBar.add(menu);
newGame=new JMenuItem("New Game");
newGame.addActionListener(this);
menu.add(newGame);
return menuBar;
public void actionPerformed(ActionEvent e){
String command=e.getActionCommand();
switch (command){
case "New Game":
solitaire=new Solitaire();
solitaire.shuffle();
solitaire.deal();
solitaire.update();
break;
}
}
public static void main (String[] args){
Main main=new Main();
}
}

I'm trying to add/push a javascript object (let's call this
'session') to this.state.sessions.



I've tried this two ways:
1. Concat'ing the new session



this.setState({sessions:
this.state.sessions.concat(session)});



  1. Using React's immutability helpers



    var newState = React.addons.update(this.state, {
    sessions : {
    $push : [session]
    }
    });
    this.setState(newState);




While the shallow data (e.g. sessions[i].location) is added
correctly, the problem is that all prior session's scope is now set to
the new session.scope. In the picture link below you can see that the
first session's scope values (sessions[0].scope) were overwritten by
the second session's scope values (sessions href="http://i.stack.imgur.com/Av72I.png" rel="nofollow">1.scope).
How do I ensure that when I add a new session, prior session's values
aren't affected?



App
state picture



I have a model with a CharField with choices. I want to
aggregate the model and get a list of all of the choices and the
number of models in each choice. So if i have:



model1: a
model2: b
model3: c
model4: a
model5: c
model6: c


I want to build a django query set to get the following result (in
json if i can)



{a: 2, b: 1, c: 3}


Is this even possible with the django orm or do i need to run a
pure sql query?

Thanks.

I have small C++ program where main process is "creating data" and
sends them to the child (fork) process which should read that data. My
problem is that in school my code works well, but on my own laptop
both processes get stuck right after the program start. Specifically
both of them are in Waiting Channel "do_msgrcv".



Here is link to my code on pastebin (I'm posting whole code, so
that's the reason for pastebin): href="http://pastebin.com/f1zrzbS9" rel="nofollow">Link



If it helps in school we have Ubuntu 12.04 and I'm using Ubuntu
16.04.



Thanks for any help.

Most of the cases we use (as beginner) OpenFileDialog to open File
explorer and we choose files...



But I want, if we right click on the file and choose "open with"
option and choose the WPF app, then how it can be read?!!

I'm beggining in XML and XSLT and I have a problem with adding a
new line beetwen elements



Here's XML:



<?xml version="1.0" encoding="UTF-8"?>
<numbers>
<person id="1">
<phone>
<phone_nr>111111111</phone_nr>
<phone_nr>222222222</phone_nr>
</phone>
</person>
<person id="2">
<phone>
<phone_nr>333333333</phone_nr>
</phone>
</person>
</numbers>


XSLT looks like:



<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="numbers/person">
<table border="1">
<tr>
<td>
<table>
<td><xsl:value-of select="phone"/></td>
</table>
</td>
</tr>
</table>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


and it gives me this (with borders) :



111111111 222222222
333333333


but what I want is:



111111111
222222222
333333333


The problem is that XML must be like this and I don't know, how to
creating a new line in XSLT.

I have an exe created with an old Borland C++ compiler. It needs
administrator privileges to function correctly. Since the app will
run at startup, I do not want the user prompted if it's OK to run the
program (testing on Win7). My question is is there ANY way to remove
that annoying prompt every time the app is run?



I added a manifest file with admin privs and signed it, but it then
still appears with the publisher name.



This will be distributed, so I don't want users to have to turn off
UAC or do anything too complicated. Any suggestions are much
appreciated.



I am hoping there's something for UAC like "Always Trust This
Program" or something.

so i'm using a costume dialog that ive created in a separate xml
file in my project, and i'm coloring the main window a blueish tint,
but the main header still remains the default white color,



there is no way to change the font color, size, background for the
header ?



is the only thing i can change in the header is just the text ?



this is the dialog >



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:background="#3edfbc"
android:orientation="vertical">


<TextView
android:id="@+id/textaligmentManager_loader_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:text="Initlizing Wifi"
android:textAppearance="?android:attr/textAppearanceLarge"
/>

<com.github.ybq.android.spinkit.SpinKitView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/barcodeScanning_spinkit"
style="@style/SpinKitView.Large.FoldingCube"
android:layout_width="80dp"
android:layout_height="80dp"

android:layout_below="@+id/textaligmentManager_loader_textview"
android:padding="20dp"
android:layout_centerHorizontal="true"
app:SpinKit_Color="#ffffff" />


</RelativeLayout>


and this is how i call it >



 Dialog dialog = new
Dialog(Scanning_Barcode_Activity.this);

dialog.setContentView(R.layout.aligment_manager_loader_layout);
dialog.setTitle("Loading");
dialog.setCancelable(false);

//set up text
loaderScreenMainText = (TextView)
dialog.findViewById(R.id.textaligmentManager_loader_textview);
loaderScreenMainText.setText("Loading Wifi");


//progressBar = (ProgressBar)
dialog.findViewById(R.id.barcodeScanning_spinkit);
//DoubleBounce doubleBounce = new DoubleBounce();
//progressBar.setIndeterminateDrawable(doubleBounce);


//now that the dialog is set up, it's time to show it
dialog.show();

I've got a span which I need to keep as restrict to a single
horizontal line which will not wrap inside it's parent div. The extra
bit of text which goes beyond the length of its parent will be
hidden.



<div id="parent">
<span id="child">ABCD ABCD ABCD ABCD ABCD ABCD ABCD
ABCD</span>
</div>

#parent{
width: 75px;
white-space: nowrap;
overflow: hidden;
}


I tried overflow:hidden and
white-space:nowrap but did not work.

I've got a full screen slide down navigation menu with links which
when clicked scroll to the relevant section . The menu is slide
toggled by clicking on the #hamburger div . what i want is for the
menu to slide out of view again when i click on a link but what
happens is it slides up and then back down again



<div id="hamburger">
<nav id="navigation">
<ul>
<li><a></a></li>
<li><a></a></li>
<li><a></a></li>
</ul>
</nav>
</div>

<script>
$(document).ready(function(){
$("#hamburger , ul li a").click(function(){
$("#navigation").slideToggle("slow");
});
});
</script>

- Technology - Languages
+ Webmasters
+ Development
+ Development Tools
+ Internet
+ Mobile Programming
+ Linux
+ Unix
+ Apple
+ Ubuntu
+ Mobile & Tablets
+ Databases
+ Android
+ Network & Servers
+ Operating Systems
+ Coding
+ Design Software
+ Web Development
+ Game Development
+ Access
+ Excel
+ Web Design
+ Web Hosting
+ Web Site Reviews
+ Domain Name
+ Information Security
+ Software
+ Computers
+ Electronics
+ Hardware
+ Windows
+ PHP
+ ASP/ASP.Net
+ C/C++/C#
+ VB/VB.Net
+ JAVA
+ Javascript
+ Programming
Privacy Policy - Copyrights Notice - Feedback - Report Violation 2018 © BigHow