Java Code Examples for javax.swing.JList#addMouseListener()

The following examples show how to use javax.swing.JList#addMouseListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CheckRenderer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public CheckRenderer(final JList list) {
    this.list = list;
    list.addMouseListener(
            new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    int index = list.locationToIndex(e.getPoint());
                    Point p2 = list.indexToLocation(index);
                    Rectangle r = new Rectangle(p2.x, p2.y, getPreferredSize().height, getPreferredSize().height);
                    if (r.contains(e.getPoint())) {
                        CheckNode node = ((CheckNodeListModel) list.getModel()).getCheckNodeAt(index);
                        node.setSelected(!node.isSelected());
                        list.repaint();
                        e.consume();
                    }
                }
            });

    this.setPreferredSize(new Dimension(getPreferredSize().width, getPreferredSize().height - 5));
    startBackground = this.getBackground();
}
 
Example 2
Source File: CheckRenderer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public CheckRenderer(final JList list) {
    this.list = list;
    list.addMouseListener(
            new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    int index = list.locationToIndex(e.getPoint());
                    Point p2 = list.indexToLocation(index);
                    Rectangle r = new Rectangle(p2.x, p2.y, getPreferredSize().height, getPreferredSize().height);
                    if (r.contains(e.getPoint())) {
                        CheckNode node = ((CheckNodeListModel) list.getModel()).getCheckNodeAt(index);
                        node.setSelected(!node.isSelected());
                        list.repaint();
                        e.consume();
                    }
                }
            });

    this.setPreferredSize(new Dimension(getPreferredSize().width, getPreferredSize().height - 5));
    startBackground = this.getBackground();
}
 
Example 3
Source File: CheckRenderer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public CheckRenderer(final JList list) {
    this.list = list;
    list.addMouseListener(
            new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    int index = list.locationToIndex(e.getPoint());
                    Point p2 = list.indexToLocation(index);
                    Rectangle r = new Rectangle(p2.x, p2.y, getPreferredSize().height, getPreferredSize().height);
                    if (r.contains(e.getPoint())) {
                        CheckNode node = ((CheckNodeListModel) list.getModel()).getCheckNodeAt(index);
                        node.setSelected(!node.isSelected());
                        list.repaint();
                        e.consume();
                    }
                }
            });

    this.setPreferredSize(new Dimension(getPreferredSize().width, getPreferredSize().height - 5));
    startBackground = this.getBackground();
}
 
Example 4
Source File: Main.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public Main() {
    super("Demo Programs");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    List<String> resources = FindResources.findClasses("Demo");
    final ResourceListModel dataModel = new ResourceListModel(resources);
    final JList list = new JList(dataModel);
    list.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() > 1) {
                int index = list.locationToIndex(e.getPoint());
                if (index != -1)
                    dataModel.load(index);
            }
        }
    });
    add(new JScrollPane(list));
    pack();
}
 
Example 5
Source File: CheckRenderer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public CheckRenderer(final JList list) {
    this.list = list;
    list.addMouseListener(
            new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    int index = list.locationToIndex(e.getPoint());
                    Point p2 = list.indexToLocation(index);
                    Rectangle r = new Rectangle(p2.x, p2.y, getPreferredSize().height, getPreferredSize().height);
                    if (r.contains(e.getPoint())) {
                        CheckNode node = ((CheckNodeListModel) list.getModel()).getCheckNodeAt(index);
                        node.setSelected(!node.isSelected());
                        list.repaint();
                        e.consume();
                    }
                }
            });

    this.setPreferredSize(new Dimension(getPreferredSize().width, getPreferredSize().height - 5));
    startBackground = this.getBackground();
}
 
Example 6
Source File: CheckRenderer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public CheckRenderer(final JList<Object> list) {
    this.list = list;
    list.addMouseListener(
            new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    int index = list.locationToIndex(e.getPoint());
                    Point p2 = list.indexToLocation(index);
                    Rectangle r = new Rectangle(p2.x, p2.y, getPreferredSize().height, getPreferredSize().height);
                    if (r.contains(e.getPoint())) {
                        CheckNode node = ((CheckNodeListModel) list.getModel()).getCheckNodeAt(index);
                        node.setSelected(!node.isSelected());
                        list.repaint();
                        e.consume();
                    }
                }
            });

    this.setPreferredSize(new Dimension(getPreferredSize().width, getPreferredSize().height - 5));
    startBackground = this.getBackground();
}
 
Example 7
Source File: CheckRenderer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public CheckRenderer(final JList list) {
    this.list = list;
    list.addMouseListener(
            new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    int index = list.locationToIndex(e.getPoint());
                    Point p2 = list.indexToLocation(index);
                    Rectangle r = new Rectangle(p2.x, p2.y, getPreferredSize().height, getPreferredSize().height);
                    if (r.contains(e.getPoint())) {
                        CheckNode node = ((CheckNodeListModel) list.getModel()).getCheckNodeAt(index);
                        node.setSelected(!node.isSelected());
                        list.repaint();
                        e.consume();
                    }
                }
            });

    this.setPreferredSize(new Dimension(getPreferredSize().width, getPreferredSize().height - 5));
    startBackground = this.getBackground();
}
 
Example 8
Source File: CheckRenderer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public CheckRenderer(final JList list) {
    this.list = list;
    list.addMouseListener(
            new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    int index = list.locationToIndex(e.getPoint());
                    Point p2 = list.indexToLocation(index);
                    Rectangle r = new Rectangle(p2.x, p2.y, getPreferredSize().height, getPreferredSize().height);
                    if (r.contains(e.getPoint())) {
                        CheckNode node = ((CheckNodeListModel) list.getModel()).getCheckNodeAt(index);
                        node.setSelected(!node.isSelected());
                        list.repaint();
                        e.consume();
                    }
                }
            });

    this.setPreferredSize(new Dimension(getPreferredSize().width, getPreferredSize().height - 5));
    startBackground = this.getBackground();
}
 
Example 9
Source File: ToolSelectorPanel.java    From chipster with MIT License 5 votes vote down vote up
/**
 * Creates a new ToolSelectorPanel.
 * 
 * @param parent The ToolPanel, for communication purposes.
 */
public ToolSelectorPanel(ToolPanel parent, ToolModule toolModule) {
	super(new GridLayout(1, 2));
	this.toolPanel = parent;
	this.toolModule = toolModule;
	
       List<ToolCategory> toolCategories;
       toolCategories = Collections.list(Collections.enumeration(toolModule.getVisibleCategories()));
       
	categoryList = new JList();
	categoryList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	categoryList.addListSelectionListener(this);
	categoryList.setCellRenderer(new CategoryListRenderer());
	categoryList.getInsets().right = 1;
	categoryList.setName("categoryList");
	categoryList.setListData(toolCategories.toArray());
	
	
	
	toolList = new JList();
	toolList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	toolList.addListSelectionListener(this);
	toolList.setCellRenderer(new FontSizeFriendlyListRenderer());
	toolList.addMouseListener(new MouseClickListener());
	toolList.getInsets().right = 1;
	toolList.setName("toolList");
	
	JScrollPane categoryListScroller = new JScrollPane(categoryList);		
	JScrollPane toolListScroller = new JScrollPane(toolList);
	
	//Remove useless borders
	categoryListScroller.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1,
	        VisualConstants.TOOL_LIST_BORDER_COLOR));
	toolListScroller.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
	
	this.add(categoryListScroller);
	this.add(toolListScroller);
}
 
Example 10
Source File: CheckBoxListDecorator.java    From importer-exporter with Apache License 2.0 5 votes vote down vote up
public CheckBoxListDecorator(JList<T> list) {
	this.list = list;

	list.setCellRenderer(new CheckBoxListCellRenderer<T>());
	list.addMouseListener(this); 
	list.addPropertyChangeListener(this);
	list.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), JComponent.WHEN_FOCUSED); 

	checkBoxSelectionModel = new DefaultListSelectionModel();
	checkBoxSelectionModel.addListSelectionListener(this);

	enabled = new HashMap<Integer, Boolean>();
	width = new JCheckBox().getPreferredSize().width;
}
 
Example 11
Source File: RoleSetPage.java    From ganttproject with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Component getComponent() {
  Box domainBox = new Box(BoxLayout.PAGE_AXIS);
  JLabel label = new JLabel(GanttLanguage.getInstance().getText("chooseRoleSets"));

  final JList roleSetsList = new JList(myListModel);
  roleSetsList.setCellRenderer(myListModel.getCellRenderer());
  roleSetsList.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseClicked(MouseEvent e) {
      int index = roleSetsList.locationToIndex(e.getPoint());
      myListModel.toggle(index);
    }
  });
  roleSetsList.setAlignmentX(0);
  label.setLabelFor(roleSetsList);
  label.setAlignmentX(0);

  domainBox.add(label);
  domainBox.add(Box.createVerticalStrut(5));
  domainBox.add(roleSetsList);

  JPanel result = new JPanel(new BorderLayout());
  result.add(domainBox, BorderLayout.CENTER);
  // result.setBorder(LineBorder.createBlackLineBorder());
  return result;
}
 
Example 12
Source File: Units.java    From iBioSim with Apache License 2.0 5 votes vote down vote up
public Units(BioModel gcm, ModelEditor modelEditor) {
	super(new BorderLayout());
	this.bioModel = gcm;
	this.modelEditor = modelEditor;
	Model model = gcm.getSBMLDocument().getModel();
	addUnit = new JButton("Add Unit");
	removeUnit = new JButton("Remove Unit");
	editUnit = new JButton("Edit Unit");
	unitDefs = new JList();
	ListOf<UnitDefinition> listOfUnits = model.getListOfUnitDefinitions();
	String[] units = new String[model.getUnitDefinitionCount()];
	for (int i = 0; i < model.getUnitDefinitionCount(); i++) {
		UnitDefinition unit = listOfUnits.get(i);
		units[i] = unit.getId();
		// GET OTHER THINGS
	}
	JPanel addRem = new JPanel();
	addRem.add(addUnit);
	addRem.add(removeUnit);
	addRem.add(editUnit);
	addUnit.addActionListener(this);
	removeUnit.addActionListener(this);
	editUnit.addActionListener(this);
	JLabel panelLabel = new JLabel("List of Units:");
	JScrollPane scroll = new JScrollPane();
	scroll.setMinimumSize(new Dimension(260, 220));
	scroll.setPreferredSize(new Dimension(276, 152));
	scroll.setViewportView(unitDefs);
	edu.utah.ece.async.ibiosim.dataModels.biomodel.util.Utility.sort(units);
	unitDefs.setListData(units);
	unitDefs.setSelectedIndex(0);
	unitDefs.addMouseListener(this);
	this.add(panelLabel, "North");
	this.add(scroll, "Center");
	this.add(addRem, "South");
}
 
Example 13
Source File: Utility.java    From iBioSim with Apache License 2.0 5 votes vote down vote up
public static/* Create add/remove/edit panel */
JPanel createPanel(ActionListener listener, String panelName,
		JList panelJList, JButton addButton, JButton removeButton,
		JButton editButton) {
	JPanel Panel = new JPanel(new BorderLayout());
	JPanel addRem = new JPanel();
	if (addButton != null) {
		addButton.addActionListener(listener);
		addRem.add(addButton);
	}
	if (removeButton != null) {
		removeButton.addActionListener(listener);
		addRem.add(removeButton);
	}
	if (editButton != null) {
		addRem.add(editButton);
		editButton.addActionListener(listener);
	}

	JLabel panelLabel = new JLabel("List of " + panelName + ":");
	JScrollPane scroll = new JScrollPane();
	scroll.setMinimumSize(new Dimension(260, 220));
	scroll.setPreferredSize(new Dimension(276, 152));
	scroll.setViewportView(panelJList);

	if (listener instanceof MouseListener) {
		panelJList.addMouseListener((MouseListener) listener);
	}
	Panel.add(panelLabel, "North");
	Panel.add(scroll, "Center");
	Panel.add(addRem, "South");
	return Panel;
}
 
Example 14
Source File: MissedCalls.java    From Spark with Apache License 2.0 5 votes vote down vote up
public MissedCalls() {
    model = new DefaultListModel();
    list = new JList(model);
    gui = getMissedCallPanel();


    list.setCellRenderer(new MissedCallRenderer());
    list.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent mouseEvent) {
            if (mouseEvent.getClickCount() == 2) {
                placeCall((MissedCall)list.getSelectedValue());
            }
        }
    });

    list.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }

            int selectedIndex = list.getSelectedIndex();
            boolean enabled = selectedIndex != -1;
            callBackButton.setEnabled(enabled);
            deleteButton.setEnabled(enabled);
        }
    });
}
 
Example 15
Source File: FBAObjective.java    From iBioSim with Apache License 2.0 4 votes vote down vote up
public FBAObjective(BioModel bioModel) {
	super(new BorderLayout());
	this.bioModel = bioModel;
	fbc = bioModel.getSBMLFBC();
	
	bigPanel = new JPanel(new BorderLayout());
	objectiveStringArray = new String[fbc.getListOfObjectives().size()];
	activeObjective = fbc.getListOfObjectives().getActiveObjective();
		
	for (int i = 0; i < fbc.getListOfObjectives().size(); i++) {
		String objective = "";
		Type type = fbc.getObjective(i).getType();
		String id = fbc.getObjective(i).getId();
		if(activeObjective.equals(id)){
			objective = "*";
		}
		if (type.equals(Type.MINIMIZE)) {
			objective += "Min";
		}
		else {
			objective += "Max";
		}
		objective += "(" + id + ") = ";
		boolean first = true;
		for (int j = 0; j < fbc.getObjective(i).getListOfFluxObjectives().size(); j++) {
			FluxObjective fluxObjective = fbc.getObjective(i).getListOfFluxObjectives().get(j);
			String indexStr = SBMLutilities.getIndicesString(fluxObjective, "fbc:reaction");
			if (!first) objective += " + "; else first = false;
			objective += fluxObjective.getCoefficient() + " * " + fluxObjective.getReaction() + indexStr;
		}
		objectiveStringArray[i] = objective;
	}
	objectives = new JList();
	objectiveList = new JList();
	
	JPanel ObjectiveCreationPanel = new JPanel(new BorderLayout());
	JPanel buttons = new JPanel();
	JButton addObjective = new JButton("Add");
	JButton removeObjective = new JButton("Remove");
	JButton editObjective = new JButton("Edit");
	buttons.add(addObjective);
	buttons.add(removeObjective);
	buttons.add(editObjective);
	addObjective.addActionListener(this);
	removeObjective.addActionListener(this);
	editObjective.addActionListener(this);
	JLabel ObjectiveCreationLabel = new JLabel("List of Objectives:");
	objectiveList.removeAll();
	objectiveList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	JScrollPane scroll = new JScrollPane();
	scroll.setMinimumSize(new Dimension(260, 220));
	scroll.setPreferredSize(new Dimension(276, 152));
	scroll.setViewportView(objectiveList);
	
	edu.utah.ece.async.ibiosim.dataModels.biomodel.util.Utility.sort(objectiveStringArray);
	objectiveList.setListData(objectiveStringArray);
	objectiveList.setSelectedIndex(0);
	objectiveList.addMouseListener(this);
	ObjectiveCreationPanel.add(ObjectiveCreationLabel, "North");
	ObjectiveCreationPanel.add(scroll, "Center");
	ObjectiveCreationPanel.add(buttons, "South");
	
	bigPanel.add(ObjectiveCreationPanel, "South");
}
 
Example 16
Source File: Constraints.java    From iBioSim with Apache License 2.0 4 votes vote down vote up
public Constraints(BioModel bioModel, ModelEditor modelEditor) {
	super(new BorderLayout());
	this.bioModel = bioModel;
	this.modelEditor = modelEditor;
	Model model = bioModel.getSBMLDocument().getModel();
	addConstraint = new JButton("Add Constraint");
	removeConstraint = new JButton("Remove Constraint");
	editConstraint = new JButton("Edit Constraint");
	constraints = new JList();
	ListOf<Constraint> listOfConstraints = model.getListOfConstraints();
	String[] cons = new String[model.getConstraintCount()];
	for (int i = 0; i < model.getConstraintCount(); i++) {
		Constraint constraint = listOfConstraints.get(i);
		if (!constraint.isSetMetaId()) {
			String constraintId = "c0";
			int cn = 0;
			while (bioModel.isSIdInUse(constraintId)) {
				cn++;
				constraintId = "c" + cn;
			}
			SBMLutilities.setMetaId(constraint, constraintId);
		}
		cons[i] = constraint.getMetaId();
		cons[i] += SBMLutilities.getDimensionString(constraint);
	}
	JPanel addRem = new JPanel();
	addRem.add(addConstraint);
	addRem.add(removeConstraint);
	addRem.add(editConstraint);
	addConstraint.addActionListener(this);
	removeConstraint.addActionListener(this);
	editConstraint.addActionListener(this);
	JLabel panelLabel = new JLabel("List of Constraints:");
	JScrollPane scroll = new JScrollPane();
	scroll.setMinimumSize(new Dimension(260, 220));
	scroll.setPreferredSize(new Dimension(276, 152));
	scroll.setViewportView(constraints);
	edu.utah.ece.async.ibiosim.dataModels.biomodel.util.Utility.sort(cons);
	constraints.setListData(cons);
	constraints.setSelectedIndex(0);
	constraints.addMouseListener(this);
	this.add(panelLabel, "North");
	this.add(scroll, "Center");
	this.add(addRem, "South");
}
 
Example 17
Source File: NullpoMinoSwing.java    From nullpomino with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Init top screen
 */
protected void initTopScreenUI(JComponent p) {
	p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));

	// Label
	lModeSelect = new JLabel(getUIText("Top_ModeSelect"));
	lModeSelect.setAlignmentX(0f);
	p.add(lModeSelect);

	// Mode & rule select panel
	JPanel subpanelModeSelect = new JPanel(new BorderLayout());
	subpanelModeSelect.setBorder(new EtchedBorder());
	subpanelModeSelect.setAlignmentX(0f);
	p.add(subpanelModeSelect);

	// * Mode select listbox
	listboxMode = new JList(modeList);
	listboxMode.addMouseListener(new ListboxModeMouseAdapter());
	listboxMode.addListSelectionListener(new ListSelectionListener() {
		public void valueChanged(ListSelectionEvent e) {
			String strMode = (String)listboxMode.getSelectedValue();
			lModeSelect.setText(getModeDesc(strMode));
			prepareRuleList(strMode);
		}
	});
	JScrollPane scpaneListboxMode = new JScrollPane(listboxMode);
	scpaneListboxMode.setPreferredSize(new Dimension(280, 375));
	subpanelModeSelect.add(scpaneListboxMode, BorderLayout.WEST);

	// * Rule select listbox
	listmodelRule = new DefaultListModel();
	listboxRule = new JList(listmodelRule);
	listboxRule.addMouseListener(new ListboxModeMouseAdapter());
	JScrollPane scpaneListBoxRule = new JScrollPane(listboxRule);
	scpaneListBoxRule.setPreferredSize(new Dimension(150, 375));
	subpanelModeSelect.add(scpaneListBoxRule, BorderLayout.CENTER);

	// * Set default selected index
	listboxMode.setSelectedValue(propGlobal.getProperty("name.mode", ""), true);
	if(listboxMode.getSelectedIndex() == -1) listboxMode.setSelectedIndex(0);
	prepareRuleList((String)listboxMode.getSelectedValue());

	// Start button
	JButton buttonStartOffline = new JButton(getUIText("Top_StartOffline"));
	buttonStartOffline.setMnemonic('S');
	buttonStartOffline.addActionListener(this);
	buttonStartOffline.setActionCommand("Top_StartOffline");
	buttonStartOffline.setAlignmentX(0f);
	buttonStartOffline.setMaximumSize(new Dimension(Short.MAX_VALUE, buttonStartOffline.getMaximumSize().height));
	p.add(buttonStartOffline);
	this.getRootPane().setDefaultButton(buttonStartOffline);

	// Menu
	initMenu();
}
 
Example 18
Source File: SpringDemo.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private JComponent buildList() {
    Application[] elements = new Application[] {
        new Application("Address Book", "x-office-address-book.png"),
        new Application("Calendar",     "x-office-calendar.png"),
        new Application("Presentation", "x-office-presentation.png"),
        new Application("Spreadsheet",  "x-office-spreadsheet.png"),
    };
    
    list = new JList(elements);
    list.setCellRenderer(new ApplicationListCellRenderer());
    list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
    list.setVisibleRowCount(2);
    list.setBorder(BorderFactory.createEtchedBorder());
    list.addMouseListener(new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
             if (e.getClickCount() == 2) {
                 int index = list.getSelectedIndex();
                 
                 Rectangle bounds = list.getCellBounds(index, index);
                 Point location = new Point(bounds.x, bounds.y);
                 location = SwingUtilities.convertPoint(list, location, glassPane);
                 location.y -= 13;
                 bounds.setLocation(location);
                 
                 glassPane.showSpring(bounds,
                         ((Application) list.getSelectedValue()).icon.getImage());
             }
         }
     });
    
    JPanel panel = new JPanel(new GridBagLayout());
    panel.add(new JLabel("Launcher"),
            new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
                GridBagConstraints.LINE_START, GridBagConstraints.NONE,
                new Insets(0, 0, 0, 0), 0, 0));
    panel.add(list, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0,
            GridBagConstraints.CENTER, GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0), 0, 0));
    panel.add(new JLabel("Double-click an icon to launch the program"),
            new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0,
                GridBagConstraints.LINE_START, GridBagConstraints.NONE,
                new Insets(0, 0, 0, 0), 0, 0));
    
    return panel;
}
 
Example 19
Source File: ChatHistory.java    From Spark with Apache License 2.0 4 votes vote down vote up
public ChatHistory() {
    list = new JList(model);

    list.setCellRenderer(new HistoryItemRenderer());

    final JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    mainPanel.setBackground(Color.white);


    final BackgroundPane titlePane = new BackgroundPane() {
        public Dimension getPreferredSize() {
            final Dimension size = super.getPreferredSize();
            size.width = 0;
            return size;
        }
    };

    titlePane.setLayout(new GridBagLayout());
    titlePane.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.LIGHT_GRAY));


    JLabel userImage = new JLabel();
    userImage.setHorizontalAlignment(JLabel.LEFT);
    userImage.setText(FpRes.getString("title.previous.chats"));
    userImage.setIcon(FastpathRes.getImageIcon(FastpathRes.FASTPATH_IMAGE_24x24));
    titlePane.add(userImage, new GridBagConstraints(0, 0, 4, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    userImage.setFont(new Font("Dialog", Font.BOLD, 12));
    mainPanel.add(titlePane, BorderLayout.NORTH);

    mainPanel.add(list, BorderLayout.CENTER);

    setLayout(new BorderLayout());
    add(mainPanel, BorderLayout.CENTER);
    init();

    list.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                HistoryItem historyItem = (HistoryItem)list.getSelectedValue();
                showTranscript(historyItem.getSessionID());
            }
        }
    });
}
 
Example 20
Source File: JCarouselMenu.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Creates a new instance of JCarouselMenu
 * @param border The border to use to draw items in the menu
 */
public JCarouselMenu(ImageBorder border) {
    carousel = new JCarosel();
    carousel.setLayout(new OffsetCaroselLayout(carousel));
    carousel.setBackground(null);
    carousel.setOpaque(false);
    carousel.setContentWidth(256);
    
    super.setLayout(new GridLayout(1,2));
    super.add(carousel);
    
    upButton.setForeground(Color.WHITE);
    downButton.setForeground(Color.WHITE);
    
    JPanel menuPanel = new JPanel();
    menuPanel.setBackground(null);
    menuPanel.setOpaque(false);
    menuPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc  = new GridBagConstraints();
    
    menu = new JList();
    menuScroll = new JScrollPane(menu, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    menuScroll.getViewport().setOpaque(false);
    menuScroll.setBorder(null);
    menuScroll.getViewport().addChangeListener(this);
    menu.setModel(menuModel);
    menu.setCellRenderer(new CarouselListCellRenderer(border));
    menu.setBackground(null);       
    menu.setOpaque(false);
    menu.addListSelectionListener(this);
    menuScroll.setOpaque(true);
    menuScroll.setBackground(Color.BLACK);
    menuScroll.setBorder(BorderFactory.createEmptyBorder());
    
    gbc.weightx=0.0;
    gbc.weighty=0.0;
    gbc.gridy=0;
    gbc.fill=GridBagConstraints.HORIZONTAL;
    menuPanel.add(upButton,gbc);
    gbc.weighty=1.0;
    gbc.weightx=1.0;
    gbc.gridy++;
    gbc.fill=GridBagConstraints.BOTH;
    menuPanel.add(menuScroll,gbc);
    gbc.weighty=0.0;
    gbc.weightx=0.0;
    gbc.gridy++;
    gbc.fill=GridBagConstraints.HORIZONTAL;
    menuPanel.add(downButton,gbc);
    menu.addMouseListener(this);
    menu.addKeyListener(this);
            
    //Don't want it to listen to itself...
    carousel.removeMouseWheelListener(carousel);
    carousel.addMouseWheelListener(this);
    menu.addMouseWheelListener(this);
    menuScroll.addMouseWheelListener(this);
    menuPanel.addMouseWheelListener(this);
    
    super.add(menuPanel);
}