How to get multiline text on progress bar

Hi there,
I have to use Progress Bar and need to show text in multiline.
can anyone please suggest me how to achieve that.
Thanks,
Prashant

can u guys figure out what really i am missing here?A spoon-fed solution, I suppose. So enjoy:
// A JProgressBar with two lines of text.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.beans.*;
public class PB2Lines extends JPanel implements
                         ActionListener, PropertyChangeListener {
    private TwoLinesProgressBar progressBar;
    private JButton startButton;
    private Task task;
    class Task extends SwingWorker<Void, Void> {
        public Void doInBackground() {
            int progress = 0;
            //Initialize progress property.
            setProgress(0);
            while (progress < 100) {
                progress += 25;
                setProgress(progress);
          if (progress==25)
            progressBar.setString("Eggs|added");
          else if (progress==50)
            progressBar.setString("Sugar|added");
          else if (progress==75)
            progressBar.setString("Milk|added");
          else
            progressBar.setString("Everything|done");
                try {
                  Thread.sleep(500);
                } catch (InterruptedException ignore) {}
            return null;
        public void done() {
            Toolkit.getDefaultToolkit().beep();
            startButton.setEnabled(true);
            setCursor(null); //turn off the wait cursor
    public PB2Lines() {
        super(new BorderLayout());
        //Create the demo's UI.
        startButton = new JButton("Start");
//        startButton.setActionCommand("start");
        startButton.addActionListener(this);
        progressBar = new TwoLinesProgressBar(0, 100);
        progressBar.setPreferredSize(new Dimension(200,40));
        progressBar.setValue(0);
//        progressBar.setStringPainted(true);
        progressBar.setString("Progress|Bar");
        JPanel panel = new JPanel();
        panel.add(startButton);
        panel.add(progressBar);
        add(panel, BorderLayout.PAGE_START);
        setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
     * Invoked when the user presses the start button.
    public void actionPerformed(ActionEvent evt) {
        startButton.setEnabled(false);
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        task = new Task();
        task.addPropertyChangeListener(this);
        task.execute();
     * Invoked when task's progress property changes.
    public void propertyChange(PropertyChangeEvent evt) {
        if ("progress" == evt.getPropertyName()) {
            int progress = (Integer) evt.getNewValue();
            progressBar.setValue(progress);
    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
               JFrame frame = new JFrame("ProgressBar with 2 lines");
               frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
               JComponent newContentPane = new PB2Lines();
               newContentPane.setOpaque(true); //content panes must be opaque
               frame.setContentPane(newContentPane);
               frame.pack();
               frame.setVisible(true);
  class TwoLinesProgressBar extends JProgressBar {
    public TwoLinesProgressBar(int min, int max) {
      super(min, max);
    private int getXofCenteredString(String s) {
      int ix= getFontMetrics(getFont()).stringWidth(s);
      return (getWidth()-ix)/2;
    protected void paintComponent(Graphics g) {
      super.paintComponent(g);
      int i= getString().indexOf('|');
      String s= getString().substring(0,i);
      int ix= getXofCenteredString(s);
      g.setColor(Color.BLACK);
      g.drawString(s, ix,15);
      s= getString().substring(i+1);
      ix= getXofCenteredString(s);
      g.drawString(s, ix,35);
}

Similar Messages

  • How to get the Text name to pass in the  parameter header in save_text

    Hi,
      I am trying to change the long text of operation for historical order by using the flat file.I am using the save_text to do this.I would like to know how  to get the text name in order to pass the parameter header in save_text.
      I went to the tcode iw62 to get the header information of the long text.300100000009200000001
    i would like to know what this 1000000092 indicates and where is this value updated in the table so that i can link it thru the order no  to get the link and pass it in the text_name.
      can anyone help me out?
    krishnan

    Hi,
    Your query is.
    I went to the tcode iw62 to get the header information of the long text.300100000009200000001
    i would like to know what this 1000000092 indicates
    In above number
    300 - Client
    1000000092 - AUFPL - Routing number of operations in the order (You can fetch this from table HIVG)
    00000001 - APLZL - General counter for order ( You can fetch this from table HIVG).
    BR,
    Vijay

  • How to get the text present in JTextArea

    i am writing application for some system to be computerised and i am not getting how to get the text present in text area and set it into database...can anybody suggest me solution??

    You must have named the TextArea like
    JTextArea textArea;so, use the getText() method like
    String strTextAreaContents = textArea.getText();You can then use JDBC to connect to the database that you want and save your contents that is now in strTextAreaContents.
    -- Srikanth

  • How to get Sales Text & Purchase Order Text in MM based on (MSEG-MATNR)

    Hi
      Am working on a Report based on Purchase order & Sales, Could any body tell How to get Sales Text & Purchase Order Text in MM based on (MSEG-MATNR).
    the Field i need to get are : SALES TEXT, PO TEXT.
    Sunil.

    Hi Sunil,
    For getting Material PO text and sales text, you have to rely on Purchase Order and Sales Order. And use READ_TEXT function module to fetch the text.
    Below are examples of PO text and Sales Text:
    1. PO text:
        CALL FUNCTION 'READ_TEXT'
         EXPORT
           ID = 'F03'
           LANGUAGE = SY-LANGU
           NAME = '450000011200010' conacte PO number and line item number
           OBJECT = 'EKPO'
         TABLES
           LINES = INT_TLINES "you will get text in this table
    2. Sales order text:
            CALL FUNCTION 'READ_TEXT'
         EXPORT
           ID = '0001'
           LANGUAGE = SY-LANGU
           NAME = '0000000036000010' conacte SO number and line item number
           OBJECT = 'VBBP'
         TABLES
           LINES = INT_TLINES "you will get text in this table
    ref: STXH and STXL tables.
    Hope it will solve the problem.
    Regards
    Krishnendu

  • How to get the 'text' property value of a button in coding?

    Hi Experts,
    I'm using 10 buttons all are having common action('click'). when i click a button the 'text' value of the button should pass to a function.So the action is same but the passed value will be the 'text' value of the corresponding button.  I don't know how to get the 'text' property of a button in coding. Kindly help me to solve this problem.
    Thanks and Regards
    Basheer

    Hi,
    My event is like this.
    public void onActionclick(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
         String s =  ?  ; // should get the 'text' property of clicked button
         fillInput(s);     // function to be called
    The called function is,
    public void fillInput( java.lang.String id )
        String str=wdContext.currentContextElement().getNum();
        str = str + id;
        wdContext.currentContextElement().setNum(str);
    How can i get the 'text' property value of the corresponding button. Click action should be common to all buttons.
    Thanks and Regards,
    Basheer

  • How do you unstick the blue progress bar?

    how do you unstick the blue progress bar? It most times, just sits there and the refresh button doesn't help.

    1. Power cycle
         Power off the router. Unplug it from the wall. Wait a while.
         Plug it back to the wall. Power the router on. Wait until all the lights are lit properly.
         It will take a   while.
         Restart the computer.
         Start up in Safe Mode
         http://support.apple.com/kb/PH11212
    2 Empty Caches
        Safari > Preference > Advanced
        Checkmark the box for "Show Develop menu in menu bar".
        Develop menu will appear in the Safari menu bar.
        Click Develop and select "Empty Caches" from the dropdown.

  • How to get a text between two XML tags?

    Hello everybody!
    I've got a problem! How can I extract a text that is between tags, like <myTag> My text </myTag> I have no problem to get the attributes inside the tags, however, i don't know how to get some text that is between tags. Here is my xml:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <tangram_request service_id="3">
    <send keep_session="nada">
    <source></source>
    <destination>3196931566</destination>
    <channel_id>2</channel_id>
    <text>Teste ServerSocket!!!</text>
    </send>
    </tangram_request>
    Now, there's a fragment of my code, which gets some tags' attributes:
    DOMParser parser = new DOMParser();
    InputSource resp = new InputSource(new StringReader(XML));
    parser.parse(resp);
    Document doc = parser.getDocument();
    Node node =(doc.getElementsByTagName "tangram_request")).item(0);
    if (node instanceof Element)
    Element el = (Element) node;
    service_id = el.getAttribute("service_id");
    System.out.println("\n\nService_id="+service_id);
    }else{System.out.println("Erro");}
    node = (doc.getElementsByTagName("send")).item(0);
    if (node instanceof Element)
    Element el = (Element) node;
    keep_session = el.getAttribute("keep_session");
    System.out.println("keep_session="+keep_session);
    }else{System.out.println("Erro");}
    Now, I want to get the texte between <destination> ... </destination>
    How could I do that?
    Thanks a lot
    Calegari

    Thanks... It worked fine!!!
    Now how can I get lots of <desctination>... I did something that haven't worked...
    node = (doc.getElementsByTagName("destination")).item(0);
    while(node.hasChildNodes())
    destination = node.removeChild(node.getFirstChild()).getNodeValue();
    System.out.println("destination="+destination);
    And now, my XML is like:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <tangram_request service_id="3">
    <send keep_session="nada">
    <source></source>
    <destination>3196931566</destination>
    <destination>3196931567</destination>
    <channel_id>2</channel_id>
    <text>Teste ServerSocket!!!</text>
    </send>
    </tangram_request>
    Thanks so much!
    Calegari

  • How to get standard Windows (7) title bars in Visual Studio 2013 Express?

    With the "title bar" background color changing when active vs inactive like all my other Windows.
    Using Win 7 in "Windows Classic" theme.

    Hi sponge_bob_128,
    >>How to get standard Windows (7) title bars in Visual Studio 2013 Express?
    Based on your issue, could you please tell me more detailed message about your issue.
    For example:
    (1)What did you would like to do in the Visual Studio 2013 Express?
    (2) If you want to develop a program like the "title bar" background color changing when active vs inactive from the VS2013 Express.
    Generally, I know that when we set the theme as "Windows Classic" theme on the Windows 7 and then start two VS windows, it will show an active VS window like the following screen shot.
    To further help you solve this issue, please tell me more detailed message for me.
    Best 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.

  • When and How to get the Text.ScrollPos value of a String control when scroll bar position changed

    Hi, 
    I'm working on a feature triggered by scroll bar position of a string control changed.
    But I could not find a good way to catch the scroll bar position changed event, 
    the scroll bar is controlled manually by mouse down → mouse move → mouse up, I want the get the Text.ScrollPos value when user mouse up, and compare with the maximum value.
    But the problem is,  mouse up on the scroll bar could not trigger String: Mouse up event!
    So I have to get the Text.ScrollPos continuously in the background in Timeout event, but I think it’s not efficient.
    Do you have any better idea on when to get the correct destination value of Text.ScrollPos?
    I plan to store the value of Text.ScrollPos in the bottom(maximum value) in a shift register, then compare the current Text.ScrollPos value with the max one.
    If it comes close to the bottom(90%~100% of the maximum value), then the close to bottom LED will turn on.
    Attachments:
    scroll bar pos changed.vi ‏15 KB

    Hello Cecilia,
    I don't think there is any build-in event for this.
    One solution would be to create your own user event at the initialisation of you main and launch a thread which is going to be pulling the value of your scrollbar position:
    Then you can build your main as if they were a scrollbar move event.
    And dont forget to close the thread and destroy the event at the end.
    Hope it helps.
    Attachments:
    Scrollbar event.PNG ‏10 KB

  • How to get short text of a exception thrown by abap rfc

    Hi buddy,
    I use jco to communicate with backend, an abap function module will raise a exception. I can catch that exception,
    The example exception is:
    <b>Exception</b>     <b>Short text</b>
    Test                   This is exception test.
    e.getKey()
    will return TEST.
    Does any know how to get that short text "This is exception test." from the exception I caught?
    Thanks
    Austin

    Hi Austin,
    There are 2 methods to raise errors in function modules.
    1) Using the raise Exception statement
    2) Using a return structure like BAPIRET to populate the message details like type, error number, error text etc.
    Generally method 1 is not recommended for any RFC/BAPI function modules because it causes the calling program to crash if the function raises an exception. Method 2 is the recommended way and is used in all standard BAPI's. ABAP programmers are advised to code RFC's as per method 2, but some times it would not be possible as the function would already be used and could be barred from changes.
    But whatever method the RFC uses to raise an exception, web dynpro can handle it in the following ways,
    Method 1) If the RFC raises an exception using RAISE EXCEPTION,
    Dont catch Exception class in your code, instead do the following,
    catch (WDDynamicRFCExecuteException e) {
                      wdComponentAPI.getMessageManager().reportException(
                            e.getLocalizedMessage(),
                            true);
    Method 2) If the function returns the errors in the standard bapi return structure, you can do the following
                IWDMessageManager MsgMgr = wdComponentAPI.getMessageManager();
                for (int i = 0; i < ReturnNode.size(); i++) {
                      if (Types.indexOf("S") != -1
                            && ReturnNode.getElementAt(i).getAttributeAsText("Type").equals(
                                  "S"))
                            MsgMgr.reportSuccess(
                                  ReturnNode.getElementAt(i).getAttributeAsText("Message"));
                      if (Types.indexOf("W") != -1
                            && ReturnNode.getElementAt(i).getAttributeAsText("Type").equals(
                                  "W"))
                            MsgMgr.reportWarning(
                                  ReturnNode.getElementAt(i).getAttributeAsText("Message"));
                      if (Types.indexOf("E") != -1
                            && ReturnNode.getElementAt(i).getAttributeAsText("Type").equals(
                                  "E"))
                            MsgMgr.reportWarning(
                                  ReturnNode.getElementAt(i).getAttributeAsText("Message"));

  • How to start and stop a progress-bar thread before/after the main thread

    hi. I would appreciate any kind of help on my request.
    I have this as my main() function
         public static void main(String[] args)
              SwingUtilities.invokeLater(new Runnable(){
                   public void run(){                              
                        Options op = new Options();
                        OdessaClient oc = new OdessaClient(op);     
                        oc.setVisible(true);                    
         }Whenever I try to start a simple JFrame with an indeterminate progress bar on it just before the main function and stop it somewhere after I get a StackOverFlow error
    Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
         at java.awt.Component.show(Component.java:1302)
         at java.awt.Component.setVisible(Component.java:1253)
         at com.client.CylonBar.hide(CylonBar.java:25)
         at java.awt.Component.show(Component.java:1302)
         at java.awt.Component.setVisible(Component.java:1253)
    ...and so on...How must I implement something like it?

    Not precisely that way, but just off the top of my head, you would have to have a handle to the proccess (server) in the first window, then have a monitor program that allows you take this handle and end it. I would make this monitor program be the gateway to starting and stopping your server. To run a .bat file you can use runtime.exec().

  • How to get selected text values in a textarea by mouse click?

    Hi Everyone,
    What I am trying to do is to click on some texts in a textarea, then get the selected text value.
    If you guys have used an accounting software called Simply Accounting, you might understand better.
    I list all my customer names in a textarea. What I want is, when I click on one customer, another GUI pops up with this customer's information. My problem is that I don't know how to get the selected text value from a textarea.
    Could anyone give a hand here? Thank you in advance.

    Is there some reason you aren't using a JList or
    JTable to display
    the user names/information?Thank you for es5f2000's reply. You just gave me a better idea! There is not a particular reason I have to use TextArea to list my customers. As long as the component can make my idea alive, I definitely use it. Still, if there is any way to get a selected text value, it will help me a lot with my project. Thank you.

  • How to get textbox text inside Repeater based on specific row dropdownlist selection using JavaScript

    Hi All,
    I have dropdownlist and textbox controls inside repeater control. Suppose when i select specific dropdownlist i want get the value of selected item and mean while i want to get the textbox text which in the same row.
    <script type="text/javascript">
    var ddlType;
    function ddl(ddl) {
    ddlType = ddl.value;
    alert(ddlType);
    </script>
    <asp:Repeater ID="RepterDetails" runat="server"
    onitemdatabound="RepterDetails_ItemDataBound"
    onitemcommand="RepterDetails_ItemCommand" >
    <ItemTemplate>
    <tr>
    <td>
    <asp:DropDownList ID="ddlTypeName" runat="server" onchange="ddl(this)"></asp:DropDownList>
    </td>
    <td>
    <asp:TextBox ID="txtCode" runat="server" Text='<%#Eval("otaRoomTypeCode") %>' />
    </td>
    </tr>
    </ItemTemplate>
    </asp:Repeater>
    Using the javascript i got the selected dropdownlist selected value, how to get the textbox text which is in the same row.
    Please give me advice and please find the repeater control screenshot.
    Thanking You, Nagendra.

    This forum if for C# issues, please move your post to asp.net forum:  http://forums.asp.net/
    Thanks
    Fouad Roumieh

  • How to get the text field in the header for only first page of the report

    Hi,
    I am developing reports in BI Publisher Enterprise where i am facing problem i.e., i have to get some text field in header,for only first page in the result but it is displaying in all the other pages of the report in result.So,please if you have any idea of how to solve it, please reply.It is required as early as possible.
    Thanks in Advance

    Invalid path? What are you doing? Writing the report output to an invalid directory?
    Where are your terms and conditions? It would be very easy just to put them in a database table and select them in your report query.

  • How to get the text in a label which is imbeded in a JTextPane

    I have created a JTextPane that has 5 JLabels inserted in the text. I have attempted to get the text with the following code snippet.
    Component[] lbl = new Componennt[DisplayLetterPane.getComponentCount()];
    //         JTextPane DisplayLetterPane; is defined previously
             lbl = DisplayLetterPane.getComponents();
             int componentIndex = 0;
             String lblText = new String(((JLabel)lbl[componentIndex]).getText());I have run a dump of the sytledDocument of the JTextPane and I see the JLabel listed as a component.
    When this snippet is executed I get the following:
    Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.text.ComponentView$Invalidator
    When I check the character where the component for the JLabel is located in the styled document it does not find an instanceof JLabel.
    How can I get the text from the labels.
    Thank you in advance!

    JTextPane jtp = new JTextPane();
              for (int i = 0; i <5; i++) {
                   jtp.add(new JLabel("labelText"+i));
              Component[] lbl = new Component[jtp.getComponentCount()];
    //      JTextPane DisplayLetterPane; is defined previously
          lbl = jtp.getComponents();
          int componentIndex = 0;
          for (int i = 0; i < lbl.length; i++) {
               System.out.println(((JLabel)lbl).getText());
    When I do like the above, it just works fine. Can u share a little bit more of your code?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for

  • Java plugin not working on any browser (64-bit system)

    Hi there! I'm having a major problem with running Java plugin on all of my browsers (Opera, Chromium and Firefox) under my Arch Linux 64-bit system. The system is fully up-to-date, and Java plugin is being displayed among other plugins on "about:plug

  • How to get (old)previous date and create a loop?

    Hi!!! I am using java.util.date object. I need to get the 2 months back date,i.e. 60 days back date and to create a loop from that date till today and add it to combobox. Suppose today's date=3-12-2001 x=date-60=3-10-2001 and wants to create a loop f

  • Apple id not valid for updating Pages

    Hi all, I just got a mac mini. I used time machine to migrate my desktop from my 2008 mac book. I thought I was using the same apple id for everything (I only have 1), but when I go to update pages it says the apple id does not match. What is happeni

  • Logon is not possible because you have not been assigned to a business role; please contact your system administrator

    Hi experts, I'm having a problem when our project approaching the end. If I assigned the business role in parameter CRM_UI_PROFILE and PFCG role in SU01. It works fine,and the user can logon the web ui. Now I created a new organization model and posi

  • String array error, not understandable

    I get this error: Exception in thread "AWT-EventQueue-0" java.lang.StringIndexOutOfBoundsException: String index out of range: -1 i cant understand its reason because it comes only when a string of length more than 12 is entered.Moreover it doesnt co