如何以编程方式滚动到Java Desktop Application中的特定部分

时间:2018-05-15 14:13:04

标签: java swing jframe jtabbedpane

与HTML一样,我们可以使用该部分detailed explanation的ID滚动到页面的特定部分。是否可以在我有滚动窗格的Java桌面应用程序中实现相同的功能。我找不到任何这样的功能。任何建议都会有所帮助。

2 个答案:

答案 0 :(得分:0)

有几种选择:

  1. 您可以通过编程方式滚动滚动窗格,但这会在分辨率从屏幕更改为屏幕时产生问题。
  2. 您可以拥有USE [TWL_PROD] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[Update_invValue] AS BEGIN SET NOCOUNT ON; select 'S ' + whse as whse, prod, qtyonhand + qtyunavail as qty ,(avgcost+addoncost) as cost into #stock from openquery ( twllive, 'select whse, prod, qtyonhand,qtyunavail,avgcost,addoncost from pub.icsw where cono = ''1'' and whse in (''mtl'', ''nob'', ''tdc'', ''oak'')'); select 'NS ' + whse as whse, prod, sum(quantity) as qty, sum( case when quantity > 0 then amount else -1*amount end) as total_value into #nStock from openquery ( twllive, 'select b.* from pub.icenh a left join pub.icenl b on a.cono = b.cono and a.typecd = b.typecd and a.whse = b.whse and a.prod = b.prod and a.prodcat = b.prodcat and a.seqnoh = b.seqnoh where a.cono = ''1'' and a.typecd = ''n'' and a.whse in (''mtl'', ''tdc'', ''nob'', ''oak'') and a.activefl = 1 ') group by whse, prod; select co_num , abs_num as prod, bin_num, total_qty,total_qty * 1.00 as value, item_type into #3pl from openquery (twllive, 'select a.co_num, a.abs_num, a.total_qty, a.bin_num, b.item_type from pub.inventory a left join pub.item b on a.wh_num = b.wh_num and a.abs_num = b.abs_num where a.co_num = ''1'' and a.wh_num = ''mtl'' and bin_num in ( ''dockexpp'', ''dockexca'', ''docktransi'')'); update #3PL set Value = (g.total_value/g.qty) * a.total_qty from #3PL a inner join #nStock g on a.prod = g.prod where A.item_type = 'n' and g.whse = 'NS mtl'; update #3PL set Value = (g.cost) * a.total_qty from #3PL a inner join #Stock g on a.prod = g.prod where A.item_type = 's' and g.whse = 's mtl' ; select co_num, SUM(case when bin_num = 'dockexpp' and item_type = 's' then value else 0 end) as Stock_Plaspak,SUM(case when bin_num = 'dockexpp' and item_type = 'n' then value else 0 end) as NS_Plaspak , SUM(case when bin_num = 'dockexca' and item_type = 's' then value else 0 end) as Stock_Caratrans , SUM(case when bin_num = 'dockexca' and item_type = 'N' then value else 0 end) as NS_Caratrans, SUM(case when bin_num = 'docktransi' and item_type = 's' then value else 0 end) as Stock_Transit,SUM(case when bin_num = 'docktransi' and item_type = 'n' then value else 0 end) as NS_transit into #3PL1 from #3PL group by co_num; select * into #temp from ( select 1 as cono, whse, SUM(total_value) as value from #nStock group by whse union all select 1 as cono, whse, SUM(qty * cost) as value from #Stock group by whse union all select 1 as cono,'S-3PL' as whse, SUM(case when item_type = 's' then value else 0 end) as value from #3pl union all select 1 as cono,'NS-3PL' as whse, SUM(case when item_type = 'n' then value else 0 end)as value from #3pl ) "a"; update #temp set value = ((select value from #temp where whse = 'ns mtl') - (select value from #temp where whse = 'ns-3pl') ) where whse = 'ns mtl'; update #temp set value = ((select value from #temp where whse = 's mtl') - (select value from #temp where whse = 's-3pl') ) where whse = 's mtl'; select cono,[NS MTL],[NS NOB],[NS OAK],[NS TDC],[S MTL],[S NOB], [S OAK], [S TDC] into #stock1 from #temp pivot (max(value) for whse in ([NS MTL],[NS NOB],[NS OAK],[NS TDC],[S MTL],[S NOB], [S OAK], [S TDC])) as PivotTable; insert into zloc_InvValue select * from ( select 'Stock: ' as [type], GETDATE() as [date], a.[S MTL] as MTL,a.[S NOB] as NOB, a.[S OAK] as OAK, a.[S TDC] as TDC, b.Stock_Plaspak as [3PL- Plaspak], b.Stock_Caratrans as [3PL- Caratrans], b.Stock_transit as [3PL- transit] from #stock1 a full outer join #3PL1 b on a.cono = b.co_num union all select 'Non-Stock: ' , GETDATE() , a.[NS MTL],a.[NS NOB], a.[NS OAK], a.[NS TDC], b.NS_Plaspak, b.NS_Caratrans, b.NS_transit from #stock1 a full outer join #3PL1 b on a.cono = b.co_num ) "a" drop table #nStock drop table #stock drop table #3PL drop table #3PL1 drop table #temp drop table #stock1 END 并在其中编写HTML。 Example.

答案 1 :(得分:-1)

  

我有一个滚动窗格

您可以使用以下方法控制滚动窗格视口的位置:

scrollPane.getViewport().setViewPosition(...);

因此,如果您在视口顶部知道所需的组件,则可以获取组件的位置,然后将其用作视图位置的点。