单击Jbutton时如何从另一个Jframe调用java类

时间:2017-09-27 13:11:37

标签: java swing oop javafx

我正在尝试显示JavaFX多线图。我尝试在另一个Jframe的Jbutton点击上打开这个图,并将数据数组传递给图类。

如何将此类创建为一个对象,并在从另一个Jfame单击Jbutton时显示该图?

这是我编辑的代码和两个显示临时数据的数组。

     Sub aa()

 'Declare Variables
    Dim PSheet As Worksheet
    Dim DSheet As Worksheet
    Dim PCache As PivotCache
    Dim PTable As PivotTable
    Dim PRange As Range
    Dim LastRow As Long
    Dim LastCol As Long

    'Insert a New Blank Worksheet
    On Error Resume Next
    Application.DisplayAlerts = False
    Worksheets("Customs_report").Delete
    Sheets.Add Before:=ActiveSheet
    ActiveSheet.Name = "Customs_report"
    Application.DisplayAlerts = True
    Set PSheet = Worksheets("Customs_report")
    Set DSheet = Worksheets("Zeikan")

    'Define Data Range
    LastRow = DSheet.Cells(Rows.Count, 1).End(xlUp).Row
    LastCol = DSheet.Cells(6, Columns.Count).End(xlToLeft).Column
    Set PRange = DSheet.Cells(6, 1).Resize(LastRow, LastCol)

    'Define Pivot Cache
    Set PCache = ActiveWorkbook.PivotCaches.Create _
    (SourceType:=xlDatabase, SourceData:=PRange). _
    CreatePivotTable(TableDestination:=PSheet.Cells(2, 2), _
    TableName:="PivotTable")

    'Insert Blank Pivot Table
    Set PTable = PCache.CreatePivotTable _
    (TableDestination:=PSheet.Cells(1, 1), TableName:="PivotTable")

    'Insert Row Fields
    With ActiveSheet.PivotTables("PivotTable").PivotFields("Commodity Code")
    .Orientation = xlRowField
    .Position = 1
    .Name = "Commodity Code"
    End With
    With ActiveSheet.PivotTables("PivotTable").PivotFields("Location")
    .Orientation = xlRowField
    .Position = 2
    End With

    'Insert Column Fields
    With ActiveSheet.PivotTables("PivotTable").PivotFields("Quantity (cases/sw)")
    .Orientation = xlDataField
    .Position = 1
    .Function = xlSum
    .Name = "Sum of Quantity (cases/sw)"
    End With
    With ActiveSheet.PivotTables("PivotTable").PivotFields("Quantity (items)")
    .Orientation = xlDataField
    .Position = 2
    .Function = xlSum
    .Name = "Sum of Quantity (items)"
    End With
    With ActiveSheet.PivotTables("PivotTable").PivotFields("Net value")
    .Orientation = xlDataField
    .Position = 3
    .Function = xlSum
    .Name = "Sum of Net value"
    End With
    With ActiveSheet.PivotTables("PivotTable").PivotFields("Gross weight (Kg)")
    .Orientation = xlDataField
    .Position = 4
    .Function = xlSum
    .Name = "Sum of Gross weight (Kg)"
    End With
    With ActiveSheet.PivotTables("PivotTable").PivotFields("Net weight (Kg)")
    .Orientation = xlDataField
    .Position = 5
    .Function = xlSum
    .Name = "Sum of Net weight (Kg)"
    End With


    End Sub

0 个答案:

没有答案
相关问题