Skip to content

Commit

Permalink
Adds icon on tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanue1 committed Aug 5, 2015
1 parent 85d4eb6 commit aa7c08b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.border = BorderFactory.createEmptyBorder(2, 0, 3, 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)

Expand Down Expand Up @@ -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) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -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
}
}
Expand Down

0 comments on commit aa7c08b

Please sign in to comment.