Search Results

Search found 37239 results on 1490 pages for 'javax swing text'.

Page 77/1490 | < Previous Page | 73 74 75 76 77 78 79 80 81 82 83 84  | Next Page >

  • VIM: How do you get the last ex command you used?

    - by TrevorBoydSmith
    I find that sometimes I write a really long ex mode command that do lots of stuff. They are sort of "mini-scripts" that I write in the text editor then I start ex mode and copy them into the ex line and execute. But then I always end up editing in the ex mode and then I find it difficult to get the changes i did in ex mode back to my text editing session. Using the keyboard, how do you copy the last ex command you used and paste it into your text editor? (Note: This is sort of the opposite of this question "how do I copy/paste in vim ex mode" where the user asks "how do you copy from the text editor and paste INTO the ex mode?". My question is the opposite because I wish to copy from the ex mode and paste into my text editor.)

    Read the article

  • How to prevent Excel rounding numbers or adding redundant 0's?

    - by Highly Irregular
    I have a column of numbers that appear like this: but the actual value of the shown cell is 20130.153334 Other values have a different number of decimal places. I don't want to add redundant 0's, so I can't just specify a particular number of decimal places to display. I really just want to treat the values as text. I have already changed the format of the cell to Text, as the description for Text is: "Text format cells are treated as text even when a number is in the cell. The cell is displayed exactly as entered.". However, it clearly isn't being displayed exactly as entered! Strangely, if I hit F2 on the cell to go into edit mode, then hit enter, it is then displayed correctly. I can't do this manually for 2000+ records though! How can I prevent the numbers being rounded?

    Read the article

  • Image auto resizes in PdfPCell with iTextSharp

    - by Mladen Prajdic
    Hi, i'm having a weird problem with images in iTextSharp library. I'm adding the image to the PdfPCell and for some reason it gets scaled up. How do i keep it to original size? Here's the image of the PDF at 100% and the image in its original size opened in paint.net. I though that the images would be same when printed but the difference on the pic is the same on the printed version. Having to manually scale the image with ScaleXXX to get it to right seems a bit illogical and does not give a good result. So how do I put the image in its original size inside a PdfPCell of a table without having to scale it? Here's my code: private PdfPTable CreateTestPDF() { PdfPTable table = new PdfPTable(1); table.WidthPercentage = 100; Phrase phrase = new Phrase("MY TITLE", _font24Bold); table.AddCell(phrase); PdfPTable nestedTable = new PdfPTable(5); table.WidthPercentage = 100; Phrase cellText = new Phrase("cell 1", _font9BoldBlack); nestedTable.AddCell(cellText); cellText = new Phrase("cell 2", _font9BoldBlack); nestedTable.AddCell(cellText); cellText = new Phrase("cell 3", _font9BoldBlack); nestedTable.AddCell(cellText); iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(@"d:\MyPic.jpg"); image.Alignment = iTextSharp.text.Image.ALIGN_CENTER; PdfPCell cell = new PdfPCell(image); cell.HorizontalAlignment = PdfPCell.ALIGN_MIDDLE; nestedTable.AddCell(cell); cellText = new Phrase("cell 5", _font9BoldBlack); nestedTable.AddCell(cellText); nestedTable.AddCell(""); string articleInfo = "Test Text"; cellText = new Phrase(articleInfo, _font8Black); nestedTable.AddCell(cellText); nestedTable.AddCell(""); nestedTable.AddCell(""); nestedTable.AddCell(""); table.AddCell(nestedTable); SetBorderSizeForAllCells(table, iTextSharp.text.Rectangle.NO_BORDER); return table; } static BaseColor _textColor = new BaseColor(154, 154, 154); iTextSharp.text.Font _font8 = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, iTextSharp.text.Font.NORMAL, _textColor); iTextSharp.text.Font _font8Black = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, iTextSharp.text.Font.NORMAL, BaseColor.BLACK); iTextSharp.text.Font _font9 = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 9, iTextSharp.text.Font.NORMAL, _textColor); iTextSharp.text.Font _font9BoldBlack = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 9, iTextSharp.text.Font.BOLD, BaseColor.BLACK); iTextSharp.text.Font _font10 = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10, iTextSharp.text.Font.NORMAL, _textColor); iTextSharp.text.Font _font10Black = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10, iTextSharp.text.Font.NORMAL, BaseColor.BLACK); iTextSharp.text.Font _font10BoldBlack = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10, iTextSharp.text.Font.BOLD, BaseColor.BLACK); iTextSharp.text.Font _font24Bold = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 24, iTextSharp.text.Font.BOLD, _textColor);

    Read the article

  • Text to Speech in ASP.NET - Access is denied... what to do?

    - by Magnetic_dud
    On my personal website, i would like to make it "pronounce" something I solved the "concept" problem, as in here, and on my desktop it works smoothly when launched from visual web developer. Creates a file, and then an embedded player in the page will play it. Perfect. So, I uploaded it on the server... I get this error 500: Server Error in '/sapi' Application. Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user. (...) Source Error: See it below Source File: c:\mypath\sapi\myfile.aspx.cs Line: 21 Stack Trace: [UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))] SpeechLib.SpVoiceClass.Speak(String Text, SpeechVoiceSpeakFlags Flags) +0 prova.Button1_Click(Object sender, EventArgs e) in c:\mypath\sapi\prova.aspx.cs:21 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565 Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053 This is the source Source Error: Line 19: myfile.Open(@"C:\mypath\sapi\gen\hi.wav",SpeechStreamFileMode.SSFMCreateForWrite,false); Line 20: voice.AudioOutputStream = myfile; Line 21: voice.Speak("Hi",SpeechVoiceSpeakFlags.SVSFDefault); I get error on line 21, Voice.speak That probably means that the aspnet worker user has not some right permission The generation folder has all the right permissions: an empty file is created. So, i have to give permission of execute to some system dll? Do you know which dll? It is not bin\Interop.SpeechLib.dll, on this one the aspnet user has full control Ps: i have full control on the (windows) server (i mean, access by RDC, is not a shared hosting)

    Read the article

  • Trying to write a loop that uses an OutputStream to write to a text file.

    - by Steve McLain
    I'm not a java programmer, I'm a VB programmer. I am doing this as part of an assignment, however, I'm not asking for help on something assignment related. I'd like to figure out how to get the OutputStreamWriter to work properly in this instance. I just want to capture the values I'm generating and place them into a text document. The file is generated, but only one entry exists, not the 40 I'm expecting. I could do this in a heartbeat with VB, but java feels very strange to me right now. Your help is appreciated. Thanks, Steve Here's the code: public static void main(String[] args){ long start, end; double result,difference; try {//OutputStream code assistance from http://tutorials.jenkov.com/java-io/outputstreamwriter.html OutputStream outputStream = new FileOutputStream("c:\\Temp\\output1.txt"); Writer out = new OutputStreamWriter(outputStream); for(int n=1; n<=20; n++){ //Calculate the Time for n^2. start = System.nanoTime(); //Add code to call method to calculate n^2 result = mN2(n); end = System.nanoTime(); difference = (end - start); //Output results to a file out.write("N^2 End time: " + end + " Difference: " + difference + "\n"); out.close(); } } catch (IOException e){ } try { OutputStream outputStream = new FileOutputStream("c:\\Temp\\output1.txt"); Writer out = new OutputStreamWriter(outputStream); for(int n=1; n<=20; n++){ //Calculate the Time for 2^n. start = System.nanoTime(); //Add code to call method to calculate 2^n result = m2N(n); end = System.nanoTime(); difference = (end - start); //Output results to a file out.write("N^2 End time: " + end + " Difference: " + difference + "\n"); out.close(); } } catch (IOException e){ } } //Calculate N^2 public static double mN2(double n) { n = n*n; return n; } //Calculate 2N public static double m2N (double n) { n = 2*n; return n; }

    Read the article

  • I can I separate multiple logical pages in a text file I create in Perl?

    - by Micah
    So far, I've been successful with generating output to individual files by opening a file for output as part of outer loop and closing it after all output is written. I had used a counting variable ($x) and appended .txt onto it to create a filename, and had written it to the same directory as my perl script. I want to step the code up a bit, prompt for a file name from the user, open that file once and only once, and write my output one "printed letter" per page. Is this possible in plain text? From what I understand, chr(12) is an ascii line feed character and will get me close to what I want, but is there a better way? Thanks in advance, guys. :) sub PersonalizeLetters{ print "\n\n Beginning finalization of letters..."; print "\n\n I need a filename to save these letters to."; print "\n Filename > "; $OutFileName = <stdin>; chomp ($OutFileName); open(OutFile, ">$OutFileName"); for ($x=0; $x<$NumRecords; $x++){ $xIndex = (6 * $x); $clTitle = @ClientAoA[$xIndex]; $clName = @ClientAoA[$xIndex+1]; #I use this 6x multiplier because my records have 6 elements. #For this routine I'm only interested in name and title. #Reset OutLetter array #Midletter has other merged fields that aren't specific to who's receiving the letter. @OutLetter = @MiddleLetter; for ($y=0; $y<=$ifLength; $y++){ #Step through line by line and insert the name. $WorkLine = @OutLetter[$y]; $WorkLine =~ s/\[ClientTitle\]/$clTitle/; $WorkLine =~ s/\[ClientName\]/$clName/; @OutLetter[$y] = $WorkLine; } print OutFile "@OutLetter"; #Will chr(12) work here, or is there something better? print OutFile chr(12); $StatusX = $x+1; print "Writing output $StatusX of $NumRecords... \n\n"; } close(OutFile); }

    Read the article

  • AT&T’s new prepaid plan for smartphones –$65 for 1 GB data and unlimited calls, text

    - by Gopinath
    AT&T is stepping up competition in prepaid mobile plans offering and trying to attract more smartphone customers who are not interested to lock in with expensive contracts. Today AT&T announced a new prepaid plan for smartphone customers which offers 1 GB of , unlimited calls and text for $65 a month. Compared to existing plans that offers same , the new plan saves $10 per month and rates are comparable to T-Mobile prepaid service. The new plan will be available to all prepaid customers from October 7, 2012. I’m using AT&T prepaid plan for the past 3 months and paying $75 for 1 GB data, unlimited calls. Few days ago I did some analysis on prepaid plans offered by various network providers and found T-Mobile has cheapest plans that suits my needs – $60 for 2 GB data,  unlimited calls and texts. Even though T Mobile’s network coverage is not as great as AT&T in the area where I live, I planned to switch to save $15 per month. After reading today’s announcement, I don’t think that I’ll switch to T Mobile for saving $5 + 1 GB of extra data.  Thanks AT&T for the new plan, I’ll stay with you for now. via engadget

    Read the article

  • Text contains characters that cannot be resolved by this SpriteFont

    - by Appeltaart
    I'm trying to draw currency symbols in an Arial Spritefont. According to thissite, the font contains these symbols. I've included the Unicode character region for these symbols in the Content Processor SpriteFont file, like so: <CharacterRegions> <CharacterRegion> <Start>&#32;</Start> <End>&#126;</End> </CharacterRegion> <CharacterRegion> <!-- Currency symbols --> <Start>&#8352;</Start> <End>&#8378;</End> </CharacterRegion> </CharacterRegions> However, whenever I try to draw a € (Euro) symbol, I get this exception: Text contains characters that cannot be resolved by this SpriteFont Inspecting the SpriteFont in the IDE at that breakpoint shows the € symbol is in there. I'm at a loss at what could be wrong. Why is this exception thrown?

    Read the article

  • Google Blogger Website CName and/or Text File Issues

    - by Francis Gibbons
    I have a blogger Blog website and I would like to have it show up on my company website. I have read a couple articles out there on how to do it. A hand full of them talk about using FTP which is old and no longer available. However, I am trying to following along with this one: http://www.infinite42.com/small-business/integrate-blogger-blog-website Which seems pretty easy but I am having a problem getting Google to Verify the DNS CName or Text Record that I created on my Windows 2007 Server. Do I need to create this record at the registra level. Right now the domain is setup at the registra to point the www record to my server where on my server I tried the Txt Record and the CName Record with no luck in DNS. Here are the Google instructions for creating a CName file record in DNS: Follow the steps below to create a DNS (Domain Name System) record that proves to Google that you own the domain. Add the CNAME record below to the DNS configuration for abc.com. CNAME Label / Host: CNAME Destination / Target: Click Verify below. When Google finds this DNS record, we'll make you a verified owner of the domain. (Note: DNS changes may take some time. If we don't find the record immediately, we'll check for it periodically.) To stay verified, don't remove the DNS record, even after verification succeeds. Here is the link to do it with a CName: http://googlewebmastercentral.blogspot.com/2012/08/domain-verification-using-cname-records.html When I go to add my CName record on my server's DNS the only two fields available are Alias Name and Fully Qualified Domain Name. How am I suppose to create this record can someone please tell me? Thanks, Frank

    Read the article

  • Preventing Users From Copying Text From and Pasting It Into TextBoxes

    Many websites that support user accounts require users to enter an email address as part of the registration process. This email address is then used as the primary communication channel with the user. For instance, if the user forgets her password a new one can be generated and emailed to the address on file. But what if, when registering, a user enters an incorrect email address? Perhaps the user meant to enter [email protected], but accidentally transposed the first two letters, entering [email protected]. How can such typos be prevented? The only foolproof way to ensure that the user's entered email address is valid is to send them a validation email upon registering that includes a link that, when visited, activates their account. (This technique is discussed in detail in Examining ASP.NET's Membership, Roles, and Profile - Part 11.) The downside to using a validation email is that it adds one more step to the registration process, which will cause some people to bail out on the registration process. A simpler approach to lessening email entry errors is to have the user enter their email address twice, just like how most registration forms prompt users to enter their password twice. In fact, you may have seen registration pages that do just this. However, when I encounter such a registration page I usually avoid entering the email address twice, but instead enter it once and then copy and paste it from the first textbox into the second. This behavior circumvents the purpose of the two textboxes - any typo entered into the first textbox will be copied into the second. Using a bit of JavaScript it is possible to prevent most users from copying text from one textbox and pasting it into another, thereby requiring the user to type their email address into both textboxes. This article shows how to disable cut and paste between textboxes on a web page using the free jQuery library. Read on to learn more! Read More >

    Read the article

  • Ubuntu Server 11.10 boot, white terminal with garbled black text

    - by SpeedCrazy
    I just installed Ubuntu server 11.10 and the install went fine. This system is running on an Intel Pentium II board with onboard graphics. However when I try to boot into Ubuntu I get a white terminal with garbled black text. I have tried various grub 'fixes' as googling the issue seemed to suggest it was a res or grub related issue. I cannot ssh in so the issue does affect Linux as well. I have had no luck with anything thus far and am at my wits end. This was my first Ubuntu excursion as my friend told me it was better for servers than CentOS because it was easier... Not so much.... Does anyone have any ideas as to what the issue could be? When answering bear in mind I am an Ubuntu noob and Linux novice. As of 1/26/12 I have tried to add the console=ttyl line to the /etc/default/grub and run update-grub. This results in the line in the boot parameters that normally reads: linux /vmlunz-3.0.0-12-generic-pae root=/dev/mapper/dev-root rovt.handoff=7 now reads: linux /vmlunz-3.0.0-12-generic-pae root=/dev/mapper/dev-root ro console=ttyl vt.handoff=7 This does not work. Is there anyway to have console=ttyl inserted on a line by itself? I am at my wits ends, Thanks for all your help, Speed

    Read the article

  • PHP Calculating Text to Content Ratio

    - by James
    I am using the following code to calculate text to code ratio. I think it is crazy that no one can agree on how to properly calculate the result. I am looking any suggestions or ideas to improve this code that may make it more accurate. <?php // Returns the size of the content in bytes function findKb($content){ $count=0; $order = array("\r\n", "\n", "\r", "chr(13)", "\t", "\0", "\x0B"); $content = str_replace($order, "12", $content); for ($index = 0; $index < strlen($content); $index ++){ $byte = ord($content[$index]); if ($byte <= 127) { $count++; } else if ($byte >= 194 && $byte <= 223) { $count=$count+2; } else if ($byte >= 224 && $byte <= 239) { $count=$count+3; } else if ($byte >= 240 && $byte <= 244) { $count=$count+4; } } return $count; } // Collect size of entire code $filesize = findKb($content); // Remove anything within script tags $code = preg_replace("@<script[^>]*>.+</script[^>]*>@i", "", $content); // Remove anything within style tags $code = preg_replace("@<style[^>]*>.+</style[^>]*>@i", "", $content); // Remove all tags from the system $code = strip_tags($code); // Remove Extra whitespace from the content $code = preg_replace( '/\s+/', ' ', $code ); // Find the size of the remaining code $codesize = findKb($code); // Calculate Percentage $percent = $codesize/$filesize; $percentage = $percent*100; echo $percentage; ?> I don't know the exact calculations that are used so this function is just my guess. Does anyone know what the proper calculations are or if my functions are close enough for a good judgement.

    Read the article

  • "bug" in C++11 text by Stroustrup?

    - by Astara
    I found an apparent contradiction in the c++ text having to do with the result of the c_str() function operating on std:strings (in my copy, the definition and contradiction are on p1040). First it defines the c_str() function as something that produces a 'C-style' (zero-terminated) string, but later it talks about how a C++ c_str value can have embed a 'C'-style, end-of-string terminators (i.e. NUL's) embedded in the string (that is defined by being NUL terminated). Um... does anyone else feel that this is a 'stretching' of the definition of a C-string beyond it's definition? I.e. I think what it means, is that if you were to look at the length() function as applied to the string, it will show a different end of string than using the C-definition of a z-string -- one that can contain any character except NUL, and is terminated by NUL. I likely don't have to worry about it in my of my programs, but it seems like a subtle distinction that makes a C++ c_str, not really a 'C'-string. Am I misunderstanding this issue? Thanks!

    Read the article

  • Overlapping text on top menu in Unity 12.04

    - by mercury
    So I'm new to Linux but am basically blown away by Ubuntu 12.04 and could definitely see this becoming my main desktop over time One small annoyance for me is a tendency for the global menu on the top bar to partially over-write the text description of the active window in the top panel. e.g. I focus on the "Ubuntu Software Centre" window which writes out that label in the leftmost corner of the top menu bar. If I then move the cursor up to the top menu bar to access the "file menu", this will partially overwrite the window name leaving just "Ubuntu" visible. This is a little slice of ugliness I don't want to see every day! Much easier on the eye for me would be to display the active window name at the centre of the top panel, using some of that free space and then have the global menu stay where it is, just to the right of the app launcher. I've found a solution to disable the global menu but I would prefer to keep it and instead move (or disable) the active window name in the top panel. Any way to do this?

    Read the article

  • UITextView adding text to new line

    - by Subro
    I would like to add new lines of text to my UITextView for my iPhone app. Basically my textview starts with a single line, and as app advances, new lines are added. However I can add only to the end or beginning of the existing text. How can I make such an entry into a new line. Can I manually send \n to the textview.text at a calculated range/location. E.g. of what I mean. line 1: This is first line of text. This is second line 2: line of text. --- I want: line 1: This is first line of text. line 2: This is second line of text. Thanks!

    Read the article

  • android: tablerow mixed with columns and multiline text

    - by Yang
    I am trying to have a tablelayout contains several tablerows. One of the rows contains 4 buttons, while the second row contains a very long text. However, the width of the button stretches with the text in the second row. Is there anyway to prevent this? http://img684.imageshack.us/i/tableview1.jpg/ http://img521.imageshack.us/i/tableview2.jpg/ Here is my xml file: (somehow this website is not friendly to xml file) AbsoluteLayout android:id="@+id/widget0" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" TableLayout android:id="@+id/widget28" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_x="0px" android:layout_y="10px" TableRow android:id="@+id/widget29" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" Button android:id="@+id/widget30" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" Button android:id="@+id/widget31" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" Button android:id="@+id/widget32" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" Button android:id="@+id/widget33" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" TableRow android:id="@+id/widget35" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" TextView android:id="@+id/widget40" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextViewTextViewTextViewTextViewTextViewTextView"

    Read the article

  • Java Graphics2D DrawString....

    - by user69514
    Hey guys I have a little issue here. I have a panel where I am drawing a string. This is a game so I keep redrawing the score in order to update it. However when I draw it again it is drawn on top of the previous score so it looked all garbled up. Any ideas how to fix this? comp2d.drawString(GetScore(Score),ScoreX,ScoreY);

    Read the article

  • Putting JComboBox into JTable

    - by Dan
    Hi, I want to put individual JComboBoxes into each cells of a JTable. ie. The JComboBox content is not identical for each cell. I basically would like to be able to just call the following code to add a row of JComboBox into the JTable. Anyone has any idea? Thanks JComboBox cb1 = new JComboBox(...); JComboBox cb2 = new JComboBox(...); model.addRow(new Object[] {"Row name", cb1, cb2} ); JComboBox cb3 = new JComboBox(...); JComboBox cb4 = new JComboBox(...); model.addRow(new Object[] {"Row name 2", cb3, cb4} ); This is the resultant view if I do the above. http://www.freeimagehosting.net/uploads/a6292e08ee.png The closest example code I can find is as follows. But it is for where JComboBox content is identical for the individual column. Not the solution I need. TableColumn col = table.getColumnModel().getColumn(vColIndex); col.setCellEditor(new MyComboBoxEditor(values)); where public class MyComboBoxEditor extends DefaultCellEditor { public MyComboBoxEditor(String[] items) { super(new JComboBox(items)); } }

    Read the article

  • MigLayout JTextArea is not shrinking when used with linewrap=true

    - by Marcel
    Hi. If I use a JTextArea with MigLayout like this: MigLayout thisLayout = new MigLayout("", "[][grow]", "[]20[]"); this.setLayout(thisLayout); { jLabel1 = new JLabel(); this.add(jLabel1, "cell 0 0"); jLabel1.setText("jLabel1"); } { jTextArea1 = new JTextArea(); this.add(jTextArea1, "cell 0 1 2 1,growx"); jTextArea1.setText("jTextArea1"); jTextArea1.setLineWrap(false); } then the JTextArea grows and shrinks perfectly when resizing the window. When I set the linewrap to true the JTextArea is not shrinking when I make the window smaller again. I would very much appreciate any help. Thanks Marcel

    Read the article

  • Problem with my whiteboard application

    - by swift
    I have to develop a whiteboard application in which both the local user and the remote user should be able to draw simultaneously, is this possible? If possible then any logic? I have already developed a code but in which i am not able to do this, when the remote user starts drawing the shape which i am drawing is being replaced by his shape and co-ordinates. This problem is only when both draw simultaneously. any idea guys? Here is my code class Paper extends JPanel implements MouseListener,MouseMotionListener,ActionListener { static BufferedImage image; int bpressed; Color color; Point start; Point end; Point mp; Button elipse=new Button("elipse"); Button rectangle=new Button("rect"); Button line=new Button("line"); Button empty=new Button(""); JButton save=new JButton("Save"); JButton erase=new JButton("Erase"); String selected; int ex,ey;//eraser DatagramSocket dataSocket; JButton button = new JButton("test"); Client client; Point p=new Point(); int w,h; public Paper(DatagramSocket dataSocket) { this.dataSocket=dataSocket; client=new Client(dataSocket); System.out.println("paper"); setBackground(Color.white); addMouseListener(this); addMouseMotionListener(this); color = Color.black; setBorder(BorderFactory.createLineBorder(Color.black)); //save.setPreferredSize(new Dimension(100,20)); save.setMaximumSize(new Dimension(75,27)); erase.setMaximumSize(new Dimension(75,27)); } public void paintComponent(Graphics g) { try { g.drawImage(image, 0, 0, this); Graphics2D g2 = (Graphics2D)g; g2.setPaint(Color.black); if(selected==("elipse")) g2.drawOval(start.x, start.y,(end.x-start.x),(end.y-start.y)); else if(selected==("rect")) g2.drawRect(start.x, start.y, (end.x-start.x),(end.y-start.y)); else if(selected==("line")) g2.drawLine(start.x,start.y,end.x,end.y); } catch(Exception e) {} } //Function to draw the shape on image public void draw() { Graphics2D g2 = image.createGraphics(); g2.setPaint(color); if(selected=="line") g2.drawLine(start.x, start.y, end.x, end.y); if(selected=="elipse") g2.drawOval(start.x, start.y, (end.x-start.x),(end.y-start.y)); if(selected=="rect") g2.drawRect(start.x, start.y, (end.x-start.x),(end.y-start.y)); repaint(); g2.dispose(); start=null; } //To add the point to the board which is broadcasted by the server public synchronized void addPoint(Point ps,String varname,String shape,String event) { try { if(end==null) end = new Point(); if(start==null) start = new Point(); if(shape.equals("elipse")) selected="elipse"; else if(shape.equals("line")) selected="line"; else if(shape.equals("rect")) selected="rect"; else if(shape.equals("erase")) { selected="erase"; erase(); } if(end!=null && start!=null) { if(varname.equals("end")) end=ps; if(varname.equals("mp")) mp=ps; if(varname.equals("start")) start=ps; if(event.equals("drag")) repaint(); else if(event.equals("release")) draw(); } } catch(Exception e) { e.printStackTrace(); } } //To set the size of the image public void setWidth(int x,int y) { System.out.println("("+x+","+y+")"); w=x; h=y; image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); g2.setPaint(Color.white); g2.fillRect(0,0,w,h); g2.dispose(); } //Function which provides the erase functionality public void erase() { Graphics2D pic=(Graphics2D) image.getGraphics(); pic.setPaint(Color.white); pic.fillRect(start.x, start.y, 10, 10); } //Function to add buttons into the panel, calling this function returns a panel public JPanel addButtons() { JPanel buttonpanel=new JPanel(); JPanel row1=new JPanel(); JPanel row2=new JPanel(); JPanel row3=new JPanel(); JPanel row4=new JPanel(); buttonpanel.setPreferredSize(new Dimension(80,80)); //buttonpanel.setMinimumSize(new Dimension(150,150)); row1.setLayout(new BoxLayout(row1,BoxLayout.X_AXIS)); row1.setPreferredSize(new Dimension(150,150)); row2.setLayout(new BoxLayout(row2,BoxLayout.X_AXIS)); row3.setLayout(new BoxLayout(row3,BoxLayout.X_AXIS)); row4.setLayout(new BoxLayout(row4,BoxLayout.X_AXIS)); buttonpanel.setLayout(new BoxLayout(buttonpanel,BoxLayout.Y_AXIS)); elipse.addActionListener(this); rectangle.addActionListener(this); line.addActionListener( this); save.addActionListener( this); erase.addActionListener( this); buttonpanel.add(Box.createRigidArea(new Dimension(10,10))); row1.add(elipse); row1.add(Box.createRigidArea(new Dimension(5,0))); row1.add(rectangle); buttonpanel.add(row1); buttonpanel.add(Box.createRigidArea(new Dimension(10,10))); row2.add(line); row2.add(Box.createRigidArea(new Dimension(5,0))); row2.add(empty); buttonpanel.add(row2); buttonpanel.add(Box.createRigidArea(new Dimension(10,10))); row3.add(save); buttonpanel.add(row3); buttonpanel.add(Box.createRigidArea(new Dimension(10,10))); row4.add(erase); buttonpanel.add(row4); return buttonpanel; } //To save the image drawn public void save() { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bos); JFileChooser fc = new JFileChooser(); fc.showSaveDialog(this); encoder.encode(image); byte[] jpgData = bos.toByteArray(); FileOutputStream fos = new FileOutputStream(fc.getSelectedFile()+".jpeg"); fos.write(jpgData); fos.close(); //add replce confirmation here } catch (IOException e) { System.out.println(e); } } public void mouseClicked(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseEntered(MouseEvent arg0) { } public void mouseExited(MouseEvent arg0) { // TODO Auto-generated method stub } public void mousePressed(MouseEvent e) { if(selected=="line"||selected=="erase") { start=e.getPoint(); client.broadcast(start,"start", selected,"press"); } else if(selected=="elipse"||selected=="rect") { mp = e.getPoint(); client.broadcast(mp,"mp", selected,"press"); } } public void mouseReleased(MouseEvent e) { if(start!=null) { if(selected=="line") { end=e.getPoint(); client.broadcast(end,"end", selected,"release"); } else if(selected=="elipse"||selected=="rect") { end.x = Math.max(mp.x,e.getX()); end.y = Math.max(mp.y,e.getY()); client.broadcast(end,"end", selected,"release"); } draw(); } //start=null; } public void mouseDragged(MouseEvent e) { if(end==null) end = new Point(); if(start==null) start = new Point(); if(selected=="line") { end=e.getPoint(); client.broadcast(end,"end", selected,"drag"); } else if(selected=="erase") { start=e.getPoint(); erase(); client.broadcast(start,"start", selected,"drag"); } else if(selected=="elipse"||selected=="rect") { start.x = Math.min(mp.x,e.getX()); start.y = Math.min(mp.y,e.getY()); end.x = Math.max(mp.x,e.getX()); end.y = Math.max(mp.y,e.getY()); client.broadcast(start,"start", selected,"drag"); client.broadcast(end,"end", selected,"drag"); } repaint(); } @Override public void mouseMoved(MouseEvent arg0) { // TODO Auto-generated method stub } public void actionPerformed(ActionEvent e) { if(e.getSource()==elipse) selected="elipse"; if(e.getSource()==line) selected="line"; if(e.getSource()==rectangle) selected="rect"; if(e.getSource()==save) save(); if(e.getSource()==erase) { selected="erase"; erase(); } } } class Button extends JButton { String name; public Button(String name) { this.name=name; Dimension buttonSize = new Dimension(35,35); setMaximumSize(buttonSize); } public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D)g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //g2.setStroke(new BasicStroke(1.2f)); if (name == "line") g.drawLine(5,5,30,30); if (name == "elipse") g.drawOval(5,7,25,20); if (name== "rect") g.drawRect(5,5,25,23); } }

    Read the article

  • How to set a Transparent Background of JPanel

    - by Imran
    Hi, I need to know if a JPanel`s bacground can be set to Transparent? My frame is has two Jpanels Image Panel and Feature Panel, Feature Panel is overlapping Image Panel, the Image Panel is working as a background and it is loading image from a remote Url, now I want to draw shaps on Feature Panel , but now Image Panel cannot be seen due to Feature Panel's background color. I need to make Feature Panel background transparent while still drawing its shapes and i want Image Panel to be visible since it is doing tiling and cache function of images. I need to seperate the image drawing and shape drawing thats why I`m using two jPanels! is there anyway the overlapping Jpanel have a transparent background? thanks

    Read the article

  • while loop ignore the event listener

    - by Tamer
    so when i run this code to try to change the background the GUI crashes and gets stuck in a infinite while loop ignoring the event listeners. here is the code: `private Panel getPanel1() { if (panel1 == null) { panel1 = new Panel(); panel1.setLayout(new GridBagLayout()); while(frame.isVisible()){ panel1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent e) { frame.setVisible(false); } }); int r = (int) (Math.random()*255); int g = (int) (Math.random()*255); int b = (int) (Math.random()*255); Color c = new Color(r, g, b); panel1.setBackground(c); try { Thread.sleep(4000); } catch (InterruptedException e1) { e1.printStackTrace(); } panel1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent e) { /*panel1.setVisible(false); frame.setVisible(false);*/ System.exit(0); } }); } } return panel1; }` instead of exiting the loop of terminating the program or event changing the background it just displays the panel and does nothing else and i have to force it to quit. what should i do?

    Read the article

  • Checkboxes and Radio Buttons Together in a JTree

    - by Thunderforge
    I'd like to create a JTree that more or less has the following structure (with a hidden root node) [No Option] Main Dish [Radio Button] Steak [Radio Button] Fish [Radio Button] Filet Mignon [Checkbox] Side Dish [Checkbox] Mashed Potatoes [Checkbox] Green Beans [Checkbox] Mixed Vegetables [Checkbox] Dessert [Radio Button] Ice Cream [Radio Button] Pudding [Radio Button] Cake Basically, at least one main dish (but no more than one) can be chosen, any number of side dishes can be chosen (or none, if the "Side Dish" checkbox is unchecked), and only one dessert can be chosen (or none, if the "Dessert" checkbox is unchecked). This article describes how to create a tree that uses JCheckboxes (as I'd like to use for the Side Dish and Dessert sections) by creating a custom Renderer and page 3 of the same article describes how to use Radio buttons (as I'd like to use for the Main Course) section. But it doesn't describe how to mix them up within the same JTree. Is it possible to create a structure like this? And if so, how?

    Read the article

< Previous Page | 73 74 75 76 77 78 79 80 81 82 83 84  | Next Page >