Adds icon on tabs

This commit is contained in:
emmanue1 2015-08-05 07:10:20 +02:00
parent 85d4eb647f
commit aa7c08bfa5
2 changed files with 10 additions and 9 deletions

View File

@ -110,15 +110,10 @@ class TabbedPanel extends JPanel implements PreferencesChangeListener {
})
JPanel tab = new JPanel(new BorderLayout())
if (PlatformService.instance.isMac) {
tab.border = BorderFactory.createEmptyBorder(2, 0, 3, 0)
} else {
tab.border = BorderFactory.createEmptyBorder(1, 0, 1, 0)
}
tab.opaque = false
tab.toolTipText = tip
// Show label and icon: panel.add(new JLabel(title, icon, JLabel.LEADING), BorderLayout.CENTER)
tab.add(new JLabel(title), BorderLayout.CENTER)
tab.add(new JLabel(title, icon, JLabel.LEADING), BorderLayout.CENTER)
tab.add(tabCloseButton, BorderLayout.EAST)
ToolTipManager.sharedInstance().unregisterComponent(tab)
@ -189,7 +184,9 @@ class TabbedPanel extends JPanel implements PreferencesChangeListener {
int count = tabbedPane.tabCount
for (int i=0; i<count; i++) {
def subMenuItem = new JMenuItem(tabbedPane.getTitleAt(i), null)
JPanel tab = tabbedPane.getTabComponentAt(i)
JLabel label = tab.getComponent(0)
JMenuItem subMenuItem = new JMenuItem(label.text, label.icon)
subMenuItem.addActionListener(new ActionListener() {
final int index = i
void actionPerformed(ActionEvent e) { tabbedPane.setSelectedIndex(index) }

View File

@ -8,6 +8,7 @@ package org.jd.gui.service.fileloader
import org.jd.gui.api.API
import org.jd.gui.api.feature.UriGettable
import org.jd.gui.api.model.Container
import org.jd.gui.api.model.TreeNodeData
import org.jd.gui.spi.FileLoader
import javax.swing.*
@ -46,7 +47,10 @@ abstract class AbstractFileLoaderProvider implements FileLoader {
def mainPanel = api.getMainPanelFactory(container)?.make(api, container)
if (mainPanel) {
api.addPanel(file.name, null, 'Location: ' + file.absolutePath, mainPanel)
def data = api.getTreeNodeFactory(parentEntry)?.make(api, parentEntry).userObject
def icon = (data instanceof TreeNodeData) ? data.icon : null
api.addPanel(file.name, icon, 'Location: ' + file.absolutePath, mainPanel)
return mainPanel
}
}