Displaying Lines in java Qusetion?

hi,
i was wondering is there a way to display thick 2d lines in java swing when drawing lines with paintComponent(). the default is very thin but i was wondering is there a method to display wider lines!!
cheers in advance

You can define line width using setStroke(Stroke myStroke) of Graphics2D class.
Cheers
DB

Similar Messages

  • Problem in drawing a line in Java Application Program

    Hi,
    I am trying to draw a line after a message is displayed on the screen. But the line is not at all coming on the screen while running. but I can see a red line is appearing on the screen first and and it is getting overridden.
    There is something wrong in the concept what I understood about graphics.Can anybody help to
    understand where the problem is ?
    Here is the part of the code which used to draw line.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import java.util.Date.*;
    import java.text.*;
    import java.lang.*;
    import MyPack.*;
    class chalan_pay extends JFrame
    JTextField jt1,jt2,jt3,jt4,jt5;
    JLabel jlh,jl1,jl2,jl3,jl4,jl5,jl10;
    JButton bt1,bt2,bt3;
    Choice ch1,ch2,ch3,ch4;
    Connection con = null;
    int i1no,i2no,i3no,i4no,itno;
    String idate;
    public chalan_pay()
    getContentPane().setLayout(null);
    jt1= new JTextField(5);
    jt1.setBounds(110,150,50,20);
    jt2= new JTextField(10);
    jt2.setBounds(400,150,100,20);
    jt3= new JTextField(3);
    jt3.setBounds(590,150,30,20);
    jt4= new JTextField(2);
    jt4.setBounds(750,150,30,20);
    jlh= new JLabel();
    jlh.setText("CHALLAN DETAILS");
    jlh.setBounds(300,50,200,20);
    jl1= new JLabel();
    jl1.setText("IGM No. ");
    jl1.setBounds(50,150,100,20);
    jl2= new JLabel();
    jl2.setText("IGM Date ");
    jl2.setBounds(340,150,100,20);
    jl3= new JLabel();
    jl3.setText("Line No. ");
    jl3.setBounds(530,150,100,20);
    jl4= new JLabel();
    jl4.setText("Subline No. ");
    jl4.setBounds(680,150,100,20);
    jl10= new JLabel();
    jl10.setBounds(100,200,300,20);
    ch1= new Choice();
    ch1.setBounds(170,150,150,20);
    getContentPane().add(ch1);
    ch1.addItemListener(new Opt1());
    bt1= new JButton("Exit");
    bt1.setBounds(200,600,100,20);
    getContentPane().add(bt1);
    bt1.addActionListener(new Ex());
    try
    con=db_connect.getConnection();
    Statement st1 = con.createStatement();
    ResultSet rs1 = st1.executeQuery("select igm_no,to_char(igm_dt,'DD-MON-YY'),line_no,subline_no from "+
    "det_item order by igm_no");
    while(rs1.next())
    ch1.addItem(String.valueOf(rs1.getInt(1))+" "+rs1.getString(2)+" "+
    String.valueOf(rs1.getInt(3))+" "+String.valueOf(rs1.getInt(4)));
    rs1.close();
    st1.close();
    catch(Exception e){e.printStackTrace();}
    getContentPane().add(jlh);
    getContentPane().add(jl1);
    getContentPane().add(jt1);
    getContentPane().add(jl2);
    getContentPane().add(jt2);
    getContentPane().add(jl3);
    getContentPane().add(jt3);
    getContentPane().add(jl4);
    getContentPane().add(jt4);
    getContentPane().add(jl10);
    setSize(900,700);
    setVisible(true);
    show();
    public void paint(Graphics g)
    g.setColor(Color.red);
    g.drawLine(0,300,600,300);
    class Ex implements ActionListener
    public void actionPerformed(ActionEvent evt)
    if(evt.getSource() == bt1)
    dispose();
    return;
    This code is incomplete. The program is compiled and Ran. I am unable to see the Line.
    Is it because , I am using contentPane ?. Please help me to cake it clear.
    mjava

    I have no idea what JTutor is, but if it tells you to override paint() in Swing, it's not worth its disk space.
    [http://java.sun.com/docs/books/tutorial/uiswing/painting/closer.html] clearly says that for all practical purposes paintComponent will be the only method that you will ever need to override.

  • I am programmer and I am using dr java on my mac-book pro with retina display but dr java doesn't support retina display, what is the possible way to solve this ?

    I am programmer and I am using dr java on my mac-book pro with retina display but dr java doesn't support retina display, what is the possible way to solve this ?

    I have made some progress.... I can print wirelessly from my printer now, but I can't set the printer itself to be wireless.  I had to move my printer downstairs to where my router is...which is not that convient.   I printed up the page you asked about....and as expected, it says it is off line and there is no IP address.    So now I need to figure out how to make my printer itself wireless.  I did download the HP driver I needed...but I can't access it to do anything else.  It seems l like I am missing a step... or I need to hook up my computer itself to the printer to help get the printer to be wirelss, but I can't hook it up because there is no port for me to do that (no port that looks like a phone jack).  I am guessing I would need a different type of cord, but I am not sure what kind of cord that would be! Ugh!

  • How to brake to new line in Java function in XI

    Hi,
    How to brake next line in java function in XI(i am trying to use \n but it is not going to next line its displaying same in output). can anybody help me on this
    Thanks,
    Sudheer.

    Sudheer ,
    Please explain about your requirement with example data with source structure and target structures with the java requirement .
    Regards,#
    Reddy

  • Trying to get a JEditorPane to highlight the full width of a displayed line

    I have displayed the wep page in JEditorPane . Now I'm trying to get a JEditorPane to highlight the full width of a displayed line. All the examples I've tried only highlight the textual content. For example if I have content such as this:
    + Here is some text +
    + some more text +
    within a JEditorPane represented by the box above, then highlighting the first row highlights only the 'Here is some text' (represented between [ and ] below).
    [ Here is some text ]
    [some more text ]
    I would like it to highlight the full width of the JEditorPane like the following:( ie Inspecting the Html element in firebug ....)
    l Here is some text l
    l some more text l
    l_________________________l
    Is there a way to do this?
    Edited by: arunnprakash on Mar 27, 2009 7:59 AM

    Take a look here:
    [http://tips4java.wordpress.com/2008/10/29/line-painter/]
    [http://www.java-forums.org/awt-swing/10862-how-select-highlight-entire-row-jtextpane.html]
    db

  • Displaying line numbers in JTextPane?

    Hi I have attached a JTextPane to an InternalFrame. What i wanted to do is i have to display line number on the left side of the textpane and that should be not editable(only Line number) and when we move to the next line the cursor has to be placed right next to the line number. How this can be done?

    You can try this one http://www.developer.com/java/other/article.php/3318421/Add-Line-Numbering-in-the-JEditorPane.htm
    Or this http://java-sl.com/bullets_numberings.html (bullets/numbering based)
    Or this http://tips4java.wordpress.com/2009/05/23/text-component-line-number/

  • Display image in java.awt.List

    hello guys,
    How i can display image in java.awt.List means listbox. give me sample code. if you have
    Waiting for your favorable reply.
    Regards,
    Bhavesh Kharwa

    java.awt.List you can not.
    javax.swing.JLast you can.

  • How to display line items twice in a single page in sap script

    HI,
      I am working on check printing. I copied the standard driver program and form to Zprogram and ZForm. Which are RFFOUS_C(print program) and F110_PRENUM_CHECK(Form Name).
    I want to display the line items twice in the same page and sub sequent pages.
    Currently I am able to display line items only once.
    Example:
    PAGE1.
    line item1
    line item2
    line item3
    line item4
    line item5
    line item1
    line item2
    line item3
    line item4
    line item5
    line items 1 to 5 which are in main window.
    How to achive this problem.
    Regards,
    vinod

    Hi
    I had the same request for a check form in Canada. I solved it by writing the line item output into variables and print these variables in a second window. It was ~10 hours of effort, not a real nice technical solution but it worked.
    If you require I can send you a PDF of the sap script form definition. You can contact me at [email protected] Answers can take 1 week or more. 
    Best regards
    JD

  • How to go to a specific line # in java?

    Hi,
    I have located a keyword in a file using the bufferredreader class (by reading line by line and searching for the keyword).
    This method returns the # of the line that contains the keyword. Say this method return 'n'. I need to pass this information to another method and have it skip the first 'n' lines and start reading from the (n+1)th line.
    I have not found this capability in the Bufferredreader class nor other classes in Java that I looked at. Do you know of any filereader class that does that?
    Note that my intent is to delete the line that contains this keyword. The way I am thinking of right now is to find the line, pass its line # to another method and have that method line (n)th with (n+1)th sequentially to the end of the file. Would you suggest a better way of approaching the problem all together?
    Thanks,
    parachuter2b

    bckrispi is right ! This is a small part of a pretty big server/client program that has to be platform independable as well.
    mchan0 :
    so this is not useful? rather then have the second program re-read, you >could output the rest of the file to a new file without the first n lines?
    java.lang.Object
    java.io.Reader
    java.io.BufferedReader
    readLine
    public String readLine()
    throws IOExceptionRead a line of text. A line is considered to be terminated >by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return >followed immediately by a linefeed.
    Returns:
    A String containing the contents of the line, not including any >line-termination characters, or null if the end of the stream has been >reached
    Throws:
    IOException - If an I/O error occursI need to delete only that one line from the file...so would need to retain the first n-1 lines and (n+1)th till the end of the file.
    cotton.m:
    Note that my intent is to delete the line that
    contains this keyword.
    This actually concerns me more than your current problem.Do you mean there's a better way of going about this problem or something else? sorry ! I don't quite get what you mean.

  • Displaying line items, although not activated in FS00

    Hi everyone!
    I've got a question about line items.
    I had created a GL account, and in it's master record I didn't activated Display line item. But, when I call transaction for displaying GL account's line items (FAGLL03), I can see line items?
    How is that possible?
    I know that there are some special cases, for example expense accounts: for every expense account there is a cost element in CO, and no matter settings in FS00, for expense account there is always line item display. Similary, reconciliation accounts always have open items management, irrespective of settings in FS00.
    But this is just regular account, with very few settings in master record: its balance sheet account, the account currency is local currency, sort key 001 and field status group G001. And that's all.
    Can somebody explaine this?

    Guys. In addition to above my problem.  I was facing this problem due to some graphics issue on my laptop. I was not able to see most of the fields because of Graphics Driver installed on my laptop. ( Later on I got this solution. ).
    This seems very unrealistic to hear but my experience is true.
    I hope in future if some one will have this issue please check out driver compatibility specially Graphics. This problem may suppose to encounter with Dell. 
    Anyways Z layout also worked fine as suggested by Guest FICO.
    Thank you all.
    Regards,
    Sharvari Joshi.

  • Problem in display line items in FS10N

    Hi all,
               I have checked ,check box in G/L account  "Line items display "  in FS00 in current period ( 4 / 2014 )after that line items get displayed in FS10N for this period .
    There is problem in displaying line items for same  G/L account with previous all periods such as 3/2014,2/2014,1/2014.
    I have tried report "RFSEPA01" it works fine if we enter document number for selection with other parameters ,but it gives error if we run report with just Company code and G/L account .
    Please provide any other way to get item details for previous periods or is there any update on report "RFSEPA01".
    Please let me know why this issue occurred, if we activated the line item display for the particular G/L account in between the Posting period
    Thanks,

    Hi,
    You can check below two programs
    RFSEPA01 - for line item display
    RFSEPA02 - for open item display
    Steps to follow:
    1. Block the G/L account from posting
    2. Run both programs
    3. Unblock the G/L account
    this will make the earlier posted items visible.
    Regards,
    Jyoti

  • Error display line items

    Hi Gurus,
    please help me on this error.. what to do?
    No line item display possible for account 41000010 1000
    Message no. F4430
    Diagnosis
    You have determined that displaying line items is not to be possible for G/L account 41000010 in company code 1000.
    Procedure
    It is presumably a clearing account (incoming check account, GR/IR clearing account) which has its own reports for analysis.

    Hi,
    Intally GOTO FS00 and tick the line item display and then GOTO SE38 and give program RFSEPA01 and execute .
    then GIVE co code and GL account number
    Documemt 1-999999999
    hope this solve your problem
    regards,
    Santosh kumar

  • Display line items in Cells of a table- Smartform

    Hello All,
    Can any one help me achieving  the below requirement.
    I have a requirement of printing invoice with a smartform. I am displaying line items from a TABLE node by looping VBRP's internal table. There are 12 cells and the 5 th cell contains a number of Dicount rates.
    I am displaying these discount rates from LOOP node by looping KONV's internal table within that CELL. The 7 th Cell has got 2 values which are required to be: one aligned to the TOP right corner of the cell and the other to the bottom right side of the cell.
    Now the issue description is:
    CELL-5:  Contains unknown number of values for display within the cell to be positioned as MIDDLE justified for an item(POSNR) of the main item table.
    CELL-7: Contains two fixed values :KWERT to be at Top right of the CELL-7and NETWR at the bottom right of CELL-7
    I have managed to display the sub items in CELL-5 in the middle  by giving values to SPACE BEFORE/SPACE AFTER sections of PARAGRAPH FORMAT in SMART STYLE.
    Requirement: Irrespective of number of sub items in CELL-5 the 2 values in CELL- 7 to be aligned as one at the top right and the other  to the bottom right cell flexibly . Same applies to other items(POSNR) of MAIN VBRP item table.
    The ROWS of the MAIN Table to be flexible enough to shrink the space when then are less number of subitems in   CELL-5.
    Values in Cell-7  should be adjusted according to contents in CELL-5.
    Thanks in advance for your valuable suggestions.

    Hi,
    Do one thing while filling the 5th cell , count the number of values(counter) in it for each record and fill new internal table (Itab_cell7) as follws.
    DATA : FLAG,
    counter1 type n.
    DO COUNTER TIMES.
    counter1 = counter1 + 1.
      CLEAR FLAG.
    IF counter = 1.
        WA_CELL7-VALUE = KWERT.
        APPEND WA_CELL7 TO ITAB_CELL7.
        FLAG = 'X'.
    ENDIF.
    IF counter1 =  (counter1 - 1).
        WA_CELL7-VALUE = KWERT.
        APPEND WA_CELL7 TO ITAB_CELL7.
        FLAG = 'X'.
    EXIT.
    ENDIF.
      IF FLAG NE 'X'.
      WA_CELL7-VALUE = ''.
      APPEND WA_CELL7 TO ITAB_CELL7.
    ENDIF.
    ENDDO.
    Adjust the code if need as per your data.
    In cell 7 under loop node print ITAB_CELL7 values in a text. and prepare a paragragh for alingment.
    if it does not work for send me the XML file for your smartform.
    Regards,
    Antim

  • Number of displayed lines in a table

    Hello colleagues,
    We are using a table with a master column (tree). Additional we are using an input field where a user can enter a number so that the displayed lines can be change at runtime.
    Problem:
    I would like to know the displayed number of lines as it is displayed in the button line of the table in the view (where a user can jump direct to a line) - but I do not know how I get it.
    Question:
    How do I get the content of the max number of available lines in the button of the displayed table?
    Thanks+greetings,
    Achim

    Hey Maheswaran.B,
      thanks for the reply - the problem is not solved with the suggestion (because I do not get the maximum number of line displayed).
    I did the following:
    On the very first time if "modifyView" will be executed I do a loop over the table. If the maximum number is reached within the loop I set this number - if not I set the number of loops.
    Here is a code example:
       DO 10 TIMES.
          ADD 1 TO l_counter.
          CLEAR elem_tabletree.
          elem_tabletree = node_tabletree->get_element( index = l_counter ).
          IF elem_tabletree IS  INITIAL.
            SUBTRACT 1 FROM l_counter.
            EXIT.
          ENDIF.
        ENDDO.
    *--- set the value to the bound variable
        elem_owner_node->set_attribute(
          EXPORTING
            name =  `NUMBER_OF_LINES`
            value = item_number_of_lines ).

  • Not able to display line item 20 in contract

    I could not able to display line item 20 in the contract document.
    line item 10 and 30is there however there is no line item 30. What could be reason and how to enable the same.
    MRS

    It may also possible if user forgot to enter the line item 20 and jump to line item 30 after 10 as below.
    Then system will show as like this

Maybe you are looking for