How to fill canvas with lines

<mx:Canvas id="b1" x="10" y="10" height="40" width="300" borderStyle="solid" borderColor="black"/>
when i want to draw lines with 15 pixels gap to fill the entire canvas i wrote as follows
               for(var i:int=b1.x+15;i<b1.x+b1.width;i=i+15)
                    var line1:UIComponent = new UIComponent();
                    var lineThickness1:Number = 1;
                    var lineColor1:Number = 0x000000;
                    var lineAlpha1:Number = 1;
                    line1.graphics.lineStyle(lineThickness1,lineColor1,lineAlpha1);
                    line1.graphics.moveTo(i,b1.y);
                    line1.graphics.lineTo(i,b1.y+b1.height);
                    this.addChild(line1);
it's working fine
lly,
<mx:Canvas id="b4" x="600" y="200" height="60" width="300" borderStyle="solid" borderColor="black" rotation="40"/>
I have the above canvas with id 'b4' only difference is that this canvas has the rotation
how to fill this canvas with lines just i did above?

Hope this code will help you,
for(var i: int = 15; i < b4.width; i = i + 15) {
     var line1: UIComponent = new UIComponent();
     var lineThickness1: Number = 1;
     var lineColor1: Number = 0x000000;
     var lineAlpha1: Number = 1;
     line1.graphics.lineStyle(lineThickness1, lineColor1, lineAlpha1);
     line1.graphics.moveTo(i, 0);
     line1.graphics.lineTo(i, b4.height - 1);
     //Add line in canvas instead of main container
     b4.addChild(line1);
<mx:Canvas id="b4" x="600" y="200" height="60" width="300" borderStyle="solid" borderColor="black" rotation="40"/>

Similar Messages

  • How to fill tabs with textures?

    Hi all,
    I wondering how to fill tabs with textures, just like in the "Personal Budget" template.
    I mean this:
    How could I replicate this nice effect? Please help!
    I already read the user manual but I won't be able to find a solution...

    One way is to open the template and select the table with the fill pattern.  Open the table inspector
    highlight the Image fill cell (in the "Cell Background" section).  Copy.
    Now open the application Preview in the Applications folder.  Select the menu item "File > New From Clipboard" to create a new document with the image you copied.  Now save the image as a pdf using the menu item "File > Save..."
    Save it with a name you can remember in a location of your choice.
    Now select a table in some other Numbers document and set the table background to the image you just saved by using the Table Inspctor:

  • How to fill field with test data in alv grid display

    hi all,
    i m adding field TEXT to the structure for displaying grid.
    i m modifying program like this
    DATA: ALV_OUTPUT  LIKE HRPDV_EXPIRED_Q OCCURS 0 WITH HEADER LINE.
    TYPES : BEGIN OF FS_OUTPUT .
          TEXT(20) TYPE C.
            INCLUDE STRUCTURE HRPDV_EXPIRED_Q.
    TYPES       TEXT(20) TYPE C.
    TYPES    END OF FS_OUTPUT.
    DATA: fs_output like table of alv_output.
    CLEAR WA_FIELDCAT.
      WA_FIELDCAT-FIELDNAME = 'TEXT'.
      WA_FIELDCAT-seltext_l = 'Abteilungs Struktur'.
      wa_fieldcat-tabname   = 'ALV_OUTPUT'.
      WA_FIELDCAT-COL_POS  = '13'.
      APPEND WA_FIELDCAT TO P_GT_FIELDCAT.
    this is what i have write for diapalying field. but my question is how to fill test data with field TEXT.I m writing like this but not executed in the aboove grid dispaly statement.
    loop at alv_output.
    *alv_output-text(20)  = 'abcdefgh'.
    *modify alv_output.
    *endloop.
    plz tell me how to fill test data

    hI..,
    Your table declaration has to be like this..
    TYPES : BEGIN OF FS_OUTPUT .
    INCLUDE STRUCTURE HRPDV_EXPIRED_Q.
    TYPES TEXT(20) TYPE C.
    TYPES END OF FS_OUTPUT.
    DATA: ALV_OUTPUT LIKE standard table of fs_output initial size 0.
    loop at alv_output <b>into fs_output</b>.
    <b>fs</b>_output-text(20) = 'abcdefgh'.
    <b>modify alv_output index sy-tabix from fs_output transporting text.</b>
    endloop.
    Now give this table alv_output to the GRID_DISPLAY function module..
    you will get the required output !!
    Plz do remember to close the thread when ur problem is solved !!
    reward all helpful answers !!
    regards,
    sai ramesh

  • Fill page with lines

    Post Author: RedAle
    CA Forum: General
    Hi,I'm using CR XI r2.I need to design e report with the CR XI Designer tool. In my report I have a DB table with some rows (about 10) linked to my report. Every detail section row has a table field and a Line. I would like to repeat this line to fill the entire page and not only for the number of table records.Does anybody knows how can I do it? Thank you in advanceAlessandro Rossi.

    Post Author: V361
    CA Forum: General
    Hope this will help.... Stolen from another post.
    Assuming that you have your report setup in such a way as to go to the next page when the record count is greater than 15, here is a way to 'draw' lines so that there are always 15 on a page.
    1. Create a sub-report with lines drawn such that if the subreport were displayed then the lines would match with those of the main report.
    2. In the subreport, suppress all sections except the detail.
    3. Create a formula with:
    whileprintingrecords;
    shared numbervar rc;
    if rc <= 15 then
    replicatestring('_______________' & chrw(13) & chrw(13),(15 - rc));
    where rc is your recordcount based upon which you go to next page. The string within the 'replicatestring' will be the lines you want to draw to make up the 15 rows.
    4. Place the subreport in a separate details section and suppress it based on conditions such that it is only displayed if there are less than 15 records displayed per page.

  • How to fill areas with Fireworks CS4?

    How can I fill areas created with a pen tablet in more than
    one layer with Fireworks CS4?
    I need to fill areas created with vector path tool divided in
    more layers like a raster image but without converting strokes to a
    raster image.
    For example hair of a man...
    Do you know a trick or a tecnique?

    arcadiaclub.com wrote:
    > Ok this is an example... I need a trick or tecnique to
    fast (because I am
    > creating a long animation) fill areas with strokes
    placed in different layers...
    >
    >
    http://www.arcadiaclub.com/img/zup/scena_1.png
    >
    > I need to fill all hairs (front and back) in one time,
    clothes in one time and
    > so on...
    >
    Is there a reason each path is it's own object? Do they have
    to remain
    this way?
    If they don't, you can select the paths that make up the
    different areas
    and try using Modify > Alter Path > Join or Modify
    > Alter Path >
    Union. You will probably need to remove some anchor points if
    you choose
    one of these options.
    Are you aware of the Vector path tool which let's you draw a
    path
    freehand? That might be a better option than the Pen tool.
    Jim Babbage - .:Community MX:. & .:Adobe Community
    Expert:.
    http://www.communityMX.com/
    CommunityMX - Free Resources:
    http://www.communitymx.com/free.cfm
    .:Adobe Community Expert for Fireworks:.
    Adobe Community Expert
    http://tinyurl.com/2a7dyp
    .:Author:.
    Lynda.com -
    http://movielibrary.lynda.com/authors/author/?aid=188
    Peachpit Press -
    http://www.peachpit.com/authors/bio.aspx?a=d98ed798-5ef0-45a8-a70d-4b35fa14c9a4
    Layers Magazine -
    http://www.layersmagazine.com/author/jim-babbage

  • How to send string with line feed to Agilent 33250A via COM1

    Agilent 33250A is a function generator. In HPERTERMINAL, when "Send line ends with line feeds" is enabled, simple strings make it work well, such as: "APPLQU", "OUTPUT ON", etc...
    But I can't make it work with .vi file. COM setting is correct because 33250A shows "remote" icon immediatly after string sent. It will respon "error" to any mismatched setting (e.g. 9600 vs 115200). So, the connection is there but it just doesn't respond to commands.
    I don't know why. The termination character is enabled in .vi
    I apprecite your help to make the .vi to send string just like the HYPERTERMINAL with 'line feeds'.
    Thank you very much.
    Jian
    Attachments:
    Serial_Communication.vi ‏40 KB
    Write2COM1.vi ‏22 KB

    From what I can see it looks like you are NOT specifying what termination character you want to use when you call the serial port init.
    When not otherwise specified, the port will be configured to use the default termination character which is a "carrige return" HEX 0A.
    Try wiring a "Line Feed" constant to the init VI.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • JTextField: How to fill it with a "number" instead of with "text"

    Hi everybody,
    I want to fill a JTextField variable with "something" that is actually a number (an int variable). How could I do it? I can not cast from int into string...
    Thanks a lot!
    Fran.

    Hi,
    I've implemented number fields based on JFormattedTextField. Maybe you find them usefull (the library is Open Source):
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JRealNumberField.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JDoubleField.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JFloatField.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JLocalizedRealNumberField.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JLocalizedDoubleField.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JLocalizedFloatField.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JWholeNumberField.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JByteField.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JIntegerField.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JLongField.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JShortField.html
    Tutorial:
    http://softsmithy.sourceforge.net/lib/docs/tutorial/swing/number/index.html
    Homepage:
    http://www.softsmithy.org
    Download:
    http://sourceforge.net/project/showfiles.php?group_id=64833
    Source:
    http://sourceforge.net/svn/?group_id=64833
    http://softsmithy.svn.sourceforge.net/viewvc/softsmithy/trunk/lib/src/org/softsmithy/lib/
    API:
    http://softsmithy.sourceforge.net/lib/docs/api/index.html
    If you want to use the fileds in a table have a look at the source code of JXTable:
    http://softsmithy.svn.sourceforge.net/viewvc/softsmithy/trunk/lib/src/org/softsmithy/lib/swing/JXTable.java?view=markup
    If you want you can use it or one of its subclasses (JCellTable, JPropertyTable) and set the default editors.
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JXTable.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/DoubleCellEditor.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/FloatCellEditor.html
    -Puce

  • How to fill matrix with the output of recordset query?

    Hi all,
    I want a user matrix to load data when I hit a button and the data to be filled is the output of an sql query. binding the matrix columns with table columns and then load the matrix with DBDatasource attached to that table will not do in this case as the columns in the sql query are from several different tables or views. 
    writing following line to do this takes several minutes to load the data:
    For j = 0 To Reordset.RecordCount - 1
    Matrix.AddRow()
    Matrix.Columns.Item("col1").Cells.Item(i).Specific.value =  Recordset.Fields.Item("cardcode").Value
    Recordset.movenext()
    next
    Is there any other way to fill the matrix in this case, which loads the data faster?
    Regards,

    Hello Binita,
    I've tested the CFL for DataTable-Matrixes in my test-AddOn. But there's still one problem left. Maybe you find it out (I will need this in the future too...).
    The ChooseFromList must be added behind the DataTable-Bind, which is done on every MTX-Load (it's not from the sample above, so the UIDs are new ones):
                oDt = oDts.Item("dt_test")
                query = "SELECT  * FROM [@T_CONVTOOLS01]"
                oDt.ExecuteQuery(query)
                oMtx.Columns.Item("0").DataBind.Bind("dt_test", "Code")
                oMtx.Columns.Item("1").DataBind.Bind("dt_test", "U_Alpha01")
                oMtx.Columns.Item("2").DataBind.Bind("dt_test", "U_Price01")
                oMtx.Columns.Item("3").DataBind.Bind("dt_test", "U_Quant01")
                oMtx.Columns.Item("4").DataBind.Bind("dt_test", "U_Date01")
                AddChooseFromLists()
                oMtx.LoadFromDataSource()
    ...where AddChooseFromLists() is...
      Private Shared Sub AddChooseFromLists()
            Try
                Dim oCfls As SAPbouiCOM.ChooseFromListCollection
                Dim oCons As SAPbouiCOM.Conditions
                Dim oCon As SAPbouiCOM.Condition
                Dim oCfl As SAPbouiCOM.ChooseFromList
                Dim oCflCreationParams As SAPbouiCOM.ChooseFromListCreationParams
                Dim oBtn As SAPbouiCOM.Button
                Dim oMtx As SAPbouiCOM.Matrix
                Dim oCol As SAPbouiCOM.Column
                Dim oEtx As SAPbouiCOM.EditText
                oMtx = oForm.Items.Item("MTX_TEST02").Specific
                oCfls = oForm.ChooseFromLists
                oCflCreationParams = SboCon.SboUI.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_ChooseFromListCreationParams)
                oCflCreationParams.MultiSelection = False
                oCflCreationParams.ObjectType = SAPbouiCOM.BoLinkedObject.lf_BusinessPartner
                oCflCreationParams.UniqueID = "CFL_C1"
                oCfl = oCfls.Add(oCflCreationParams)
                '### OPTION:
                '# Shown ChooseFromList restricted by Conditions
                oCons = oCfl.GetConditions()
                oCon = oCons.Add()
                oCon.Alias = "CardType"
                oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL
                oCon.CondVal = "C"
                oCfl.SetConditions(oCons)
                oCol = oMtx.Columns.Item("1")
                oCol.ChooseFromListUID = "CFL_C1"
                oCol.ChooseFromListAlias = "CardCode"
            Catch e As Exception
                Microsoft.VisualBasic.MsgBox(className & ".AddChooseFromLists()" & vbCrLf & "Exception:" & vbCrLf & e.Message.ToString)
            End Try
        End Sub
    But I'm running into problems when trying to set the MTX-Cell via DataTable at the CFL-Event (see comment):
                If pVal.EventType = SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST Then
                    Dim oMtx As SAPbouiCOM.Matrix
                    Dim oCFLEvent As SAPbouiCOM.IChooseFromListEvent
                    Dim oCFL As SAPbouiCOM.ChooseFromList
                    Dim oDataTable As SAPbouiCOM.DataTable
                    Dim cflID As String
                    Dim oDt As SAPbouiCOM.DataTable = oForm.DataSources.DataTables.Item("dt_test")
                    oCFLEvent = pVal
                    cflID = oCFLEvent.ChooseFromListUID
                    'Dim oForm As SAPbouiCOM.Form
                    'oForm = SboConnection.SboUI.Forms.Item(FormUID)
                    oCFL = oForm.ChooseFromLists.Item(cflID)
                    If Not oCFLEvent.BeforeAction Then
                        oDataTable = oCFLEvent.SelectedObjects
                        If oDataTable Is Nothing Then Exit Sub
                        '############## Matrix Test #######################################################################
                        If (oCFLEvent.ItemUID = "MTX_TEST02") Then
                            oMtx = oForm.Items.Item("MTX_TEST02").Specific
                            '### CFL Results to UserForm
                            oDt.Rows.Offset = oCFLEvent.Row - 1
                            MsgBox(oDt.GetValue("U_Alpha01", oCFLEvent.Row - 1))
                            MsgBox(oDataTable.GetValue("CardCode", 0))
                            ' PROBLEM - can't get this working - don't know at the moment:
                            ' on other forms SetValue works....
                            oDt.SetValue("U_Alpha01", oCFLEvent.Row - 1, oDataTable.GetValue("CardCode", 0))
                            ' this also gives me problems...:
                            'oMtx.Columns.Item("1").Cells.Item(oCFLEvent.Row).Specific.value = oDataTable.GetValue("CardCode", 0)
                            oForm.Update()
                        End If
                    End If
                End If
    The CFL-Form opens and returns the choosen value(s) at the CFL-event. But writing to MTX still not works with this code...
    Maybe you find the last piece. If so: please write here.
    Cheers,
    Roland
    p.s.:
    David Nussböck wrote
    LOL - ROLAND WAS FASTER ))
    ...just one minute...

  • How to fill array with random number?

    I need to fill a 3-dimensional array that has user-controlled dimension sizes with random numbers (1-10). I'm unsure of how to do this. I feel like I have to use the initialize array and maybe the build array functions somehow but I'm not entirely sure. Any help would be appreciated. Thanks.

    Something like this
    Kudos are always welcome if you got solution to some extent.
    I need my difficulties because they are necessary to enjoy my success.
    --Ranjeet
    Attachments:
    Array with random number.vi ‏9 KB

  • HOW WE FILL CR WITH TABLEADAPTER INSTEDS OF DATAADAPTER

    HELLO DEAR, CAN YOU HELP ME, I WANT FILL CRYSTAL REPORT WITH TABLEADAPTER IN STED OF DATAADAPTER IN VB 2008, WITH DATAADAPER IT DO IT NORMAILY IT WORKS FINE, BUT WHEN I CREATE DATATABLE WITH UNION QUERY (FOR UNPIVOT DATA) THEN IT NOT SHOW ALL DATA (LIKE WHICH DATA I UNPIVOT), SAME HAPPEND IN REPORT.RDLS WHEN I TRY WITH DATAADAPTER, BUT IT WORK WITH TABLEADAPTER IN REPORT.RDLS, SO I THINK THAT I WILL TRY WITH TABLEADAPTER INSTED OF DATAADAPTE, MY CODE AS BELOW WHICH I USE WITH DATAADAPTER,
    Imports System.Data
    Imports System.Data.OleDb
    Imports WindowsApplication1.OledbTableAdapter
    Imports WindowsApplication1.MasterDataSetTableAdapters
    Public Class OledbTableAdapter
    End Class
    Module Module1
        Public Cnn As New OleDbConnection
        Public Cmd As New OleDbCommand()
        Public Dr As OleDbDataReader
        Public Mcmd As New OleDbCommand()
        Public mDr As OleDbDataReader
        Dim myAdapter As New System.Data.SqlClient.SqlDataAdapter
        Public data As New Data.DataSet
        Public ds As New DataSet
        Public CusSearch As String 'Search Customer
        Public da As New OleDbDataAdapter
        Public DTT As New MPatient1TableAdapter
        Public dt As New DataTable
        Public conn As New OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\MASTER.accdb")
        Public adp As New OleDbDataAdapter(Cmd)
        Public Sub OpenConnect()
            Try
                Cmd.Connection = conn
                conn.Open()
                Cmd.CommandType = CommandType.Text
                Mcmd.Connection = conn
                conn.Open()
                Mcmd.CommandType = CommandType.Text
            Catch ex As Exception
                ' MsgBox(ex.Message)
            End Try
    Public Class Form2
        Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        End Sub
        Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load
            Dim report As New CrystalReport1
            dt.Clear()
            If form1.TextBox3.Text <> "" Then
                Cmd.CommandText = "Select * from  [Final_Report] where LabNo ='" & form1.TextBox3.Text & "'"
                OpenConnect()
                da.SelectCommand = Cmd
                da.Fill(dt)
                report.SetDataSource(dt)
                CrystalReportViewer1.ReportSource = report
                CrystalReportViewer1.Show()
            End If
        End Sub
    End Class

    What's the error?
    BE wary of the amount of data in a DataSet, 5000 rows could be max but it all depends on the number of columns.
    Stick with using the Database direct connection rather than using Datasets. DS's use a lot of memory and limited.
    If you don't want to use a direct connection then save your data as a XML file.
    Search, I've posted code on how to do this.
    Don

  • How to fill shape with pattern... and cut outline?

    I have an old plotter that works great for making drawings. I can fill a shape with a pattern, convert the pattern to outlines (or strokes) BUT my problem is that the outline of the original shape remains, and this will be plotted. I do not want an outline of the original shape, I want the pattern to create the shape. Any ideas? Also, shape stroke remains part of the art (even if stroke = none before object/expand/ungroup/divide)

    aha!
    made scribble
    expanded scribble
    put shape in front
    select all, ctrl+7 (masked scribble to shape)
    pathfinder/crop
    solved. thanks! sishamDSS!

  • How connect dragable labels with line

    When I load the program labels will appear within the window. You can ckick
    and drag these labels. The code for this
    is very simple. The code works perfectly. However I want to extend my code to do
    the following :
    (1) I want to add an extra label .. it does not matter where on the screen
    [ JLabel label = new JLabel() ]
    (2) When I press this button I want a line to appear between the two
    moveable labels ( ie the two labels are joined together by the line)
    (3)Now here is the hard part.. Whenever I move either of the two labels
    the line stretches so that the two labels are still connected.
    start--->
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import javax.swing.border.*;
    public class Connection
    public static void main(String[] args)
    JFrame f = new JFrame("Connection");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(new ConnectionPanel());
    f.setSize(400,300);
    f.setLocation(200,200);
    f.setVisible(true);
    class ConnectionPanel extends JPanel
    JLabel label1, label2, label3, label4;
    JLabel[] labels;
    JLabel selectedLabel;
    int offsetX, offsetY;
    boolean dragging;
    public ConnectionPanel()
    setOpaque(false);
    setLayout(null);
    addLabels();
    addMouseListener(new LabelSelector());
    addMouseMotionListener(new LabelMover());
    public void paintComponent(Graphics g)
    Graphics2D g2 = (Graphics2D)g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
    RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setPaint(Color.white);
    g2.fillRect(0, 0, getWidth(), getHeight());
    g2.setPaint(Color.blue);
    Point
    p1 = getCenter(label1),
    p2 = getCenter(label2),
    p3 = getCenter(label3),
    p4 = getCenter(label4);
    g2.draw(new Line2D.Double(p1.x, p1.y, p2.x, p2.y));
    g2.draw(new Line2D.Double(p1.x, p1.y, p3.x, p3.y));
    g2.draw(new Line2D.Double(p1.x, p1.y, p4.x, p4.y));
    g2.draw(new Line2D.Double(p2.x, p2.y, p3.x, p3.y));
    g2.draw(new Line2D.Double(p2.x, p2.y, p4.x, p4.y));
    g2.draw(new Line2D.Double(p3.x, p3.y, p4.x, p4.y));
    super.paintComponent(g);
    private Point getCenter(JComponent c)
    Rectangle r = c.getBounds();
    return new Point((int)r.getCenterX(), (int)r.getCenterY());
    private class LabelSelector extends MouseAdapter
    public void mousePressed(MouseEvent e)
    Point p = e.getPoint();
    for(int i = 0; i < labels.length; i++)
    Rectangle r = labels.getBounds();
    if(r.contains(p))
    selectedLabel = labels[i];
    offsetX = p.x - r.x;
    offsetY = p.y - r.y;
    dragging = true;
    break;
    public void mouseReleased(MouseEvent e)
    dragging = false;
    private class LabelMover extends MouseMotionAdapter
    public void mouseDragged(MouseEvent e)
    if(dragging)
    int x = e.getX() - offsetX;
    int y = e.getY() - offsetY;
    Rectangle r = selectedLabel.getBounds();
    selectedLabel.setBounds(x, y, r.width, r.height);
    repaint();
    private void addLabels()
    int w = 125;
    int h = 25;
    Border border = BorderFactory.createEtchedBorder();
    label1 = new JLabel("Label 1", JLabel.CENTER);
    label2 = new JLabel("Label 2", JLabel.CENTER);
    label3 = new JLabel("Label 3", JLabel.CENTER);
    label4 = new JLabel("Label 4", JLabel.CENTER);
    labels = new JLabel[4];
    labels[0] = label1; labels[1] = label2; labels[2] = label3; labels
    [3] = label4;
    for(int i = 0; i < labels.length; i++)
    labels[i].setBorder(border);
    labels[i].setOpaque(true);
    labels[i].setBackground(Color.white);
    add(labels[i]);
    label1.setBounds(40, 40, w, h);
    label2.setBounds(215, 40, w, h);
    label3.setBounds(40, 200, w, h);
    label4.setBounds(215, 200, w, h);
    end-->
    In this code: How to add labels when to me it is necessary
    (From menu: add new label)?

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.Line2D;
    import javax.swing.*;
    import javax.swing.event.MouseInputAdapter;
    public class Connection
        ConnectionPanel connectionPanel;
        LabelWrangler wrangler;
        public Connection()
            connectionPanel = new ConnectionPanel();
            wrangler = new LabelWrangler(connectionPanel);
            connectionPanel.addMouseListener(wrangler);
            connectionPanel.addMouseMotionListener(wrangler);
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(getUIPanel(), "North");
            f.getContentPane().add(connectionPanel);
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
        private JPanel getUIPanel()
            JButton add = new JButton("add label");
            add.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    wrangler.willAcceptLabel = true;
            JCheckBox lineBox = new JCheckBox("show lines");
            lineBox.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    connectionPanel.showConnectionLines();
            JPanel panel = new JPanel();
            panel.add(add);
            panel.add(lineBox);
            return panel;
        public static void main(String[] args)
            new Connection();
    class ConnectionPanel extends JPanel
        boolean showConnections;
        int labelCount;
        final int
            N  = 2,
            NW = 3,
            W  = 1,
            SW = 9,
            S  = 8,
            SE = 12,
            E  = 4,
            NE = 6;
        public ConnectionPanel()
            showConnections = false;
            labelCount = 0;
            setLayout(null);
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            if(showConnections)
                Component[] c = getComponents();
                Rectangle r1 = new Rectangle();
                Rectangle r2 = new Rectangle();
                for(int j = 0; j < c.length - 1; j++)
                    c[j].getBounds(r1);
                    for(int k = j + 1; k < c.length; k++)
                        c[k].getBounds(r2);
                        Point p1 = getClosestPoint(r1, r2);
                        Point p2 = getClosestPoint(r2, r1);
                        g2.draw(new Line2D.Double(p1.x, p1.y, p2.x, p2.y));
        private Point getClosestPoint(Rectangle r1, Rectangle r2)
            double cx = r2.getCenterX();
            double cy = r2.getCenterY();
            Point p = new Point();
            int outcode = r1.outcode(cx, cy);
            switch(outcode)
                case N:
                    p.x = r1.x + r1.width/2 - 1;
                    p.y = r1.y;
                    break;
                case NW:
                    p.x = r1.x;
                    p.y = r1.y;
                    break;
                case W:
                    p.x = r1.x;
                    p.y = r1.y + r1.height/2 - 1;
                    break;
                case SW:
                    p.x = r1.x;
                    p.y = r1.y + r1.height - 1;
                    break;
                case S:
                    p.x = r1.x + r1.width/2 - 1;
                    p.y = r1.y + r1.height - 1;
                    break;
                case SE:
                    p.x = r1.x + r1.width - 1;
                    p.y = r1.y + r1.height - 1;
                    break;
                case E:
                    p.x = r1.x + r1.width - 1;
                    p.y = r1.y + r1.height/2 - 1;
                    break;
                case NE:
                    p.x = r1.x + r1.width - 1;
                    p.y = r1.y;
                    break;
                default /* INSIDE == 0 */:
                    System.out.println("INSIDE");
            return p;
        public void addLabel(Point p)
            JLabel label = new JLabel("label " + ++labelCount);
            label.setBorder(BorderFactory.createEtchedBorder());
            add(label);
            Dimension d = label.getPreferredSize();
            label.setBounds(p.x - d.width/2, p.y - d.height/2, d.width, d.height);
            repaint();
        public void showConnectionLines()
            showConnections = !showConnections;
            repaint();
    class LabelWrangler extends MouseInputAdapter
        ConnectionPanel connectionPanel;
        Component selectedLabel;
        Point offset;
        boolean dragging, willAcceptLabel;
        public LabelWrangler(ConnectionPanel cp)
            connectionPanel = cp;
            offset = new Point();
            willAcceptLabel = false;
            dragging = false;
        public void mousePressed(MouseEvent e)
            Point p = e.getPoint();
            // has a label been selected for dragging?
            Component[] c = connectionPanel.getComponents();
            Rectangle r = new Rectangle();
            for(int j = 0; j < c.length; j++)
                c[j].getBounds(r);
                if(r.contains(p))
                    selectedLabel = c[j];
                    offset.x = p.x - r.x;
                    offset.y = p.y - r.y;
                    dragging = true;
                    break;
            // if no selection, are we adding a new label?
            if(!dragging && willAcceptLabel)
                connectionPanel.addLabel(p);
                willAcceptLabel = false;
        public void mouseReleased(MouseEvent e)
            dragging = false;
        public void mouseDragged(MouseEvent e)
            if(dragging)
                int x = e.getX() - offset.x;
                int y = e.getY() - offset.y;
                selectedLabel.setLocation(x, y);
                connectionPanel.repaint();
    }

  • How to fill combox with databind

    Hi Expert,
    I want to fill a combox with the return values from "select cardcode, cardname from ocrd".
    Could we define a datasource which get data from above query then fill the combox?
    If you can show me sample code, that will be greate!
    Thanks
    Tim

    Hi ,
    use the below code...
    Rs = objAddOn.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
            Cat = oForm.Items.Item("your combo box UID").Specific
            sQry = "select cardcode from ocrd"
            Rs.DoQuery(sQry)
            If Rs.RecordCount > 0 Then
                While Not Rs.EoF
                    Cat.ValidValues.Add(Rs.Fields.Item("cardcode ").Value, Rs.Fields.Item("cardcode ").Value)
                    Rs.MoveNext()
                End While
            End If
    dont include the cardname in the combo box as it data length is higher then it wont be bind with the combo box
    For getting the card name . get the cardcode from the selected value (say cardcode from the combo)
    get another record set and do the query as u need then get the cardname and put it to the edit box.

  • Empty app screen? How to fill screens with apps?

    HI-
    I used to have 4 pages of apps. After the 3.0 update I have 5 and my second app screen, which used to be full of apps, now only has one app. I know an app was added but this shouldn't have happened.
    So - how do I "back-fill" the screens so that there are no gaps? Like it used to be. For example, how do I move apps from screen 3 to screen 2?
    Thanks,
    J2

    Page 25 of the manual:
    " Customizing the Home Screen
    You can customize the layout of icons on the Home screen—including the Dock
    icons along the bottom of the screen. If you want, arrange them over multiple
    Home screens.
    Rearrange icons:
    1 Touch and hold any Home screen icon until the icons begin to wiggle.
    2 Arrange the icons by dragging them.
    3 Press the Home button to save your arrangement.
    You can also add links to your favorite webpages on the Home screen. See “Web
    Clips” on page 71.
    Create additional Home screens: While arranging icons, drag an icon to the right
    edge of the screen until a new screen appears. You can flick to return to the original
    screen and drag more icons to the new screen. "
    http://manuals.info.apple.com/enUS/iPhone_UserGuide.pdf

  • How to fill text with the negative of the background image

    I have a picture of grass as the background. I am trying to put text on the image, and have the fill of text be colored as the negative of the background grass image colors. To represent what I wish to do, I demonstrated the color I wish to obtain inside the fill by highlighting the text over the image. Any help is appreciated. Thanks.

    Pinipples,
    As I (mis)understand it, you may:
    1) Copy/replace the image on top of itself;
    2) Invert the colours of the copy image;
    3) Place the text (which may be live Type) on top of the copy image, select both (not the original image), and Object>Clipping Mask>Make.

Maybe you are looking for