public CheckTreeTableManager(JXTreeTable treeTable) { this.treetable = treeTable; this.tree = (JTree) treeTable.getCellRenderer(0, 0); selectionModel = new CheckTreeSelectionModel(tree.getModel()); tree.setCellRenderer(new DefaultTreeRenderer(new CheckTreeCellProvider(selectionModel))); treeTable.addMouseListener(this); selectionModel.addTreeSelectionListener(this); }
@Override public void mouseClicked(MouseEvent me) { TreePath path = tree.getPathForLocation(me.getX(), me.getY()); if (path == null) { return; } if (me.getX() > tree.getPathBounds(path).x + hotspot) { return; } boolean selected = selectionModel.isPathSelected(path, true); selectionModel.removeTreeSelectionListener(this); try { if (selected) { selectionModel.removeSelectionPath(path); } else { selectionModel.addSelectionPath(path); } } finally { selectionModel.addTreeSelectionListener(this); treetable.repaint(); } }
private void initListener(ClassEntity classEntity, String generateClassStr) { this.classEntity = classEntity; defaultMutableTreeTableNodeList = new ArrayList<DefaultMutableTreeTableNode>(); JXTreeTable treetable = new JXTreeTable(new FiledTreeTableModel(createData(classEntity))); CheckTreeTableManager manager = new CheckTreeTableManager(treetable); manager.getSelectionModel().addPathsByNodes(defaultMutableTreeTableNodeList); treetable.getColumnModel().getColumn(0).setPreferredWidth(150); treetable.expandAll(); treetable.setCellSelectionEnabled(false); final DefaultListSelectionModel defaultListSelectionModel = new DefaultListSelectionModel(); treetable.setSelectionModel(defaultListSelectionModel); treetable.setRowHeight(30); sp.setViewportView(treetable); generateClass.setText(generateClassStr);
public static JXPanel getDescription(CardView card, int width, int height) { JXPanel descriptionPanel = new JXPanel(); //descriptionPanel.setAlpha(.8f); descriptionPanel.setBounds(0, 0, width, height); descriptionPanel.setVisible(false); descriptionPanel.setLayout(null); //descriptionPanel.setBorder(BorderFactory.createLineBorder(Color.green)); JButton j = new JButton(""); j.setBounds(0, 0, width, height); j.setBackground(Color.black); j.setLayout(null); JLabel cardText = new JLabel(); cardText.setBounds(5, 5, width - 10, height - 10); cardText.setForeground(Color.white); cardText.setFont(cardNameFont); cardText.setVerticalAlignment(SwingConstants.TOP); j.add(cardText); TextLines textLines = GuiDisplayUtil.getTextLinesfromCardView(card); cardText.setText(getRulefromCardView(card, textLines).toString()); descriptionPanel.add(j); return descriptionPanel; }
private void applyUIStyle() { JXMonthView monthView = getMonthView(); monthView.setMonthStringBackground(backgroundColor); monthView.setMonthStringForeground(monthForegroundColor); monthView.setSelectionBackground(selectionBackgroundColor); monthView.setSelectionForeground(selectionForegroundColor); monthView.setDaysOfTheWeekForeground(dayOfTheWeekForegroundColor); monthView.setBackground(backgroundColor); monthView.setForeground(foregroundColor); monthView.setTodayBackground(todayBackgroundColor); getLinkPanel().setBackground(backgroundColor); getLinkPanel().setForeground(foregroundColor); } }
import java.text.SimpleDateFormat; import java.util.Calendar; import javax.swing.JFrame; import javax.swing.JPanel; import org.jdesktop.swingx.JXDatePicker; public class DatePickerExample extends JPanel { public static void main(String[] args) { JFrame frame = new JFrame("JXPicker Example"); JPanel panel = new JPanel(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(400, 400, 250, 100); JXDatePicker picker = new JXDatePicker(); picker.setDate(Calendar.getInstance().getTime()); picker.setFormats(new SimpleDateFormat("dd.MM.yyyy")); panel.add(picker); frame.getContentPane().add(panel); frame.setVisible(true); } }
final JXList list = new JXList(Locale.getAvailableLocales(), true); list.setSortOrder(SortOrder.ASCENDING); final PatternModel model = new PatternModel(); model.setMatchRule(PatternModel.MATCH_RULE_STARTSWITH); filter = RowFilters.regexFilter(newValue); list.setRowFilter(filter); model.addPropertyChangeListener(modelListener); popup.show(field, 0, field.getHeight()); model.setRawText(field.getText());
@Override protected Transferable createTransferable(JComponent c) { JXImageView view = (JXImageView)c; return new ImageTransferable(view.getImage(), view.getExportName(), view.getExportFormat()); }
@Override protected void setExpandedState(TreePath path, boolean state) { treeTable.getTreeTableHacker().completeEditing(); super.setExpandedState(path, state); treeTable.getTreeTableHacker().expansionChanged(); }
/** * Sets the <strong>User name</strong> for this panel. * * @param username User name */ public void setUserName(String username) { if (namePanel != null) { String old = getUserName(); namePanel.setUserName(username); firePropertyChange("userName", old, getUserName()); } }
private boolean canCacheSortColumn(MouseEvent e) { if (hasSortController() && !isInResizeRegion(e) && getResortsOnDoubleClick()) { return true; } return false; }
public void addActionListener(ActionListener actionListener) { datePicker.addActionListener(actionListener); } }
/** * Sets the tool bar property on the underlying {@code JXRootPane}. * * @param toolBar * the {@code JToolBar} which is to be the tool bar * @see #getToolBar() * @see JXRootPane#setToolBar(JToolBar) */ public void setToolBar(JToolBar toolBar) { getRootPane().setToolBar(toolBar); }
public void commitEdit() throws ParseException { commitTime(); super.commitEdit(); }
private void drawCardText(CardView card) { JXPanel panel = GuiDisplayUtil.getDescription(card, bigCard.getWidth(), bigCard.getHeight()); panel.setVisible(true); bigCard.hideTextComponent(); bigCard.addJXPanel(card.getId(), panel); }
public void cancelEdit() { super.cancelEdit(); setTimeSpinners(); }
@Override public JPanel getLinkPanel() { super.getLinkPanel(); if (timePanel == null) { timePanel = createTimePanel(); } setTimeSpinners(); return timePanel; }
private DateTimePicker() { super(null, Locale.getDefault()); getMonthView().setSelectionModel(new SingleDaySelectionModel()); }
private void displayCardInfo(MageCard mageCard, Image image, BigCard bigCard) { if (image instanceof BufferedImage) { // XXX: scaled to fit width bigCard.setCard(mageCard.getOriginal().getId(), enlargeMode, image, mageCard.getOriginal().getRules(), mageCard.getOriginal().isToRotate()); // if it's an ability, show only the ability text as overlay if (mageCard.getOriginal().isAbility() && enlargeMode == EnlargeMode.NORMAL) { bigCard.showTextComponent(); } else { bigCard.hideTextComponent(); } } else { JXPanel panel = GuiDisplayUtil.getDescription(mageCard.getOriginal(), bigCard.getWidth(), bigCard.getHeight()); panel.setVisible(true); bigCard.hideTextComponent(); bigCard.addJXPanel(mageCard.getOriginal().getId(), panel); } enlargeredViewOpened = new Date(); }