How do I add a line (graphic) as a Component to a JPanel

I'm using swing, and the line-component should be used in the JPanel with plenty of buttons. Therefor it is important that it is as small as possible, with no large background.

The line is just a line from x1,x2 to y1,y2.
The point is that I do not want to use drawLine(), i preferable want to use setBounds, so that I can just add the component to the contentPane like a Jbutton.
I want my class to be a variant of something like this:
public class Line extends JComponent {
int x1,x2,y1,y2;
public Line(int X1,int X2,int Y1,int Y2) {
x1 = X1;
x2 = X2;
y1 = Y1;
y2 = Y2;
public void paint(Graphics g){
super.paintComponent(g);
//g.setColor(Color.white);
//g.fillRect(0,0,getWidth(),getHeight());
// g.drawLine(x1,x2,y1,y2);
}

Similar Messages

  • MaxL script syntax: How do I add comment lines?

    How do I add comment lines to MaxL scripts? REM didn't work, ' didn't work.
    http://download.oracle.com/docs/cd/E10530_01/doc/epm.931/html_esb_techref/maxl/ddl/utils/shell/syntax.htm

    Hmm, a url delimted by "!" on either side is supposed to allow me to embed a graphic.
    Apparently I am to stupid/impatient/all of the above to figure that out, so check out a code sample from my blog (I am on a roll today with references to this beast) to see what it looks like: Regards,
    Cameron Lackpour                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How can I add a line item to delivery?

    Hi all,
    How can I add a line item in a delivery without using BDC?
    Regards!
    Curtis

    Hi,
    I have tried
    BAPI_OUTB_DELIVERY_CHANGE
    and this only allows you to change existing lines not add lines.
    Since its outboud delivery that I'm interested in I will not look at the inbound that you suggested.
    Any other suggestions would be appreciated.
    Regards!
    Curtis

  • How do I add PO line item to incomplete log procedure

    Hi SD Experts,
    How do I add PO line item to incomplete log procedure for VA02? Is that possible through configuration and/or code? if it is done by code, what userexit or BAdI I need to implement?
    Thanks,
    Duy

    Hi Duy,
    You need to go to SD > Basic functions > log of incomplete items > define incomplete procedure > select group A (sales header) > procedures > select 11 (Sales order) > fields tab and add PO number incompletion fields as below:
    table---field namedescriptionscreen--status--warning
    VBKD---BSTKDPO number-KBES     -
    0----
    X
    Finally, you should assign your incompletion procedures to your sales doc. typ.
    I hope these will work.
    Regards,

  • How can i add a line separator on Dreamweaver?

    Hi
    How can i add a line separator on Dreamweaver?
    Thanks

    Do you mean a Horizontal Rule (the <hr/> tag)?
    Click where you want it to appear and go to Insert > Horizontal Rule, or drag and drop from the Common heading of the Insert window.
    If that's not what you're talking about, could you be a bit more descriptive as to what you are trying to accomplish?

  • How can I add a line but keep the number I have from tmobile

    How can I add a line but keep the number I have from Tmobile

    Hi, Janice!
    I'm just guessing, but I imagine you'd get your question answered faster in the AE forum.

  • How do i add multiple lines in a cell (like a list) in Excel for MAC?

    I'm trying to add multiple lines (in the form of a list) in a individual cell in Excel for MAC.  I used ALT Enter on my PC but that doesn't work on the iMac.  Does anyone know how to do this?
    Thanks!

    It's been a while but I think you hold SHIFT while typing a page break (RETURN) to make a new line without shifting to another cell.
    However, as Excel isn't an Apple product, I am sure you will get a faster and more current answer by using Microsoft's Office:Mac forums here:
    Office for Mac forums
    They are very good.

  • How do I add multiple lines to a cell

    I am trying to create an assignment sheet in Numbers. I am using the "Schedule" template. Under each day of the week, I want to add daily assignments. But each assignment may need multiple lines. In the screenshot below, I want to add another line under "Genesis 5" but still have it within the same cell. How can I do that?

    I do extensive research  build on the work of others

  • How can I add a line to my CSS file to have all TextArea fields show PRE

    Hi,
    I would like all my TextAreas to show the text as it was inserted into the database... with the new lines, tabs, etc...
    I would like to add a line to my CSS file to do this if possible.
    Thanks, Bill :>)

    Thanks for all the input!
    Fab. You have been talking about a report the whole time... I have been talking about one Database ITEM that is "Displayed as Text".
    In a report the replace() always works in all browsers I believe... and I had no problem.
    BUT, in a text ITEM I wasn't able to get anything to work..
    So, I created a report region and retieved this one column (item) and selected a borderless region and it is fine...
    select     replace(LAST_ACTION,chr(10),'<BR>') "LAST_ACTION"
    from     "HT_ISSUES" "HT_ISSUES"
    where issue_id = :P7_ISSUE_ID
    I still would like to know how to Display as Text - as it is in the DB.
    When have a Dispay as Text Item and I view Source when running the page.. it is correct in the source delivered to the browser but displays all one line.
    (I save a SQL statement to the field)
    [tr>[td  colspan="6" rowspan="6" align="left">[span class="t3NoLabel">Last Action Item[/span> [br>Maintenance Issue - SELECT *
    FROM (SELECT ROWNUM row_num, empno, ename, job, mgr,
    hiredate, sal, comm, deptno
    FROM emp)
    WHERE row_num BETWEEN NVL (:p7_row_from, 1)
    AND NVL (:p7_row_to, 1000000)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How do i add a line to header on a template

    I created a template and on that template i want a line to print before and after the heading. How do i add this. I see i have access to change the fonts, and the colors, but not how i can add something into this area.
    Help

    Since Entourage is not an Apple product, you should consider posting your question on Microsoft's own forums for Entourage as they would be geared more toward the issue than an Apple forum for Apple's own Mail and Address Book applications:
    http://www.officeformac.com/productforums
    You may also want to search the Entourage Help Page to see if it's covered there:
    http://www.entourage.mvps.org/

  • Hi Sir! I have some questions regarding word report generation please.1.How can i add border to a word page?.2.How can i add grid lines to a table generated in word report?.3.How can i add border to a table of word report?.Thanks Imran Pakistan

    Hi !
    Sir I have some questions regarding word report generation using(C language in labwindows) Please.
    1.How can i add border to a word page?.
    2.How can i add border and grid lines to a table generated in word report(Not the " cvi table control" inserted from gui,i am asking about the table generated in word report)?
    3.How can i fill a cell of word report table withe the data type other than "character"?.
    And sir one question about use of timer in cvi labwindows please.
    Sir i'm trying to set minimum delay interval of timer control to 1millisecond(0.001s),as i set ,timer don't cares of the interval that is set by me it responds only to the default minimum time interval which is i think 10milliseconds(i'am using windows xp service pack3 version 2002).
    Regards
    Imran
    Pakistan
    Solved!
    Go to Solution.

    Hello sir!
    Sir i'm using daq6251.But Sir before implimenting it to my final application now i'm just trying to achieve 1millisecond time interval for timer in a vary simple programe i mean at this time no hardware (daq device) is  involved i,m just trying to achieve minimum time interval of 1millisecond.
    Sir i read form "help" of labwindows how this time interval can be set,i'm trying for,as described in help notes but i could'nt.I'm attaching a screen shot sir for you it may helpful for you to explain me.
    And sir also waiting for your kind reply regarding word report generation.
    Thanks.
    Imran.
    Attachments:
    screen_shot_rigistry.docx ‏65 KB

  • HT202879 how do i add a line to the top and bottom of a text box only

    i have a text box in my Pages document but i need to be able to add a line tot he top and bottom only to my text box. can i pleae get some help.

    Hello alegna23,
    To add a line just to the top and bottom of a text box, you will need to add the two lines as shapes.  Follow the steps below to add a line to your document:
    Add a shape
    Click Shape in the toolbar.Click the arrows to see more shape styles.
    Select a shape to add it to the page.
    In step 2, select a line and use the squares on the end of the line to help resize the line.  You can find the full article here:
    Pages Help for Mac - Add and edit shapes
    http://help.apple.com/pages/mac/5.0/#/tan9ad18c384
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • How do I add custom style to custom AS3 component via .css file?

    Hi all,
    I have created a flex application which displays a custom component I created in actionscript. My custom component is just an extended canvas component which displays a gradient background. When I add the component to my flex app, see code below, the component works great.
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:ns1="http://localhost/mycomps">
        <ns1:GradientCanvas fillColors="[#ffffff, #000000]" />
    </mx:Application>
    However, I also want to support css styles to add the gradient colors to my component, like so
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:ns1="http://localhost/mycomps">
        <mx:Style source="test.css" />
        <ns1:GradientCanvas styleName="gradientCanvas" />
    </mx:Application>
    test.css
    .gradientCanvas {
        fill-colors: #ffffff, #000000;
    When I try this my component doesn't display a gradient. I have followed the tutorials online that I could find but it seems to be the same example from Adobe repeated on multiple site and it doesn't work.
    My component code is added below, if anyone could show me how to get this to work it would be much appreciated.
    Thanks in advance,
    Xander
    GradientCanvas.as
    package mycomps {
        import flash.display.GradientType;
        import flash.geom.Matrix;
        import mx.containers.Canvas;
        import mx.styles.CSSStyleDeclaration;
        import mx.styles.StyleManager;
        public class GradientCanvas extends Canvas {
            private static var classConstructed:Boolean = constructStyle();
            public function GradientCanvas() {
                super();
                this.width = 100;
                this.height = 20;
            private static function constructStyle():Boolean {
                var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration("GradientCanvas");
                if (style) {
                    if (style.getStyle("fill-colors") == undefined) {
                        style.setStyle("fill-colors", [0xffffff, 0x000000]);
                } else {
                    style = new CSSStyleDeclaration();
                    style.defaultFactory = function():void {
                        this._fillColours = [0xffffff, 0x000000];
                    StyleManager.setStyleDeclaration("GradientCanvas", style, true);
                return true;
            override public function styleChanged(styleProp:String):void {
                super.styleChanged(styleProp);
                if (styleProp == "fill-colors") {
                    this._fillColours = getStyle("fill-colors");
                    this._fillColoursChanged = true;
                    this.invalidateDisplayList();
            override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
                super.updateDisplayList(unscaledWidth, unscaledHeight);
                if (this._fillColoursChanged == true) {
                    var direction:Number = 90 * (Math.PI / 180);
                    var matrix:Matrix = new Matrix();
                    matrix.createGradientBox(unscaledWidth, unscaledHeight, direction, 0, 0);
                    graphics.clear();
                    graphics.beginGradientFill(GradientType.LINEAR, this._fillColours, [1,1], [0, 255], matrix, "pad", "rgb", -1);
                    graphics.drawRect(0, 0, unscaledWidth, unscaledHeight);
                    graphics.endFill();
                    this._fillColoursChanged = false;
            [Inspectable(category="Gradient", type="Array", format="Color", name="Fill Colours")]
            private var _fillColours:Array;
            private var _fillColoursChanged:Boolean = false;
            public function get fillColours():Array {
                return this._fillColours;
            public function set fillColours(value:Array):void {
                this._fillColours = value;
                this._fillColoursChanged = true;
                this.invalidateProperties();
                this.invalidateDisplayList();

    Never mind, I've discovered how to do it for myself.
    Thanks...

  • Acrobat 9 Mac- Forms-how do I add multiple lines?

    I created a document cover in Quark and saved it as a PDF.(I'm on a Mac)
    The idea is for the client (on a PC) to open the document in Acrobat
    and add a few lines for a heading. I think I figured out how
    to add a text box form, but it only allows for ONE line of text.
    I know some of their document headings will require 2 -3  lines.
    How is this done? And is this the best method for giving the client something they
    can "add to" and print out? PLease advise.  I have looked thru the Help menus
    and community support,  but did not find an answer. thanks.

    You can set a text box to be multiline. Right-click it using the Select Object Tool and look under Properties.

  • How to dynamically add new line series to the line chart in flex?

    i need to add line series dynamically..and each line  series should have a different data provider...

    A chart can have only 1 dataProvider which in my case is an ArrayCollection.
    The chart will update every time the dataProvider changes if you use binding.
    So you have to write a function that periodically populates the ArrayCollection with data from the server and the chart will update automatically.
    'Using line charts' tutorial from Adobe: http://livedocs.adobe.com/flex/3/html/charts_types_08.html#243339

Maybe you are looking for

  • Design the New process set up for Materials in one physical stock plant

    Hi Experts, The requirement is one physical plant as two different logical plants in the system. The main issue is how to administrate or how to find the set up which allows one Physical warehouse in Hamburg which we have supplying two Logical wareho

  • My itunes wont work after update

    my itunes wont work after update. whats the problem.

  • Form in Find Mode

    Hai, After matrix is loaded the "Add" button changes to Find mode. I need "Add" button to be in "Add" mode after the data gets loaded into the matrix. when i click any row in the matrix button should change to update mode automaticall as SAP Businees

  • Application crashes on starting from one path but works from another path

    We have an odd problem.  A small application is deployed to a handful of users. The PB11.5 version has been running successfully for years on XP and then a year on Win7. It was recently migrated to PB12.5 and redeployed. It is a simple deployment - E

  • How to Generate XML Output file

    Hi, I want to print sample output XML file. I got this link 362496.1 An output file can be generated via the Preview functionality available under the XML Publisher Administrator responsibility. Navigation path : 1. Login to the application as SYSADM