How to make new line in JButton.setText()?
how to make new line in JButton.setText()?
I want to set the text of jbutton in tow line ,as follows
| jbutton-line1 |
| xxxxxxx-line2 |
i konw i can jbtton.settext("<html>line1<br>line2</html>");
but i find it's ugly using html,
is there anyother way to create new line in JButton's Text
As for the above comment....
I thought the question was well purposed. Using HTML was not acceptable in this instance, which was made clear, so why critisize his comments? "Using HTML" is a poor solution, it does NOT work in many instances due to browser, OS variations. Usually the "common answer" is never a COMPLETE answer.
Possible Solution:
Use JLabels to render the text on the button.
import javax.swing.*;
import java.awt.*;
public class ButtonMaker {
public static void makeButton(JButton jb, String[] titleList) {
jb.setLayout(new FlowLayout());
for (int i = 0; i < titleList.length; i++) {
JLabel tmpLabel = new JLabel(titleList);
tmpLabel.setForeground(Color.black);
jb.add(tmpLabel);
public static void clearButton(JButton jb) {
Component[] cList = jb.getComponents();
for (int i = 0; i < cList.length; i++) {
if (cList[i] instanceof JLabel)
jb.remove(cList[i]);
Known Limitations:
1. Flowlayout does not work well with single line text buttons... perhaps another layout manager may work better for various buttonsizes-linenumber combos.
2. Mac OSX : The default UI for Mac OS X (and above it seems), is to have rounded edged buttons. These rounded edges are destoryed when using JLabels, leaving a square, blocky button in its place.
POSSIBLE SOLUTION:
(this is ugly and time consuming)
- create images of the button with text on them.
Similar Messages
-
How to make new-line when printing strings?
Please help me with code . I can't able to print the string in new line
Anil... the same question as your other post:
Printing the string -
How to insert new line character?
Hi all,
I have two lines to print.
out.println("Available number of columns="+cols);
out.println("Number of columns must be present=10");My problem is:
i want both the lines to be printed one below the other. But, it is displayed in one single line.....
Can anyone please tell me how to insert new line character?
I tried with \n, '\n' and \r\n but, in vain......
Thanks for your time.
Regards,
AshviniYou should never use "\n" directly.
The line separator character is different on different operating systems.
And putting quotes around it in your string will make absolutely no difference in the JSP.
To find out what the line separator is you should use System.getProperty("line.separator");
The JSPWriter and PrintWriter classes will automatically use this property with a println statement, so a println will always finish with a line separator.
The issue here was that HTML by default ignores all whitespace.
The solutions provided
- use a <br> tag instead of a carriage return
- use <pre> tags, which tells the browser not to ignore whitespace. That can be troublesome in JSP which generates a lot of extraneous carriage returns into the code.
Cheers,
evnafets -
hai Friends , i've some problems, i really don't know how to add new line when typing
ThanksSorry you feel that way. It is still a new platform and is improving with every update. Hopefully the next update will make things better for you then.
If you want to thank someone for their comment, do so by clicking the Thumbs Up icon.
If your issue is resolved, don't forget to click the Solution button on the resolution! -
How to write new line on resource file.
Hello Everyone,
Can you please help me add new row on resource file, here is the code i have used to read my resource file.
I have no idea on how to add new line... Please help
private void btnBrowse1_Click(object sender, EventArgs e)
BrowseFile();
//versionIncrement();
if (txtInputfile.Text.Length > 0)
PathSelection = txtInputfile.Text;
oDataSet = new DataSet();
//now am reading the files fro the path that is selected
XmlReadMode omode = oDataSet.ReadXml(PathSelection);
for (int i = 0; i < oDataSet.Tables[2].Rows.Count; i++)
string comment = oDataSet.Tables["data"].Rows[i][2].ToString();
//the elements array contain all the columns filled
string[] elements = comment.Split('-'); //when it reaches the comma, it will jump to the next line
string font = elements[0]; //Font
string datestamp = elements[1]; //DateStamp
string commentVal = elements[2]; //Comment
string[] row = new string[] { oDataSet.Tables["data"].Rows[i][0].ToString(), oDataSet.Tables["data"].Rows[i][1].ToString(), font, datestamp = DateTime.Now.ToString(), commentVal };
Gridview_Input.Rows.Add(row);Hello
Sitholimela,
>> Can you please help me add new row on resource file, here is the code i have used to read my resource file.
From your description, it seems that your resource file is a XML format file, if so, you could also have a try to use
LINQ To XML which is easy to operate the XML file to add new row to your resource file, and here is an example to show how to add a new element/row to the specific tree:
Linq to XML Add element to specific sub tree
Regards.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
How to print new line in jsp page
hi
how to print new line in jsp page
thanks\n - new line character is in java specific not HTML
specific.Well, if the correct line separator sequence (by far not always \n) would be used, it does add a new line to the HTML output. Too bad that you don't want to see HTML but formatted text. The BR tag is a formatting element for the displayed text, not a line break in HTML. ;) -
How to insert new line in the copied schema with transaction code PE01?
Dear Experts,
I have copied HKT0 to ZKT0 , i want to insert new line between line 150 and line 160 in ZKT0, I don't know how to insert new line 160, who can tell me ?
Looking forward to your reply.
Best Regards,
MerryHi,
1. Open your schema,
2. In first colume "Line" select line where you want to add new line,
3. Replace first value in the column field (that indicates number of line) with character I (means insert),
4. Press enter
The line will be added. The same way you can add lines to PCR.
To delete use character D.
Cheers -
How to add new line in message on my S890
My stock keyboard in Lenovo S890 doesn't have enter key, is this normal ? How to add new line ?
However this happened only in messages, while using whatsapp the enter key present.Hi,
the fact that your question is posted in Order Management section, does the move order automatically generated by OM?
nevertheless, i don't think you should (or allowed, in this case) to add a new line in transact move order. Transact move order only queries (not create records) the move order lines eligible to allocate and transact.
So, I don't see why you need to add a new line in transact move order.
You can, however, add a new line in the allocation of the lines, where for instance, you need to have half of the line allocated to one locator, and the other half to another locator
Thanks -
How to insert new line break in XSLT mapping
Hi experts,
I am doing file to mail scenario, i am sending the text file as an attachment using reciever mail adapter.
I did everything, i can able to send the mail with text file attachment, but with in the file i got multiple rows, i need to put line break in XSLT mapping.
I did use following statement but it is inserting small rectangle between the records, the records are not separating with new lines, all are in one line.
<xsl:text>*#xA;</xsl:text>
note: in real coding replace * with &
Can anyone suggest me how to insert new line in XSLT mapping.
My XSLT mapping as look like:
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns0="http://www.Coj.co.za/SapIsuToABSA/DirectDebitFile">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:variable name="break"><br/></xsl:variable>
<xsl:variable name="space"> </xsl:variable>
<xsl:variable name="newline"><xsl:text></xsl:text></xsl:variable>
<xsl:template match="/">
<ns1:Mail xmlns:ns1="http://sap.com/xi/XI/Mail/30">
<Subject>Please Check Attached Direct Debit File</Subject>
<From>S@za</From>
<To>P@za</To>
<Content_Type>text/plain</Content_Type>
<Content>
<xsl:for-each select="MT_SapIsuToABSA_DirectDebitFile/DirectDebitRec/Body">
<xsl:value-of select="Space1"/>
<xsl:value-of select="Cust_AccNo"/>
<xsl:value-of select="Reserve_1"/>
<xsl:value-of select="Cust_Name"/>
<xsl:value-of select="Cust_Name1"/>
<xsl:value-of select="Cust_Bank_AccNo"/>
<xsl:value-of select="Space2"/>
<xsl:value-of select="Cust_Bank_BranchNo"/>
<xsl:value-of select="Reserve_2"/>
<xsl:value-of select="Space3"/>
<xsl:value-of select="Cust_AccNo_1"/>
<xsl:value-of select="Space4"/>
<xsl:value-of select="Reserve_3"/>
<xsl:value-of select="Deduction_Amnt"/>
<xsl:value-of select="Space5"/>
<xsl:value-of select="Reserve_4"/>
<xsl:value-of select="Space6"/>
<xsl:value-of select="Action_Date"/>
<xsl:value-of select="Space7"/>
<xsl:value-of select="Reserve_5"/>
<xsl:text>*#xA;</xsl:text>
note: in real coding replace * with &
</xsl:for-each>
</Content>
</ns1:Mail>
</xsl:template>
</xsl:stylesheet>
Kind regards,
PraveenHi,
I think <xsl:text>#xa;</xsl:text> should do the trick, but depending on which OS (ux or win), the "new line" chars sequence is different (win would require a CRLF like <xsl:text>#xd;*#xa;</xsl:text>)
Chris
-> &
Edited by: Christophe PFERTZEL on Apr 14, 2010 2:16 PM -
How to add new line item using BAPI BAPI_CONTRACT_CHANGE for contract-ME32K
HI Experts,
how to add new line item using BAPI: BAPI_CONTRACT_CHANGE for existing contract.
Requirement:
Already the contract having two line items using ME31K.
Custom program has to add new line items in existing contract.
Thanks,
SendilI got the solution:
We can do like this:
1. Get all details using details, BAPI_CONTRACT_GETDETAIL.
2. After getting results, append new line item. Then use your BAPI.
Check this posting program.. where this bapi is used, use the same coding technique.
IDOC_INPUT_PURCONTRACT_CHANGE -
Wanted to know how to make new mailboxes in e mail.
Wanted to know how to make new mailbox in e mail.
If you are on iOS 5+ and it's an IMAP type account then you should get an Edit button at the top of the list of folders that you currently have on your email account. If it's a POP type account then you won't get the Edit button, and you are limited to the folders that you currently have.
-
Hi,
How to make 'New Document' and 'Upload Document' to have same content type(Custom) in Document Library in Sharepoint2010.
Note : I have created custom Content Type since I have custom columns along with upload column..
Regards, Shreyas R Sgo to library settings
Change new button order and default content type
set your custom content type to be #1
when you upload new document it will automatically have your custom content type
Hope that helps|Amr Fouad|MCTS,MCPD sharePoint 2010 -
How to remove new line character from query output?
Hi,
How to remove new line character from query output?
have tried select replace(column_name, CHR(10), ' ') from table_name.
Edited by: GreenHorn on Sep 11, 2008 12:53 AMPlease consider, that windows uses a sequence of chr13||chr(10) Unix uses only one character chr(10).
The new line character(s) may be OS-dependent.
You could consider both with:
replace(replace(column_name, CHR(13)||CHR(10), ' '),CHR(10),' ')
Hartmut
Edited by: hartmutm on 11.09.2008 01:32 -
How to write new line to a File?
How to write new line to a file?
I have a string to be written to a file. the string contains "\n" in it. But why it is not showing the new line in the file.
I have tryed FileWriter class and FileOutputStream class, but none of them works?
any suggestion please...Probably using PrintStream::println() is a portable way.
import java.io.FileOutputStream;
import java.io.PrintStream;
public class NewLine {
public static void main(String[] args) {
try {
PrintStream ps = new PrintStream(new FileOutputStream("foo.txt"));
ps.write("string".getBytes());
ps.println();
ps.close();
} catch (java.io.IOException e) {
e.printStackTrace();
}Regards, -
How to create new line in actionscript 3
I have this simple script that is suppose to take a comma seperate values from xml and make it into something similar to a unordered list if only i could get a "\n" to work. Here is my script.
var dont_forget:Array = myXML..dont_forget[n].split(",");
var d:Number = dont_forget.length;
while (d--) {
detailsMovieClip_mc.dont_forget.text = "> "+dont_forget[d]+"\n\r";
trace(dont_forget[d]);
When the trace runs it shows me the values so i know that they are there. I am however only seeing the last value. How do i create a new line in as 3?Use the appendText method. By assigning the text using "=" you are overwriting it on each pass thru the loop.
detailsMovieClip_mc.dont_forget.appendText( "> "+dont_forget[d]+"\n\r");
Maybe you are looking for
-
Posting Period coming into the rows at the query runtime & couldn't drop it
Hi All, We have a query on an InfoCube that we have copied to the Multiprovider containing two cubes, exact copies of the original cubes. Two cubes are one for the previous years and one for the current year. Now, the query is copied from original cu
-
On Windows 7. It was working fine right up to the point of the upgrade to iTunes 10.2.2.12. Once I upgraded and restarted my home computer, the Apple TV (Gen2) does still see the share name of my main home computer hosting the iTunes shared library
-
Problems in creating RLANG stored procedure in HANA studio
Hi, While I am creating a stored procedure (using .hdbprocedure file) in HANA studio with language as RLANG, I am getting an error message like this: "It is not supported to use another language than sqlscript". I have the following setting configure
-
Keys sticking and repeating. Cannot be reproduced at will but will happen every few minutes or so while typing. I have not seen this when booting in to Windows 7. This problem makes this expensive computer frustrating to use. There have been akin r
-
hi there, i just noticed a strange behaviour in SL: when i configure the firewall with system preferences -> security -> firewall and set it to defaults, i.e. allowing certain services, stupid stealth mode off and then do a ipfw list in a terminal wi