Beginner
Date of registration: Jan 15th 2011
Location: Sarasota, FL
Occupation: Cabinet Design
Hobbies: Programming
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Public Sub Command1_Click() Dim listModel As New DefaultListModel Dim f = New JFrame("JScrollPane Demonstration") f.setSize(300, 200) Dim list As New JList(listModel) 'Dim scrollpane As New JScrollPane(list) Dim scrollpane As New JScrollPane(list, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED) f.getContentPane().add(scrollpane) For i = 1 To 50000 listModel.addElement("Entry Number " & i ) Next i f.setVisible(True) End Sub |
Jabaco Source |
|
1 2 3 |
tmpCheckBox = New JCheckBox(Text) ... tmpLabel = New JLabel(Text, getIcon(), SwingConstants.LEFT) |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
'in ListCellDataRenderer Public Function getListCellRendererComponent(List As #JList, Value As #Object, Index As Integer, IsSelected As Boolean, CellHasFocus As Boolean) As #Component On Error Resume Next Dim tmpCellData As ListCellData = Cast(Value, #ListCellData) If tmpCellData <> Nothing And myOwner <> Nothing Then 'old ' getListCellRendererComponent = tmpCellData.getComponent(myOwner, IsSelected, CellHasFocus) 'new Dim myComponent As #Component myComponent = IIF(tmpCellData.Icon = Nothing And tmpCellData.AsCheckBox = False, Base.getListCellRendererComponent(List, Value, Index, IsSelected, CellHasFocus), Nothing) getListCellRendererComponent = tmpCellData.getComponent(myOwner, myComponent, IsSelected, CellHasFocus) ' If Index Mod 2 = 1 Then If Not IsSelected Then If myOwner.BackColorAlternating = 0 Then Call getListCellRendererComponent.setBackground(myOwner.getBackground) Else Call getListCellRendererComponent.setBackground(RGBtoColor(myOwner.BackColorAlternating)) End If End If Else getListCellRendererComponent = Base.getListCellRendererComponent(List, Value, Index, IsSelected, CellHasFocus) End If End Function 'in ListCellData 'old 'Public Function getComponent(Owner As IListCellDataOwner, IsSelected As Boolean, CellHasFocus As Boolean) As #Component 'new Public Function getComponent(Owner As IListCellDataOwner, myComponent As #Component, IsSelected As Boolean, CellHasFocus As Boolean) As #Component 'in ComboBox And ListBox Private Function GetCellComponent(Index As Long) As Component On Error Resume Next GetCellComponent = Cast(GetCellData(Index).getComponent(Me, Nothing, (ListIndex = Index), (ListIndex = Index)), Component) End Function |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
Public Function getListCellRendererComponent(List As #JList, Value As #Object, Index As Integer, IsSelected As Boolean, CellHasFocus As Boolean) As #Component On Error Resume Next Dim tmpCellData As ListCellData = Cast(Value, #ListCellData) If tmpCellData <> Nothing And myOwner <> Nothing Then 'old 'getListCellRendererComponent = tmpCellData.getComponent(myOwner, IsSelected, CellHasFocus) If Index = -1 Then 'pass on Nothing so ListCellData invokes a new component; to compensate LAF settings of the Editor! getListCellRendererComponent = tmpCellData.getComponent(myOwner, Nothing, IsSelected, CellHasFocus) Else 'new 'pass on the default BaseComponent Dim myComponent As #Component myComponent = IIF(tmpCellData.Icon = Nothing And tmpCellData.AsCheckBox = False, Base, Nothing) getListCellRendererComponent = tmpCellData.getComponent(myOwner, myComponent, IsSelected, CellHasFocus) End If If Index Mod 2 = 1 Then If Not IsSelected Then If myOwner.BackColorAlternating = 0 Then Call getListCellRendererComponent.setBackground(tmpCellData.Owner.getBackground) Else Call getListCellRendererComponent.setBackground(RGBtoColor(tmpCellData.Owner.BackColorAlternating)) End If End If Else getListCellRendererComponent = Base.getListCellRendererComponent(List, Value, Index, IsSelected, CellHasFocus) End If End Function |
Jabaco Source |
|
1 2 |
ComboBox1.AddItem New ListCellData(" Dani", resources.ApplicationputPng, False) ComboBox1.AddItem New ListCellData(" Dani", Nothing, True) |
This post has been edited 3 times, last edit by "Dani" (Jan 22nd 2014, 9:01pm)
Beginner
Date of registration: Jan 15th 2011
Location: Sarasota, FL
Occupation: Cabinet Design
Hobbies: Programming
Quoted
How about we split the code.
Have 1 version of code for a List box without icons, and one code version for list boxes with Icons.
Do the same for combo boxes.