Daily Archives

Articles indexed Friday December 14 2012

Page 12/17 | < Previous Page | 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • 2d shapes in XNA 4.0?

    - by Lautaro
    Having some experience of XNA but none of 3D programming. I have an idea i want to realize but i have not decided to do it in 3d or 2d. Im not sure which one will be best in XNA. I want to have a shape like a blob that can reshape depending on input. The morphing does not need to be very advanced. It could be a circle (2d) or globe (3d) that just has one point that moves slightly in a random direction. In ASP.NET i have made this through the 2d Draw classes where i can make lines, circles, squares etc and then modify the points that makes them up. But it seems to me that XNA does not have classes for making 2d shapes (can i get this confirmed?). If it had, then this would be the quickest solution for me.

    Read the article

  • Unity3D and Texture2D. GetPixel returns wrong values

    - by Heisenbug
    I'm trying to use Texture2D set and get colors, but I encountered a strange behavior. Here's the code to reproduce it: Texture2D tex = new Texture2D(2,2, TextureFormat.RGBA32 ,false); Color col = new Color(1.0f,0.5f,1.0f,0.5f); //col values: 1.00, 0.500, 1.00, 0.500 tex.setPixel(0,0,col); Color colDebug = tex.getPixel(0,0); //col values: 1.00, 0.502, 1.00, 0.502 The Color retrieved with getPixel is different from the Color set before. I initially thought about float approximation, but when inspectin col the value stored are correct, so can't be that reason. It sounds weird even a sampling error because the getValue returns a value really similar that not seems to be interpolated with anything else. Anyway I tried even to add these lines after building the texture but nothing change: this.tex.filterMode = FilterMode.Point; this.tex.wrapMode = TextureWrapMode.Clamp; this.tex.anisoLevel = 1; What's my mistake? What am I missing? In addition to that. I'm using tex to store Rect coordinates returned from atlas generation, in order to be able of retriving the correct uv coordinate of an atlas inside a shader. Is this a right way to go?

    Read the article

  • What functionality should I use in OpenGL 2.0?

    - by Jeffrey
    Considering OpenGL 2.1, we all know that glBegin and glEnd are the devil. Should I use only VBO to render 3d primitives (I can't find VAO in that version, weren't there already?)? Should I still use the matrix stack (why not?)? Should I still use glFrustum? Can I take advantage of shaders in GLSL 1.20? Where can I find a tutorial for VBO in OpenGL 2.1 and the "correct" way of programming in it? Also how am I supposed to animate something. Like a cube moving around an object or a player moving in the scene (static vbo data + shader?)? Note: Take your time to answer this question, I'll accept an answer tomorrow.

    Read the article

  • Error in destroying object in Box2D/LibGDX

    - by Crypted
    I'm trying to delete an object when a collision happens. I have put the following code in the render method of the object so it would be outside of the physics calculations. public void render(SpriteBatch spriteBatch) { // some other code... body.setActive(false); body.getWorld().destroyBody(body); But I'm getting an run-time error which crashes the JVM and shows, AL lib: alc_cleanup: 1 device not closed Assertion failed! Program: C:\Program Files\Java\jre6\bin\javaw.exe File: /var/lib/hudson/jobs/libgdx-git/workspace/gdx/jni/Box2D/Dynamics/b2World.cpp, Line 133 Expression: m_bodyCount 0 Can anyone help me here?

    Read the article

  • Sprite and Physics components or sub-components?

    - by ashes999
    I'm taking my first dive into creating a very simple entity framework. The key concepts (classes) are: Entity (has 0+ components, can return components by type) SpriteEntity (everything you need to draw on screen, including lighting info) PhysicsEntity (velocity, acceleration, collision detection) I started out with physics notions in my sprite component, and then later removed them to a sub-component. The separation of concerns makes sense; a sprite is enough information to draw anything (X, Y, width, height, lighting, etc.) and physics piggybacks (uses the parent sprite to get X/Y/W/H) while adding physics notions of velocity and collisions. The problem is that I would like collisions to be on an entity level -- meaning "no matter what your representation is (be it sprites, text, or something else), collide against this entity." So I refactored and redirected collision handling from entities to sprite.physics, while mapping and returning the right entity on physics collisions. The problem is that writing code like this.GetComponent<SpriteComponent>().physics is a violation of abstraction. Which made me think (this is the TLDR): should I keep physics as a separate component from sprites, or a sub-component, or something else? How should I share data and separate concerns?

    Read the article

  • Ways to earn money through Flash games

    - by Maged
    If you like developing flash games just for fun, why not make money through them? There are different ways you can monetize your flash game: In Game Ads: Some common examples: Mochi Ads gamejacket ad4game CPMStar InviziAds You can make money by helping online gaming companies test and evaluate new games. Many of those companies are seeking feedback and reviews of their newest games. Find a sponsor and license your game. One of the quickest yet hardest ways to make money from the flash games you create is to find a website who is willing to sponsor them. With a single sponsorship, an individual can make anywhere from $1000-$7000 for a game. What are the best ads from these sites? If the game will be in social websites like Facebook and MySpace, will it still be useful to try other sites? Are there any other ways to earn money from a Flash game?

    Read the article

  • Jsf RichFaces autocomplete : get the String for autocomplete- method()

    - by JavaNullPointer
    Part of my xhmtl-Page: <rich:autocomplete autocompleteMethod="#{autocompletMit.searchbyName()}" mode="cachedAjax" fetchValue="#{controller.mitarbeiter.mitarbeiterName}" autocompleteList="#{autocompletMit.autocompleteList}" minChars="1" autofill="true" var="it" > <h:outputText value="#{it.mitarbeiterName}" style="font-weight:bold"/> </rich:autocomplete> Bean for my Autocomplete: @ManagedBean(name = "autocompletMit") @RequestScoped public class AutoCompleteMitarbeiter implements Serializable { @EJB private Transaktionssteuerung transakt; private List<String> autocompleteList = new ArrayList<String>(); String nameSearch; public List<String> searchbyName(Object o) { String test = (String) o; //always get here a NullPointerException List<Mitarbeiter> alleMitarbeiter = transakt.alleMitarbeiter(); for (Iterator<Mitarbeiter> it = alleMitarbeiter.iterator(); it.hasNext();) { if (it.next().getMitarbeiterName().startsWith(test)) { autocompleteList.add(it.next().getMitarbeiterName()); } } return autocompleteList; } I always get a NullPointerException for String test = (String) o; I dont know how to get the StringInput correctly from </rich:autocomplete>-Input....

    Read the article

  • JQuery code does not work not understanding the markup

    - by Andrae Browne
    I am trying to make a simple animation using JQuery. I have tried adding the script externally(external file) and internally(within script tags). I have testing if the page is recognizing the script using the alert function, but the script is not executing. I am thinking that is has something to do with the syntax. $("#container5").hover(function() { //hover in $(#container5).animate({ height: "250", width: "250", left: "-=50", top: "-=50", }, "fast"); }, function() { //hover out $(#container5).animate({ height: "200", width: "200", left: "+=50", top: "+=50", }, "fast"); } })(jQuery);

    Read the article

  • How do I form a Rails link_to with custom field value as parameter

    - by rwheadon
    I have an invoice form where I'm giving the user opportunity to apply coupons to the invoice total. These coupons are held in another Model and I am going to do a lookup on the Coupon code (something like "20OFFONFRIDAY") which I will use to find what the restrictions and benefits of the coupon. (and to see if it even exists at all) The invoice does not have "coupon_code" on it so I hand forged the field onto my form with html: <% if (@invoice.status == 'new') %> <input id="coupon_code" name="coupon_code" type="text"/> <% end %> and I am calling a controller method with link_to and would like something like the following jquery enhanced link_to to work: <%= link_to "Apply Coupon", { :controller=>"invoices", :id=>@invoice.id, :coupon_code=>$('.coupon_code').val(), :action=>"apply_coupon_code" }, :method=>"post" %> ^formatted for easier reading Then inside my "apply_coupon_code" method I will go off to a couple other models and perform business logic before returning the updated invoice page. ...but maybe it's a pipe dream. I guess if push came to shove I could add the "coupon_code" field to my invoice model (even though it's persisted elsewhere.) so it's part of the entity and thus easily available on my form to send back into a controller, but I just hate adding a column to make a coupon validation easier. I figured I'd ping stackoverflow before taking that path.

    Read the article

  • Checking for duplicates with nested forms

    - by Cyrus
    I'm making a rails 3.2.9 app that allows users to create pages and they can embed youtube videos through a nested form. I'm trying to figure out how to make it so that I can prevent duplicate video records from being stored in my db. So I have a Video model that takes the youtube url and just parses out the video id and stores that instead of the full user submitted youtube url, which may have extraneous url query parameters. So here's the situation that I'm trying to figure out: There's page1 with video1 - url: 123 and video2 - url: abc Then another user creates page2 and submits video3 - url: def and video4 - url: 123 Currently each page has_many videos. But I think I should change it to a many-to-many relationship. But how would I make it so that the url submitted as video4 in the nested form points to video1? Also I how would I make a nested form that creates objects that are connected through a join table?

    Read the article

  • perl negative look behind with groupings

    - by user1539348
    I have a problem trying to get a certain match to work with negative look behind example @list = qw( apple banana cherry); $comb_tlist = join ("|", @tlist); $string1 = "include $(dir)/apple"; $string2 = "#include $(dir)/apple"; if( string1 =~ /^(?<!#).*($comb_tlist)/) #matching regex I tried, works The array holds a set of variables that is matched against the string. I need the regex to match $string1, but not $string2. It matches $string1, but it ALSO matches $string2. Can anyone tell me what I am attempting wrong here. Thanks!

    Read the article

  • Maven exec bash script and save output as property

    - by djechlin
    I'm wondering if there exists a Maven plugin that runs a bash script and saves the results of it into a property. My actual use case is to get the git source version. I found one plugin available online but it didn't look well tested, and it occurred to me that a plugin as simple as the one in the title of this post is all I need. Plugin would look something like: <plugin>maven-run-script-plugin> <phase>process-resources</phase> <!-- not sure where most intelligent --> <configuration> <script>"git rev-parse HEAD"</script> <!-- must run from build directory --> <targetProperty>"properties.gitVersion"</targetProperty> </configuration> </plugin> Of course necessary to make sure this happens before the property will be needed, and in my case I want to use this property to process a source file.

    Read the article

  • Boost Regex unknown number of var

    - by Katrin Thielmann
    I got a Problem with a regex expression and need help. I have some expressions like these in mein .txt File: 19 = NAND (1, 19) regex expression : http://rubular.com/r/U8rO09bvTO With this regex expression i got seperated matches for the numbers. But now I need a regex expression with a unknown size of numbers in the bracket . For example: 19 = NAND (1, 23, 13, 24) match1: 19 match2: 1 match3: 23 match4: 13 match5: 24 I don't know the number of the numbers. So i need a main expression for min 2 numbers in the bracket till a unknow number. I hope somebody can help me.

    Read the article

  • Select all text in an <input /> when it gains focus

    - by Chris Barr
    I've got a textbox (set to readonly) and I need its' contents to be selected for easy copy/paste when it gains focus. Using the code below it only seems to quickly select the text and then unselect it for some reason. HTML <input id='thing' type='text' value='some text' readonly='readonly' />? JavaScript document.getElementById('thing').onfocus = function(){ this.select(); };? Fiddle: http://jsfiddle.net/cfqje/

    Read the article

  • How to avoid the linebreak inside a word (Static Layout

    - by Addev
    I'm trying to make a text as big as I can making it fit a Rect. basically I use a StaticLayout for pre-calculate the text size and make it fit the Rect's height: // Since the width is fixed for the StaticLayout it should only fit the height while (currentHeight>Rect.getHeight()){ size-=2; } textPaint.setTextSize(size); The problem is that if the Rect is very high, the exit condition is reached but breaking the words (see the capture). Is there a way for avoid this? Goal: Actual: Current code: textSize=MAX_TEXT_SIZE do { if (textSize < mMinTextSize) { Log.i(TAG, "Min reached"); textSize = mMinTextSize; textPaint.setTextSize(textSize); fits = true; } else { textPaint.setTextSize(textSize); StaticLayout layout = new StaticLayout(text, textPaint, targetWidth, Alignment.ALIGN_NORMAL, 1.0, 0, true); layout.draw(canvas); float heightRatio= (float) layout.getHeight() / (float) targetHeight; boolean fitsHeight = heightRatio<= 1f; if (fitsHeight) { fits = true; } else { textSize -= 2; } } Log.i(TAG, "textSize=" + textSize + " fits=" + fits); } while (!fits); thanks

    Read the article

  • Writing a factory for classes that have required arguments

    - by Kyle Adams
    I understand the concept of factory pattern such that you give it something it spits out something of the same template back so if I gave a factory class apple, I expect to get many apples back with out having to instantiate a new apple ever time. what if that apple has a required argument of seed, or multiple required arguments of seed, step and leaf? how do you use factory pattern here? that is how do I use factory pattern to instantiate this: $apple = new Apple($seed, $stem, $leaf);

    Read the article

  • Invalid Cast Exception with Update Panel

    - by user1593175
    On Button Click Protected Sub btnSubmit_Click(sender As Object, e As System.EventArgs) Handles btnSubmit.Click MsgBox("INSIDE") If SocialAuthUser.IsLoggedIn Then Dim accountId As Integer = BLL.getAccIDFromSocialAuthSession Dim AlbumID As Integer = BLL.createAndReturnNewAlbumId(txtStoryTitle.Text.Trim, "") Dim URL As String = BLL.getAlbumPicUrl(txtStoryTitle.Text.Trim) Dim dt As New DataTable dt.Columns.Add("PictureID") dt.Columns.Add("AccountID") dt.Columns.Add("AlbumID") dt.Columns.Add("URL") dt.Columns.Add("Thumbnail") dt.Columns.Add("Description") dt.Columns.Add("AlbumCover") dt.Columns.Add("Tags") dt.Columns.Add("Votes") dt.Columns.Add("Abused") dt.Columns.Add("isActive") Dim Row As DataRow Dim uniqueFileName As String = "" If Session("ID") Is Nothing Then lblMessage.Text = "You don't seem to have uploaded any pictures." Exit Sub Else **Dim FileCount As Integer = Request.Form(Request.Form.Count - 2)** Dim FileName, TargetName As String Try Dim Path As String = Server.MapPath(BLL.getAlbumPicUrl(txtStoryTitle.Text.Trim)) If Not IO.Directory.Exists(Path) Then IO.Directory.CreateDirectory(Path) End If Dim StartIndex As Integer Dim PicCount As Integer For i As Integer = 0 To Request.Form.Count - 1 If Request.Form(i).ToLower.Contains("jpg") Or Request.Form(i).ToLower.Contains("gif") Or Request.Form(i).ToLower.Contains("png") Then StartIndex = i + 1 Exit For End If Next For i As Integer = StartIndex To Request.Form.Count - 4 Step 3 FileName = Request.Form(i) '## If part here is not kaam ka..but still using it for worst case scenario If IO.File.Exists(Path & FileName) Then TargetName = Path & FileName 'MsgBox(TargetName & "--- 1") Dim j As Integer = 1 While IO.File.Exists(TargetName) TargetName = Path & IO.Path.GetFileNameWithoutExtension(FileName) & "(" & j & ")" & IO.Path.GetExtension(FileName) j += 1 End While Else uniqueFileName = Guid.NewGuid.ToString & "__" & FileName TargetName = Path & uniqueFileName End If IO.File.Move(Server.MapPath("~/TempUploads/" & Session("ID") & "/" & FileName), TargetName) PicCount += 1 Row = dt.NewRow() Row(1) = accountId Row(2) = AlbumID Row(3) = URL & uniqueFileName Row(4) = "" Row(5) = "No Desc" Row(6) = "False" Row(7) = "" Row(8) = "0" Row(9) = "0" Row(10) = "True" dt.Rows.Add(Row) Next If BLL.insertImagesIntoAlbum(dt) Then lblMessage.Text = PicCount & IIf(PicCount = 1, " Picture", " Pictures") & " Saved!" lblMessage.ForeColor = Drawing.Color.Black Dim db As SqlDatabase = Connection.connection Using cmd As DbCommand = db.GetSqlStringCommand("SELECT PictureID,URL FROM AlbumPictures WHERE AlbumID=@AlbumID AND AccountID=@AccountID") db.AddInParameter(cmd, "AlbumID", Data.DbType.Int32, AlbumID) db.AddInParameter(cmd, "AccountID", Data.DbType.Int32, accountId) Using ds As DataSet = db.ExecuteDataSet(cmd) If ds.Tables(0).Rows.Count > 0 Then ListView1.DataSource = ds.Tables(0) ListView1.DataBind() Else lblMessage.Text = "No Such Album Exists." End If End Using End Using 'WebNavigator.GoToResponseRedirect(WebNavigator.URLFor.ReturnUrl("~/Memories/SortImages.aspx?id=" & AlbumID)) Else 'TODO:we'll show some error msg End If Catch ex As Exception MsgBox(ex.Message) lblMessage.Text = "Oo Poop!!" End Try End If Else WebNavigator.GoToResponseRedirect(WebNavigator.URLFor.LoginWithReturnUrl("~/Memories/CreateAlbum.aspx")) Exit Sub End If End Sub The above code works fine.I have added an Update Panel in the page to avoid post back, But when i add the button click as a trigger <Triggers> <asp:AsyncPostBackTrigger ControlID="btnSubmit" /> </Triggers> in the update panel to avoid post back, i get the following error.This happens when i add the button click as a Trigger to the update panel.

    Read the article

  • Converting contents of a byte array to wchar_t*

    - by Christopher MacKinnon
    I seem to be having an issue converting a byte array (containing the text from a word document) to a LPTSTR (wchar_t *) object. Every time the code executes, I am getting a bunch of unwanted Unicode characters returned. I figure it is because I am not making the proper calls somewhere, or not using the variables properly, but not quite sure how to approach this. Hopefully someone here can guide me in the right direction. The first thing that happens in we call into C# code to open up Microsoft Word and convert the text in the document into a byte array. byte document __gc[]; document = word->ConvertToArray(filename); The contents of document are as follows: {84, 101, 115, 116, 32, 68, 111, 99, 117, 109, 101, 110, 116, 13, 10} Which ends up being the following string: "Test Document". Our next step is to allocate the memory to store the byte array into a LPTSTR variable, byte __pin * value; value = &document[0]; LPTSTR image; image = (LPTSTR)malloc( document->Length + 1 ); Once we execute the line where we start allocating the memory, our image variable gets filled with a bunch of unwanted Unicode characters: ????????????????? And then we do a memcpy to transfer over all of the data memcpy(image,value,document->Length); Which just causes more unwanted Unicode characters to appear: ????????????????? I figure the issue that we are having is either related to how we are storing the values in the byte array, or possibly when we are copying the data from the byte array to the LPTSTR variable. Any help with explaining what I'm doing wrong, or anything to point me in the right direction will be greatly appreciated.

    Read the article

  • ArrayList access

    - by Ricky McQuesten
    So once again I have a question about this program. I want to store transactions that are made in an arraylist and then have an option in the case menu where I can print out those that are stored. I have been researching online and have been unable to find a solution to this, so is this possible and how would I go about doing this? I also want to attach a timestamp to each transaction as well. Here is the code I have so far. So my question is how would I add a timestamp to each withdrawal or deposit, and how would I store each transaction in array list? import java.util.*; public class BankAccount extends Money { //inheritence static String name; public static int acctNum; public static double balance, amount; BankAccount(String name, int accNo, double bal) { this.name = name; this.acctNum = accNo; this.balance = bal; } void display() { System.out.println("Your Name:" + name); System.out.println("Your Account Number:" + acctNum); System.out.println("Your Current Account Balance:" + Money.getBalance()); } void displayBalance() { System.out.println("Balance:" + balance); } } import java.util.Scanner; /** * * @author Ricky */ public class Money { public static int accountNumber; public static double balance; static double amount; static String name; public void setDeposit(double amount) { balance = balance + amount; if (amount < 0) { System.out.println("Invalid"); } } public double getDeposit() { return 1; } public void setBalance(double b) { balance = b; } public static double getBalance() { return balance; } public void setWithdraw(double amount) { if (balance < amount) { System.out.println("Not enough funds."); } else if(amount < 0) { System.out.println("Invalid"); } else { balance = balance - amount; } } public double getWithdraw() { return 1; } } import java.util.*; public class Client { public static void main(String args[]) { int n = 0; int count; String trans; ArrayList<String> transaction= new ArrayList<String>(n); Scanner input = new Scanner(System.in); System.out.println("Welcome to First National Bank"); System.out.println("Please enter your name: "); String cusName = input.nextLine(); System.out.println("You will now be assigned an account number."); Random randomGenerator = new Random(); int accNo = randomGenerator.nextInt(100000); //random number System.out.println("Your account number is: " + accNo); System.out.println("Please enter your initial account balance: "); Double balance = input.nextDouble(); BankAccount b1 = new BankAccount(cusName, accNo, balance); b1.setBalance(balance); int menu; /*System.out.println("Menu"); System.out.println("1. Deposit Amount"); System.out.println("2. Withdraw Amount"); System.out.println("3. Display Information"); System.out.println("4. Exit");*/ boolean quit = false; do { System.out.println("*******Menu*******"); System.out.println("1. Deposit Amount"); // menu to take input from user System.out.println("2. Withdraw Amount"); System.out.println("3. Display Information"); System.out.println("4. Exit"); System.out.print("Please enter your choice: "); menu = input.nextInt(); switch (menu) { case 1: System.out.print("Enter depost amount:"); b1.setDeposit(input.nextDouble()); b1.getDeposit(); transaction.add(trans); break; case 2: System.out.println("Current Account Balance=" + b1.getBalance()); System.out.print("Enter withdrawal amount:"); b1.setWithdraw(input.nextDouble()); b1.getWithdraw(); transaction.add(trans); break; // switch statments to do a loop case 3: b1.display(); break; case 4: quit = true; break; } } while (!quit); } } public class Date { static Date time = new Date(); }

    Read the article

  • ISO C90 forbids mixed declarations and code sscanf

    - by Need4Sleep
    I'm getting a strange error attempting to compile my unit test code,. For some reason the compiler treats my sscanf call as a mixed declaration? I don't quite understand, here is the entire error: cc1: warnings being treated as errors /home/brlcad/brlcad/src/libbn/tests/bn_complex.c: In function 'main': /home/brlcad/brlcad/src/libbn/tests/bn_complex.c:53: error: ISO C90 forbids mixed declarations and code make[2]: *** [src/libbn/tests/CMakeFiles/tester_bn_complex.dir/bn_complex.c.o] Error 1 make[1]: *** [src/libbn/tests/CMakeFiles/tester_bn_complex.dir/all] Error 2 make: *** [all] Error 2 int main(int argc, char *argv[]) { double expRe1, expIm2, expSqRe1, expSqIm2; double actRe1, actIm2, actSqRe1, actSqIm2; actRe1 = actIm2 = actSqRe1 = actSqIm2 = expRe1 = expIm2 = expSqRe1 = expSqIm2 = 0.0; bn_complex_t com1,com2; //a struct that holds two doubles if(argc < 5) bu_exit(1, "ERROR: Invalid parameters[%s]\n", argv[0]); sscanf(argv[1], "%lf,%lf", &com1.re, &com1.im); /* Error is HERE */ sscanf(argv[2], "%lf,%lf", &com2.re, &com2.im); sscanf(argv[3], "%lf,%lf", &expRe1, &expIm2); sscanf(argv[4], "%lf,%lf", &expSqRe1, &expSqIm2); test_div(com1, com2, &actRe1, &actIm2); test_sqrt(com1,com2, &actSqRe1, &actSqIm2); if((fabs(actRe1 - expRe1) < 0.00001) || (fabs(actIm2 - expIm2) < 0.00001)){ printf("Division failed...\n"); return 1; } if((fabs(actSqRe1 - expSqRe1) < 0.00001) || (fabs(actSqIm2 - expSqIm2) < 0.00001)){ printf("Square roots failed...\n"); return 1; } return 0; }

    Read the article

  • Better way of enforcing this template?

    - by Dennis Ritchie
    Currently, I have a function template like this that converts a vector into a string (just a natural string, separating the elements with a comma): //the type T must be passable into std::to_string template<typename T> std::string vec_to_str(const std::vector<T> &vec); As you can see, this is only meant for vectors whose elements can be passed into the built-in std::to_string function (such as int, double, etc.) Is it considered a good practice to document with comments the allowed T? If not, what should I do? Is it possible to enforce this in a better way?

    Read the article

  • send blank SMS with SmsManager.sendTextMessage method in android

    - by Dany Wehbe
    I created an android app and one of its functions is to send SMS, when I try to send blank SMS it throws an exception. Here is the code: SmsManager sm=SmsManager.getDefault(); sm.sendTextMessage("9999", null, messageBody,sentPI, deliveredPI); messageBody maybe empty string and maybe it is a string, previous method throws IllegalArgumentException when messageBody is empty string! what can I do to send blank SMS?

    Read the article

  • More than one JPanel in a Frame / having a brackground Image and another Layer with Components on the top

    - by user1905203
    I've got a JFrame with a JPanel in which there is a JLabel with an ImageIcon(). Everything's working perfectly, problem is i now want to add another JPanel with all the other stuff like buttons and so on to the JFrame. But it still shows the background Image on top and nothing with the second JPanel. Can someone help me? Here is an extract of my code: JFrame window = new JFrame("Http Download"); /* * Background Section */ JPanel panel1 = new JPanel(); JLabel lbl1 = new JLabel(); /* * Component Section */ JPanel panel2 = new JPanel(); JLabel lbl2 = new JLabel(); /* * Dimension Section */ Dimension windowSize = new Dimension(800, 600); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); public HTTPDownloadGUI() { window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); panel1.setLayout(null); panel1.setSize(windowSize); panel1.setOpaque(false); panel2.setLayout(null); panel2.setSize(windowSize); panel2.setOpaque(false); lbl1.setSize(windowSize); lbl1.setLocation(0, 0); lbl1.setIcon(new ImageIcon(getClass().getResource("bg1.png"))); panel1.add(lbl1); lbl2.setBounds(0, 0, 100, 100); //lbl2.setIcon(new ImageIcon(getClass().getResource("bg2.png"))); lbl2.setBackground(Color.GREEN); panel2.add(lbl2); panel1.add(panel2); window.add(panel1); int X = (screen.width / 2) - (windowSize.width / 2); int Y = (screen.height / 2) - (windowSize.height / 2); window.setBounds(X,Y , windowSize.width, windowSize.height); window.setVisible(true); }

    Read the article

  • Building a calendar navigation in Rails (controller and view links)

    - by user532339
    Trying to get the next month when clicking the link_to. I've done the following in the view. <%= form_tag rota_days_path, :method => 'get' do %> <p> <%= hidden_field_tag(:next_month, @t1) %> <%= link_to 'Next Month', rota_days_path(:next_month => @next_month)%> </p> <% end %> class RotaDaysController < ApplicationController # GET /rota_days # GET /rota_days.json # load_and_authorize_resource respond_to :json, :html def index @rota_days = RotaDay.all @hospitals = Hospital.all @t1 = Date.today.at_beginning_of_month @t2 = Date.today.end_of_month @dates = (@t1..@t2) #Concat variable t1 + t2 together # @next_month = Date.today + 1.month(params[: ??? ] #Old if params[:next_month] # @next_month = Date.today >> 1 @next_month = params[:next_month] + 1.month @t1 = @next_month.at_beginning_of_month @t2 = @next_month.end_of_month @dates = (@t1..@t2) end @title = "Rota" respond_to do |format| format.html # index.html.erb format.json { render json: @rota_days } end end I have identified that the reason why this may not be working is in because of the following in my controller @next_month = params[:next_month] + 1.month the last two called methods is defined only on time/date objects. but not on fixnum/string objects. I understand I am missing something from this Update I have found that the actual issue is that the `params[:next_month] is a string and I am trying to add a date to to it. Which means I need to convert the string to a date/time object. Console output: Started GET "/rota_days" for 127.0.0.1 at 2012-12-14 22:14:36 +0000 Processing by RotaDaysController#index as HTML User Load (0.0ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1 RotaDay Load (0.0ms) SELECT `rota_days`.* FROM `rota_days` Hospital Load (1.0ms) SELECT `hospitals`.* FROM `hospitals` Rendered rota_days/index.html.erb within layouts/application (23.0ms) Role Load (0.0ms) SELECT `roles`.* FROM `roles` INNER JOIN `roles_users` ON `roles`.`id` = `roles_users`.`role_id` WHERE `roles_users`.`user_id` = 1 AND `roles`.`name` = 'Administrator' LIMIT 1 Completed 200 OK in 42ms (Views: 39.0ms | ActiveRecord: 1.0ms)

    Read the article

  • Excel: Automating the Selection of an Unknown Number of Cells

    - by user1905080
    I’m trying to automate the formatting of an excel file by a macro and am seeking a solution. I have two columns titled Last Name and First Name which I would like to concatenate into a separate column titled Last Name, First Name. This is simple enough when done by hand: create one cell which does this, then drag that cell to include all cells within the range. The problem appears when trying to automate this. Because I can’t know the number of names that need to be concatenated ahead of time, I can’t automate the selection of cells by dragging. Can you help me automate this? I’ve tried a process of copying the initial concatenated cell, highlighting the column, and then pasting. I’ve also tried to use a formula which returned the concatenation only if there is text in the “Last Name” and “First Name” columns. However, in both cases, I end up with some 100,000 rows, putting a serious cramp on my ability to manipulate the worksheet. The best solution I can think of is to create concatenations within a fixed range of cells. Although this would create useless cells, at least there wouldn’t be 99,900 of them.

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17  | Next Page >