Java Code Examples for org.jdesktop.swingx.decorator.HighlighterFactory

The following examples show how to use org.jdesktop.swingx.decorator.HighlighterFactory. These examples are extracted from open source projects. 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 Project: dsworkbench   Source File: TroopSetupConfigurationFrame.java    License: Apache License 2.0 6 votes vote down vote up
public void setup() {
    jAttackTypeTable.setModel(new AttackTypeTableModel());
    jAttackTypeTable.setHighlighters(HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
    jAttackTypeTable.getTableHeader().setDefaultRenderer(new UnitTableHeaderRenderer());
    jAttackTypeTable.setDefaultRenderer(TroopAmountElement.class, new StandardAttackTypeCellRenderer());
    jAttackTypeTable.setDefaultEditor(TroopAmountElement.class, new StandardAttackElementEditor());
    jAttackTypeTable.setDefaultEditor(Integer.class, new NoteIconCellEditor(NoteIconCellEditor.ICON_TYPE.NOTE));
    jAttackTypeTable.setRowHeight(24);
    jAttackTypeTable.getColumnExt(0).setMinWidth(120);
    jAttackTypeTable.getColumnExt(0).setPreferredWidth(120);
    jAttackTypeTable.setDefaultRenderer(Integer.class, new NoteIconCellRenderer(NoteIconCellRenderer.ICON_TYPE.NOTE));
    
    jAttackTypeIcon.setRenderer(new NoteIconListCellRenderer(NoteIconCellEditor.ICON_TYPE.NOTE));
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    for (int i = -1; i <= ImageManager.MAX_NOTE_SYMBOL; i++) {
        model.addElement(i);
    }
    jAttackTypeIcon.setModel(model);
}
 
Example 2
Source Project: dsworkbench   Source File: AttackTargetFilterPanel.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates new form AttackSourcePanel
 */
AttackTargetFilterPanel() {
    initComponents();
    jXCollapsiblePane1.setLayout(new BorderLayout());
    jXCollapsiblePane1.add(jInfoScrollPane, BorderLayout.CENTER);
    jVillageTable.setModel(new TAPTargetFilterTableModel());
    jVillageTable.setHighlighters(HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
    jInfoTextPane.setText(GENERAL_INFO);
    
    updateFilterPanel(new LinkedList<TAPAttackTargetElement>());
    overviewPanel = new VillageOverviewMapPanel();
    jPanel2.add(overviewPanel, BorderLayout.CENTER);
    AttackManager.getSingleton().addManagerListener(new GenericManagerListener() {

        @Override
        public void dataChangedEvent() {
            updateAttackList();
        }

        @Override
        public void dataChangedEvent(String pGroup) {
            dataChangedEvent();
        }
    });
}
 
Example 3
Source Project: dsworkbench   Source File: ValidationPanel.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates new form AttackSourcePanel
 */
ValidationPanel() {
    initComponents();
    jXCollapsiblePane1.setLayout(new BorderLayout());
    jXCollapsiblePane1.add(jInfoScrollPane, BorderLayout.CENTER);
    jInfoTextPane.setText(GENERAL_INFO);
    
    sourceOverviewPanel = new VillageOverviewMapPanel();
    jPanel2.add(sourceOverviewPanel, BorderLayout.CENTER);
    targetOverviewPanel = new VillageOverviewMapPanel();
    jPanel3.add(targetOverviewPanel, BorderLayout.CENTER);
    jXTable1.setModel(new VillageUsageTableModel());
    jXTable2.setModel(new VillageUsageTableModel());
    jXTable1.setHighlighters(HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
    jXTable1.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer());
    jXTable2.setHighlighters(HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
    jXTable2.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer());
    jXTable1.setDefaultRenderer(Float.class, new PercentCellRenderer());
    jXTable2.setDefaultRenderer(Float.class, new PercentCellRenderer());
}
 
Example 4
Source Project: dsworkbench   Source File: AttackSourceFilterPanel.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates new form AttackSourcePanel
 */
AttackSourceFilterPanel() {
    initComponents();
    jXCollapsiblePane1.setLayout(new BorderLayout());
    jXCollapsiblePane1.add(jInfoScrollPane, BorderLayout.CENTER);
    jVillageTable.setModel(new TAPSourceFilterTableModel());
    jVillageTable.setHighlighters(HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
    jInfoTextPane.setText(GENERAL_INFO);
    
    troopFilterDialog = new TroopFilterDialog(new JFrame(), true);
    updateFilterPanel(new LinkedList<TAPAttackSourceElement>());
    overviewPanel = new VillageOverviewMapPanel();
    jPanel2.add(overviewPanel, BorderLayout.CENTER);
    AttackManager.getSingleton().addManagerListener(new GenericManagerListener() {

        @Override
        public void dataChangedEvent() {
            updateAttackList();
        }

        @Override
        public void dataChangedEvent(String pGroup) {
            dataChangedEvent();
        }
    });
}
 
Example 5
Source Project: dsworkbench   Source File: RetimerSourceFilterPanel.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates new form AttackSourcePanel
 */
RetimerSourceFilterPanel() {
    initComponents();
    jXCollapsiblePane1.setLayout(new BorderLayout());
    jXCollapsiblePane1.add(jInfoScrollPane, BorderLayout.CENTER);
    jVillageTable.setModel(new RETSourceFilterTableModel());
    jVillageTable.setHighlighters(HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
    jInfoTextPane.setText(GENERAL_INFO);
    
    troopFilterDialog = new TroopFilterDialog(new JFrame(), true);
    updateFilterPanel(new LinkedList<RETSourceElement>());
    overviewPanel = new VillageOverviewMapPanel();
    jPanel2.add(overviewPanel, BorderLayout.CENTER);
    AttackManager.getSingleton().addManagerListener(new GenericManagerListener() {

        @Override
        public void dataChangedEvent() {
            updateAttackList();
        }

        @Override
        public void dataChangedEvent(String pGroup) {
            dataChangedEvent();
        }
    });
}
 
Example 6
Source Project: dsworkbench   Source File: LinkTagsDialog.java    License: Apache License 2.0 6 votes vote down vote up
public LinkedTag setupAndShow() {
    jXTable1.setModel(new TagLinkMatrixModel());
    HighlightPredicate.ColumnHighlightPredicate colu = new HighlightPredicate.ColumnHighlightPredicate(0);
    jXTable1.setHighlighters(new CompoundHighlighter(colu, HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B)));
    jXTable1.setColumnControlVisible(false);
    jXTable1.setDefaultRenderer(Integer.class, new MultiColorCellRenderer());
    jXTable1.setDefaultEditor(Integer.class, new LinkGroupColorCellEditor());
    jXTable1.setRowHeight(21);
    jXTable1.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer());
    setVisible(true);

    if (bCreateLinkedTag) {
        LinkedTag t = new LinkedTag(jTagName.getText(), true);
        String equation = ((TagLinkMatrixModel) jXTable1.getModel()).getEquation();
        equation = equation.replaceAll("UND", "&&");
        equation = equation.replaceAll("ODER", "||");
        t.setEquation(equation);
        t.updateVillageList();
        return t;
    }
    return null;
}
 
Example 7
Source Project: gameserver   Source File: ListSelectDialog.java    License: Apache License 2.0 6 votes vote down vote up
public ListSelectDialog(DefaultListModel listModel, ListCellRenderer cellRender) {
	this.listModel = listModel;
	
	list.setModel(listModel);
	list.setCellRenderer(cellRender);
	list.setSortable(true);
	list.setRolloverEnabled(true);
	list.addHighlighter(HighlighterFactory.createAlternateStriping());
	list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	JScrollPane pane = new JScrollPane(list);
	
	this.setMinimumSize(new Dimension(250, 400));
	this.setModal(true);
	this.setLayout(new MigLayout("wrap 1"));
	this.add(pane, "width 100%, height 85%, grow");
	this.add(new JXLabel("用Ctrl-F可以搜索列表"));
	JXButton okButton = new JXButton("确定");
	okButton.addActionListener(this);
	this.add(okButton, "align center");
	this.setLocation((MainFrame.screenWidth-200)/2, (MainFrame.screenHeight-400)/2);
	this.setVisible(true);
}
 
Example 8
Source Project: gameserver   Source File: AddRemoveList.java    License: Apache License 2.0 6 votes vote down vote up
public AddRemoveList(Object[] values) {
	addButton.setSize(36, 36);
	removeButton.setSize(36, 36);
	this.addButton.setActionCommand(ActionName.ADD.name());
	this.addButton.addActionListener(this);
	this.removeButton.setActionCommand(ActionName.DELETE.name());
	this.removeButton.addActionListener(this);
	this.field.setActionCommand(ActionName.ADD.name());
	this.field.addActionListener(this);
	this.field.setToolTipText("可直接输入逗号或者顿号分割的多项内容");
	
	list.setHighlighters(HighlighterFactory.createAlternateStriping());
	if ( values != null ) {
		for ( Object o : values ) {
			listModel.insertRow(o);
		}
	}
	list.setModel(listModel);
	
	JScrollPane pane = new JScrollPane(list);
	this.setLayout(new MigLayout("wrap 2"));
	this.add(pane, "spany 2, width 80%");
	this.add(addButton, "top");
	this.add(removeButton, "top");
	this.add(field, "newline, span, width 100%");
}
 
Example 9
Source Project: dsworkbench   Source File: SupportRefillSettingsPanel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates new form AttackSourcePanel
 */
SupportRefillSettingsPanel() {
    initComponents();
    jVillageTable.setModel(new REFSettingsTableModel());
    jXCollapsiblePane1.setLayout(new BorderLayout());
    jXCollapsiblePane1.add(jInfoScrollPane, BorderLayout.CENTER);
    jVillageTable.setHighlighters(HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
    jVillageTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer());

    KeyStroke bbCopy = KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK, false);
    jVillageTable.registerKeyboardAction(SupportRefillSettingsPanel.this, "BBCopy", bbCopy, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    capabilityInfoPanel1.addActionListener(SupportRefillSettingsPanel.this);
    
    jVillageTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            int selectedRows = jVillageTable.getSelectedRowCount();
            if (selectedRows != 0) {
                jStatusLabel.setText(selectedRows + " Dorf/Dörfer gewählt");
            }
        }
    });

    targetAmountPanel = new TroopSelectionPanelFixed();
    targetAmountPanel.setupDefense(TroopSelectionPanel.alignType.GROUPED, -1);
    jTargetAmountsPanel.add(targetAmountPanel, BorderLayout.CENTER);
    splitAmountPanel = new TroopSelectionPanelFixed();
    splitAmountPanel.setupDefense(TroopSelectionPanel.alignType.GROUPED, -1);
    jSplitSizePanel.add(splitAmountPanel, BorderLayout.CENTER);
    jInfoTextPane.setText(GENERAL_INFO);
    overviewPanel = new VillageOverviewMapPanel();
    jPanel2.add(overviewPanel, BorderLayout.CENTER);
}
 
Example 10
Source Project: dsworkbench   Source File: SupportRefillFinishPanel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates new form AttackSourcePanel
 */
SupportRefillFinishPanel() {
  initComponents();
  jXCollapsiblePane1.setLayout(new BorderLayout());
  jXCollapsiblePane1.add(jInfoScrollPane, BorderLayout.CENTER);
  jInfoTextPane.setText(GENERAL_INFO);
  jxResultsTable.setHighlighters(HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
  jxResultsTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer());
  jxResultsTable.setDefaultRenderer(UnitHolder.class, new UnitCellRenderer());
  jxResultsTable.setDefaultRenderer(Date.class, new DateCellRenderer());
  overviewPanel = new VillageOverviewMapPanel();
  jPanel5.add(overviewPanel, BorderLayout.CENTER);
  jXCollapsiblePane2.add(jSummaryPanel, BorderLayout.CENTER);
}
 
Example 11
Source Project: dsworkbench   Source File: AttackFinishPanel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates new form AttackSourcePanel
 */
AttackFinishPanel() {
    initComponents();
    jXCollapsiblePane1.setLayout(new BorderLayout());
    jXCollapsiblePane1.add(jInfoScrollPane, BorderLayout.CENTER);
    jInfoTextPane.setText(GENERAL_INFO);
    jButton1.setIcon(new ImageIcon("./graphics/big/axe.png"));
    jButton2.setIcon(new ImageIcon("./graphics/big/axe_unfilled.png"));
    jxResultsTable.setModel(new TAPResultTableModel());
    jxResultsTable.setHighlighters(HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
    jxResultsTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer());
    TAPResultDetailsTableModel model = new TAPResultDetailsTableModel();
    jXDetailsTable.setModel(model);
    jXDetailsTable.setHighlighters(HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
    jXDetailsTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer());
    jXDetailsTable.setDefaultRenderer(UnitHolder.class, new UnitCellRenderer());
    jXDetailsTable.setDefaultRenderer(Date.class, new DateCellRenderer());
    jXDetailsTable.setDefaultRenderer(Integer.class, new NoteIconCellRenderer(NoteIconCellRenderer.ICON_TYPE.NOTE));
    overviewPanel = new VillageOverviewMapPanel();
    jPanel5.add(overviewPanel, BorderLayout.CENTER);
    jXCollapsiblePane2.add(jSummaryPanel, BorderLayout.CENTER);
    StandardAttackManager.getSingleton().addManagerListener(new GenericManagerListener() {

        @Override
        public void dataChangedEvent() {
            updateStandardAttacks();
        }

        @Override
        public void dataChangedEvent(String pGroup) {
            dataChangedEvent();
        }
    });
    
    jStandardFake.setRenderer(new StandardAttackListCellRenderer());
    jStandardOff.setRenderer(new StandardAttackListCellRenderer());
}
 
Example 12
Source Project: dsworkbench   Source File: RetimerFinishPanel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates new form AttackSourcePanel
 */
RetimerFinishPanel() {
    initComponents();
    jXCollapsiblePane1.setLayout(new BorderLayout());
    jXCollapsiblePane1.add(jInfoScrollPane, BorderLayout.CENTER);
    jInfoTextPane.setText(GENERAL_INFO);
    jxResultsTable.setModel(new RETResultTableModel());
    jxResultsTable.setHighlighters(HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
    jxResultsTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer());
    jxResultsTable.setDefaultRenderer(Date.class, new ColoredDateCellRenderer());
    jxResultsTable.setDefaultRenderer(UnitHolder.class, new UnitCellRenderer());
    overviewPanel = new VillageOverviewMapPanel();
    jPanel5.add(overviewPanel, BorderLayout.CENTER);
}
 
Example 13
/**
 * Creates new form ResourceDataReadPanel
 */
ResourceDistributorDataReadPanel() {
    initComponents();
    jXCollapsiblePane1.setLayout(new BorderLayout());
    jXCollapsiblePane1.add(jInfoScrollPane, BorderLayout.CENTER);
    jInfoTextPane.setText(GENERAL_INFO);
    jAddAsBothButton.setIcon(new ImageIcon(ResourceDistributorDataReadPanel.class.getResource("/res/48x48/merchant_both.png")));
    jAddAsSenderButton.setIcon(new ImageIcon(ResourceDistributorDataReadPanel.class.getResource("/res/48x48/merchant_send.png")));
    jAddAsReceiverButton.setIcon(new ImageIcon(ResourceDistributorDataReadPanel.class.getResource("/res/48x48/merchant_receive.png")));

    jDataTable.setModel(new REDSourceTableModel());
    jDataTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer());
    jDataTable.setHighlighters(HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
    jDataTable.setDefaultRenderer(VillageMerchantInfo.Direction.class, new EnumImageCellRenderer(EnumImageCellRenderer.LayoutStyle.TradeDirection));
    jDataTable.setDefaultRenderer(Integer.class, new NumberFormatCellRenderer());
    jDataTable.setDefaultRenderer(StorageStatus.class, new StorageCellRenderer());

    TableSortController sorter = (TableSortController) jDataTable.getRowSorter();
    ResourceComparator resourceComparator = new ResourceComparator();
    sorter.setComparator(1, resourceComparator);
    SlashComparator splitComparator = new SlashComparator();
    sorter.setComparator(3, splitComparator);
    sorter.setComparator(4, splitComparator);

    KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false);
    ActionListener deleteListener = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            deleteSelection();
        }
    };
    jDataTable.registerKeyboardAction(deleteListener, "Delete", delete, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    capabilityInfoPanel1.addActionListener(deleteListener);
}
 
Example 14
Source Project: dsworkbench   Source File: DefenseAnalysePanel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates new form AttackSourcePanel
 */
DefenseAnalysePanel() {
    initComponents();
    jXCollapsiblePane1.setLayout(new BorderLayout());
    jXCollapsiblePane1.add(jInfoScrollPane, BorderLayout.CENTER);
    jInfoTextPane.setText(GENERAL_INFO);
    jButton1.setIcon(new ImageIcon("./graphics/big/lifebelt.png"));
    numFormat.setMaximumFractionDigits(0);
    numFormat.setMinimumFractionDigits(0);
    jxAttacksTable.setModel(new DefenseToolModel());
    jxAttacksTable.getColumnExt("Tendenz").setCellRenderer(new TendencyTableCellRenderer());
    jxAttacksTable.getColumnExt("Status").setCellRenderer(new DefenseStatusTableCellRenderer());
    jxAttacksTable.getColumnExt("Verlustrate").setCellRenderer(new LossRatioTableCellRenderer());
    jxAttacksTable.setDefaultRenderer(Date.class, new DateCellRenderer());
    jxAttacksTable.setHighlighters(HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
    jxAttacksTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer());
    overviewPanel = new VillageOverviewMapPanel();
    jPanel6.add(overviewPanel, BorderLayout.CENTER);

    ActionListener listener = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (e.getActionCommand().equals("Delete")) {
                deleteSelection();
            }
        }
    };
    KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false);
    jxAttacksTable.registerKeyboardAction(listener, "Delete", delete, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    capabilityInfoPanel1.addActionListener(listener);
}
 
Example 15
Source Project: dsworkbench   Source File: DefenseFilterPanel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates new form AttackSourcePanel
 */
DefenseFilterPanel() {
    initComponents();
    jVillageTable.setModel(new DEPFilterTableModel());
    jVillageTable.setHighlighters(HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
    jXCollapsiblePane1.setLayout(new BorderLayout());
    jXCollapsiblePane1.add(jInfoScrollPane, BorderLayout.CENTER);
    jInfoTextPane.setText(GENERAL_INFO);
    overviewPanel = new VillageOverviewMapPanel();
    jPanel4.add(overviewPanel, BorderLayout.CENTER);
}
 
Example 16
Source Project: dsworkbench   Source File: DefenseFinishPanel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates new form AttackSourcePanel
 */
DefenseFinishPanel() {
    initComponents();
    jxResultsTable.setModel(new DEPResultTableModel());
    jxResultsTable.setHighlighters(HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
    jxResultsTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer());
    jxResultsTable.getColumnExt("Status").setCellRenderer(new DefenseStatusTableCellRenderer());
    jXCollapsiblePane1.setLayout(new BorderLayout());
    jXCollapsiblePane1.add(jInfoScrollPane, BorderLayout.CENTER);
    jInfoTextPane.setText(GENERAL_INFO);
    overviewPanel = new VillageOverviewMapPanel();
    jPanel4.add(overviewPanel, BorderLayout.CENTER);
    jXCollapsiblePane2.add(jSummaryPanel, BorderLayout.CENTER);
}
 
Example 17
Source Project: dsworkbench   Source File: SupportDetailsDialog.java    License: Apache License 2.0 5 votes vote down vote up
public void setupAndShow(List<Village> pVillages) {
    jxSupportsTable.setHighlighters(HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
    jxSupportsTable.setColumnControlVisible(true);
    jxSupportsTable.setDefaultRenderer(Number.class, new NumberFormatCellRenderer());
    jxSupportsTable.getTableHeader().setDefaultRenderer(new SupportTableHeaderRenderer());
    jxSupportsTable.setDefaultRenderer(SupportType.DIRECTION.class, new SupportDirectionRenderer());
    SupportTableModel supportModel = new SupportTableModel(pVillages);
    jxSupportsTable.setModel(supportModel);
    setVisible(true);
    pack();
}
 
Example 18
public Example_7a_View() {
    super();
    setTitle(getClass().getSimpleName() + " " + ManagementFactory.getRuntimeMXBean().getName());

    setBounds(100, 100, 700, 500);
    setDefaultCloseOperation(StrictThreadingJFrame.EXIT_ON_CLOSE);
    getContentPane().setLayout(new BorderLayout(0, 0));

    final JXTable table = new JXTable(myTableModel);
    table.setHighlighters(HighlighterFactory.createSimpleStriping());
    table.setSortable(false);
    table.getTableHeader().setReorderingAllowed(false);

    myTableModel.addTableModelListener(new TableModelListener() {

        int lastRowCountScrolledTo = -1;

        @Override
        public void tableChanged(final TableModelEvent e) {
            if (TableUtilities.isInsert(e)) {
                final int currentRowCount = myTableModel.getRowCount();
                if (currentRowCount != lastRowCountScrolledTo) {
                    lastRowCountScrolledTo = currentRowCount;
                    SwingUtilities.invokeLater(() -> table.scrollRectToVisible(table.getCellRect(myTableModel.getRowCount() - 1, 0, false)));
                }
            }
        }
    });

    JScrollPane scrollPane = new JScrollPane(table);
    getContentPane().add(scrollPane, BorderLayout.CENTER);
}
 
Example 19
public Example_7_View() {
    super();
    setTitle(getClass().getSimpleName() + " " + ManagementFactory.getRuntimeMXBean().getName());

    setBounds(100, 100, 700, 500);
    setDefaultCloseOperation(StrictThreadingJFrame.EXIT_ON_CLOSE);
    getContentPane().setLayout(new BorderLayout(0, 0));

    final JXTable table = new JXTable(myTableModel);
    table.setHighlighters(HighlighterFactory.createSimpleStriping());
    table.setSortable(false);
    table.getTableHeader().setReorderingAllowed(false);

    myTableModel.addTableModelListener(new TableModelListener() {

        int lastRowCountScrolledTo = -1;

        @Override
        public void tableChanged(final TableModelEvent e) {
            if (TableUtilities.isInsert(e)) {
                final int currentRowCount = myTableModel.getRowCount();
                if (currentRowCount != lastRowCountScrolledTo) {
                    lastRowCountScrolledTo = currentRowCount;
                    SwingUtilities.invokeLater(() -> table.scrollRectToVisible(table.getCellRect(myTableModel.getRowCount() - 1, 0, false)));
                }
            }
        }
    });

    JScrollPane scrollPane = new JScrollPane(table);
    getContentPane().add(scrollPane, BorderLayout.CENTER);
}
 
Example 20
public Example_8_View() {
    super();
    setTitle(getClass().getSimpleName() + " " + ManagementFactory.getRuntimeMXBean().getName());

    setBounds(100, 100, 700, 500);
    setDefaultCloseOperation(StrictThreadingJFrame.EXIT_ON_CLOSE);
    getContentPane().setLayout(new BorderLayout(0, 0));

    final JXTable table = new JXTable(myTableModel);
    table.setHighlighters(HighlighterFactory.createSimpleStriping());
    table.setSortable(false);
    table.getTableHeader().setReorderingAllowed(false);

    myTableModel.addTableModelListener(new TableModelListener() {

        int lastRowCountScrolledTo = -1;

        @Override
        public void tableChanged(final TableModelEvent e) {
            if (TableUtilities.isInsert(e)) {
                final int currentRowCount = myTableModel.getRowCount();
                if (currentRowCount != lastRowCountScrolledTo) {
                    lastRowCountScrolledTo = currentRowCount;
                    SwingUtilities.invokeLater(() -> table.scrollRectToVisible(table.getCellRect(myTableModel.getRowCount() - 1, 0, false)));
                }
            }
        }
    });

    JScrollPane scrollPane = new JScrollPane(table);
    getContentPane().add(scrollPane, BorderLayout.CENTER);
}
 
Example 21
Source Project: gameserver   Source File: MyMiniTablePanel.java    License: Apache License 2.0 5 votes vote down vote up
/**
	 * Initialize method
	 */
	public void init() {
		this.setLayout(new MigLayout("ins 0, gap 0"));
		
		this.table.setEditable(true);
		this.table.setHighlighters(HighlighterFactory.createAlternateStriping());
		this.table.setDragEnabled(true);
		this.table.setHorizontalScrollEnabled(true);
		this.table.setColumnControlVisible(true);
		this.table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
		this.table.setEditorFactory(new DefaultEditorFactory(this));
		this.table.packAll();
				
		this.addRowButton.setEnabled(true);
		this.addRowButton.setMaximumSize(new Dimension(36, 36));
		this.addRowButton.setToolTipText("增加一行记录");
		
		this.delRowButton.setEnabled(true);
		this.delRowButton.setMaximumSize(new Dimension(36, 36));
		this.delRowButton.setToolTipText("删除一行记录");
		
		
//		this.table.setPreferredSize(new Dimension(MainFrame.screenWidth, MainFrame.screenHeight));
		JScrollPane pane = new JScrollPane(table);
		
		buttonBarPanel.setLayout(new MigLayout("wrap 1, insets 5"));
		buttonBarPanel.add(addRowButton,  "");
		buttonBarPanel.add(delRowButton,  "");
		
		this.add(titleLbl, "dock north, width 15%");
		this.add(buttonBarPanel, "dock east, width 36px");
		this.add(pane, "dock center, height 100%, grow, push");
	}
 
Example 22
Source Project: gameserver   Source File: AddRemoveComboList.java    License: Apache License 2.0 5 votes vote down vote up
public AddRemoveComboList(Object[] values, Object[] selectArrays) {
	addButton.setSize(36, 36);
	removeButton.setSize(36, 36);
	this.addButton.setActionCommand(ActionName.ADD.name());
	this.addButton.addActionListener(this);
	this.removeButton.setActionCommand(ActionName.DELETE.name());
	this.removeButton.addActionListener(this);
	
	field = new JXComboBox(selectArrays);
	this.field.setActionCommand(ActionName.ADD.name());
	this.field.addActionListener(this);
	
	list.setHighlighters(HighlighterFactory.createAlternateStriping());
	if ( values != null ) {
		for ( Object o : values ) {
			listModel.insertRow(o);
		}
	}
	list.setModel(listModel);
	
	JScrollPane pane = new JScrollPane(list);
	this.setLayout(new MigLayout("wrap 2"));
	this.add(pane, "spany 2, width 80%");
	this.add(addButton, "top");
	this.add(removeButton, "top");
	this.add(field, "newline, span, width 100%");
}
 
Example 23
Source Project: dsworkbench   Source File: DSWorkbenchSOSRequestAnalyzer.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Creates new form DSWorkbenchSOSRequestAnalyzer
 */
DSWorkbenchSOSRequestAnalyzer() {
    initComponents();
    centerPanel = new GenericTestPanel(true);
    jSOSPanel.add(centerPanel, BorderLayout.CENTER);
    centerPanel.setChildComponent(jSOSInputPanel);
    buildMenu();
    jButton1.setIcon(new ImageIcon("./graphics/big/find.png"));
    capabilityInfoPanel1.addActionListener(DSWorkbenchSOSRequestAnalyzer.this);
    //  KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK, false);
    KeyStroke bbCopy = KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK, false);
    KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false);
    //KeyStroke cut = KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK, false);
    // jAttacksTable.registerKeyboardAction(DSWorkbenchSOSRequestAnalyzer.this, "Copy", copy, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jAttacksTable.registerKeyboardAction(DSWorkbenchSOSRequestAnalyzer.this, "BBCopy", bbCopy, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jAttacksTable.registerKeyboardAction(DSWorkbenchSOSRequestAnalyzer.this, "Delete", delete, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    // jAttacksTable.registerKeyboardAction(DSWorkbenchSOSRequestAnalyzer.this, "Cut", cut, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jAttacksTable.getActionMap().put("find", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            //ignore find
        }
    });

    jAttacksTable.setModel(new DefenseToolModel());
    jAttacksTable.setHighlighters(HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
    jAttacksTable.getColumnExt("Tendenz").setCellRenderer(new TendencyTableCellRenderer());
    jAttacksTable.getColumnExt("Status").setCellRenderer(new DefenseStatusTableCellRenderer());
    //jAttacksTable.getColumnExt("Wall").setCellRenderer(new WallLevellCellRenderer());
    jAttacksTable.getColumnExt("Verlustrate").setCellRenderer(new LossRatioTableCellRenderer());
    jAttacksTable.setDefaultRenderer(Date.class, new DateCellRenderer());
    jAttacksTable.setColumnControlVisible(false);
    jAttacksTable.setDefaultRenderer(Date.class, new DateCellRenderer());
    jAttacksTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer());
    jAttacksTable.requestFocus();

    jSupportsTable.setModel(new SupportsModel());
    jSupportsTable.setHighlighters(HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
    jSupportsTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer());
    jSupportsTable.setDefaultRenderer(Date.class, new ColoredDateCellRenderer());
    jSupportsTable.setDefaultRenderer(Boolean.class, new CustomBooleanRenderer(CustomBooleanRenderer.LayoutStyle.SENT_NOTSENT));

    new SupportCountdownThread().start();
    new SupportColorUpdateThread().start();
    jXInfoLabel.setLineWrap(true);

    // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem ">
    if (!Constants.DEBUG) {
        GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.sos_analyzer", GlobalOptions.getHelpBroker().getHelpSet());
    }
    // </editor-fold>
}
 
Example 24
@Override
public void resetView() {
    AttackManager.getSingleton().addManagerListener(this);
    //setup renderer and general view
   // ((DoItYourselfAttackTableModel) jAttackTable.getModel()).clear();

    HighlightPredicate.ColumnHighlightPredicate colu = new HighlightPredicate.ColumnHighlightPredicate(0, 1, 2, 3, 6);
    jAttackTable.setRowHeight(24);
    jAttackTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer());
    jAttackTable.setHighlighters(new CompoundHighlighter(colu, HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B)));
    jAttackTable.setColumnControlVisible(true);
    jAttackTable.setDefaultEditor(UnitHolder.class, new UnitCellEditor());
    jAttackTable.setDefaultEditor(Village.class, new VillageCellEditor());
    jAttackTable.setDefaultRenderer(UnitHolder.class, new UnitCellRenderer());
    jAttackTable.setDefaultRenderer(Integer.class, new NoteIconCellRenderer(NoteIconCellRenderer.ICON_TYPE.NOTE));
    jAttackTable.setDefaultRenderer(Date.class, new ColoredDateCellRenderer());
    jAttackTable.setDefaultRenderer(Long.class, new ColoredCoutdownCellRenderer());
    jAttackTable.setDefaultEditor(Date.class, new DateSpinEditor());
    jAttackTable.setDefaultEditor(Integer.class, new NoteIconCellEditor(NoteIconCellEditor.ICON_TYPE.NOTE));
    BufferedImage back = ImageUtils.createCompatibleBufferedImage(5, 5, BufferedImage.BITMASK);
    Graphics2D g = back.createGraphics();
    GeneralPath p = new GeneralPath();
    p.moveTo(0, 0);
    p.lineTo(5, 0);
    p.lineTo(5, 5);
    p.closePath();
    g.setColor(Color.GREEN.darker());
    g.fill(p);
    g.dispose();
    jAttackTable.addHighlighter(new PainterHighlighter(HighlightPredicate.EDITABLE, new ImagePainter(back, HorizontalAlignment.RIGHT, VerticalAlignment.TOP)));

    DefaultComboBoxModel model = new DefaultComboBoxModel();
    DefaultComboBoxModel model2 = new DefaultComboBoxModel();
    for (UnitHolder unit : DataHolder.getSingleton().getUnits()) {
        model.addElement(unit);
        model2.addElement(unit);
    }
    jUnitBox.setModel(model);
    jUnitComboBox.setModel(model2);
    jUnitBox.setSelectedItem(DataHolder.getSingleton().getUnitByPlainName("ram"));
    jUnitComboBox.setSelectedItem(DataHolder.getSingleton().getUnitByPlainName("ram"));
    jUnitBox.setRenderer(new UnitListCellRenderer());
    jAttackTypeComboBox.setRenderer(new StandardAttackListCellRenderer());
    
    DefaultComboBoxModel typeModel = new DefaultComboBoxModel();

    for (ManageableType t : StandardAttackManager.getSingleton().getAllElements()) {
        StandardAttack a = (StandardAttack) t;
        typeModel.addElement(a);
    }
    jAttackTypeComboBox.setModel(typeModel);

    jUnitComboBox.setRenderer(new UnitListCellRenderer());

    jSourceVillage.setValue(new Point(500, 500));
    jTargetVillage.setValue(new Point(500, 500));
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            jSourceVillage.updateUI();
            jTargetVillage.updateUI();
        }
    });

}
 
Example 25
Source Project: dsworkbench   Source File: DefenseSourcePanel.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Creates new form AttackSourcePanel
 */
DefenseSourcePanel() {
    initComponents();
    jVillageTable.setModel(new DEPSourceTableModel());
    jVillageTable.setHighlighters(HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
    jVillageTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer());

    jXCollapsiblePane1.setLayout(new BorderLayout());
    jXCollapsiblePane1.add(jInfoScrollPane, BorderLayout.CENTER);
    villageSelectionPanel = new VillageSelectionPanel(new VillageSelectionPanel.VillageSelectionPanelListener() {

        @Override
        public void fireVillageSelectionEvent(Village[] pSelection) {
            addVillages(pSelection);
        }
    });

    villageSelectionPanel.enableSelectionElement(VillageSelectionPanel.SELECTION_ELEMENT.ALLY, false);
    villageSelectionPanel.enableSelectionElement(VillageSelectionPanel.SELECTION_ELEMENT.TRIBE, false);
    jPanel1.add(villageSelectionPanel, BorderLayout.CENTER);

    ActionListener listener = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (e.getActionCommand().equals("Paste")) {
                pasteFromClipboard();
            } else if (e.getActionCommand().equals("Delete")) {
                deleteSelection();
            }

        }
    };

    KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK, false);
    jVillageTable.registerKeyboardAction(listener, "Paste", paste, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false);
    jVillageTable.registerKeyboardAction(listener, "Delete", delete, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    capabilityInfoPanel1.addActionListener(listener);
    jInfoTextPane.setText(GENERAL_INFO);
    overviewPanel = new VillageOverviewMapPanel();
    jPanel2.add(overviewPanel, BorderLayout.CENTER);
}
 
Example 26
Source Project: dsworkbench   Source File: RankTableTab.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Creates new form AttackTablePanel
 */
public RankTableTab(RANK_TYPE pType, final ActionListener pActionListener) {
    eType = pType;
    initComponents();
    switch (eType) {
        case TRIBE: {
            buildTribeModel();
            break;
        }
        case ALLY: {
            buildAllyModel();
            break;
        }
        case TRIBE_BASH: {
            buildTribeBashModel();
            break;
        }
        case ALLY_BASH: {
            buildAllyBashModel();
            break;
        }
    }
    jScrollPane1.setViewportView(jxRankTable);
    jxRankTable.setRowHeight(24);
    jxRankTable.setHighlighters(HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
    jxRankTable.setColumnControlVisible(true);
    jxRankTable.setModel(theModel);
    List<SortKey> keys = new LinkedList<>();
    keys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
    jxRankTable.getRowSorter().setSortKeys(keys);
    jxRankTable.setDefaultRenderer(Integer.class, new NumberFormatCellRenderer());
    jxRankTable.setDefaultRenderer(Double.class, new NumberFormatCellRenderer());

    jxRankTable.getActionMap().put("find", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            pActionListener.actionPerformed(new ActionEvent(jxRankTable, 0, "Find"));
        }
    });

    jxRankTable.getSelectionModel().addListSelectionListener(RankTableTab.this);
}
 
Example 27
Source Project: CodenameOne   Source File: BaseForm.java    License: GNU General Public License v2.0 4 votes vote down vote up
public EditorTable() {
    setSortable(true);
    addHighlighter(HighlighterFactory.createSimpleStriping());
    addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, null, Color.RED));  
    setColumnControlVisible(true);
}
 
Example 28
Source Project: gameserver   Source File: UserBagDialog.java    License: Apache License 2.0 4 votes vote down vote up
public UserBagDialog(User user) {
		this.user = user;
		this.bag  = user.getBag();
		
		currCountTf.setText(String.valueOf(bag.getCurrentCount()));
		currCountTf.setEnabled(true);
		maxCountTf.setText(String.valueOf(bag.getMaxCount()));
		maxCountTf.setEnabled(true);

		DefaultListModel listModel = new DefaultListModel();
		bagList.setModel(listModel);
		bagList.setCellRenderer(new PropDataListCellRenderer());
		bagList.setDragEnabled(true);
		bagList.setHighlighters(HighlighterFactory.createAlternateStriping());
		bagList.addMouseListener(new MouseAdapter() {

			/* (non-Javadoc)
			 * @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
			 */
			@Override
			public void mouseClicked(MouseEvent e) {
				if ( e.getClickCount() == 2 ) {
					commandWearItem();
				}
			}
			
		});
		JScrollPane bagPane = new JScrollPane(bagList);
		bagPane.setBorder(BorderFactory.createTitledBorder("玩家当前背包内容"));
		
		updateBagStatus();
		updateWearStatus();
		updateUserStatus();
		
//		this.setBorder(BorderFactory.createTitledBorder("玩家" + user.getUsername() + "背包数据"));
		this.setLayout(new MigLayout("ins 10px"));
		this.add(currCountLbl, "");
		this.add(currCountTf, "gapright 10px");
		this.add(maxCountLbl, "");
		this.add(maxCountTf, "wrap");
		
		this.add(bagPane, "dock east, width 30%, height 100%, wrap");
		JXPanel wearPanel = new JXPanel();
		wearPanel.setLayout(new MigLayout("wrap 4"));
		for ( int i=1; i<wearBtns.length; i++ ) {
			if ( i % 4 == 0 ) {
				wearPanel.add(wearBtns[i], "sg wear, wrap, height 36px");
			} else {
				wearPanel.add(wearBtns[i], "sg wear, height 36px");
			}
		}
		this.add(wearPanel, "span, align center");
		
		this.addNewItemToBagBtn.setActionCommand(COMMAND_ADD_NEW);
		this.removeItemFromBagBtn.setActionCommand(COMMAND_REMOVE_ITEM);
		this.wearBagItemBtn.setActionCommand(COMMAND_WEAR_ITEM);
		this.modiBagItemBtn.setActionCommand(COMMAND_MODIFY_ITEM);
		
		this.okButton.setActionCommand(ActionName.OK.name());
		this.cancelButton.setActionCommand(ActionName.CANCEL.name());
		
		this.addNewItemToBagBtn.addActionListener(this);
		this.removeItemFromBagBtn.addActionListener(this);
		this.wearBagItemBtn.addActionListener(this);
		this.modiBagItemBtn.addActionListener(this);
		this.okButton.addActionListener(this);
		this.cancelButton.addActionListener(this);
		
		JXPanel btnPanel = new JXPanel();
		btnPanel.setLayout(new MigLayout("wrap 4"));
		btnPanel.add(addNewItemToBagBtn, "sg btn");
		btnPanel.add(removeItemFromBagBtn, "sg btn");
		btnPanel.add(wearBagItemBtn, "sg btn");
		btnPanel.add(modiBagItemBtn, "sg btn, wrap");
		btnPanel.add(okButton, "span, split 2, align center");
		btnPanel.add(cancelButton, "");
		
		this.userStatusLbl.setBackground(Color.WHITE);
		this.userStatusLbl.setFont(MainFrame.BIG_FONT);
		this.userStatusLbl.setHorizontalTextPosition(JLabel.CENTER);
		this.userStatusLbl.setBorder(BorderFactory.createEtchedBorder());

		
		this.add(userStatusLbl, "newline, span, width 70%, height 100px, align center, wrap");
		this.add(btnPanel, "dock south, span, align center");
		
		this.setModal(true);
		this.setSize(800, 600);
		Point p = WindowUtils.getPointForCentering(this);
		this.setLocation(p);
	}
 
Example 29
Source Project: gameserver   Source File: GuildManagePanel.java    License: Apache License 2.0 4 votes vote down vote up
public void init() {
		model = new GuildTreeTableModel();
		List<String> columnNames = new ArrayList<String>();
		columnNames.add("关键字");
		columnNames.add("值");
		columnNames.add("类型");
		model.setColumnIdentifiers(columnNames);
		model.addTreeModelListener(this);

		guildBagModel = new GuildBagTreeTableModel();
		guildBagModel.setColumnIdentifiers(columnNames);
		guildBagModel.addTreeModelListener(this);
		
		saveGuildAction = new GuildSaveAction(model, this);
		saveButton.setAction(saveGuildAction);
		delGuildAction = new GuildDeleteAction(model, this);
		delButton.setAction(delGuildAction);
		
		saveGuildBagAction = new GuildBagSaveAction(model, this);
		saveGuildBagButton.setAction(saveGuildAction);
		delGuildBagAction = new GuildBagDeleteAction(model, this);
		delGuildBagButton.setAction(delGuildAction);
		
		delGuildAction.setEnabled(false);
		delButton.setAction(delGuildAction);

		guildTable.setTreeTableModel(model);
		guildTable.setHighlighters(HighlighterFactory.createAlternateStriping());
		UserTreeRenderer render = new UserTreeRenderer();
		guildTable.setTreeCellRenderer(render);
		guildTable.setEditable(true);
		guildTable.setColumnControlVisible(true);
		guildTable.packAll();
		guildTable.addTreeSelectionListener(new GuildSelectionListener());
		JScrollPane pane = new JScrollPane(guildTable);
		
		guildBagTable.setTreeTableModel(guildBagModel);
		guildBagTable.setHighlighters(HighlighterFactory.createAlternateStriping());
		guildBagTable.setTreeCellRenderer(new UserTreeRenderer());
		guildBagTable.setEditable(true);
		guildBagTable.setColumnControlVisible(true);
		guildBagTable.packAll();
		guildBagTable.addTreeSelectionListener(new GuildSelectionListener());
		JScrollPane guildBagPane = new JScrollPane(guildBagTable);
		
//		TableColumnExt columnEx = myTable.getColumnExt("值");
//		columnEx.setCellEditor(new DefaultCellEditor(new JComboBox()));
		

		inputField.setColumns(20);
		inputField.setActionCommand(ActionName.OK.name());
		inputField.addActionListener(this);

		this.setLayout(new MigLayout("wrap 2"));
		this.add(searchLabel, "span, split 6");
		this.add(inputField, "");
		this.add(matchBox, "");
		this.add(serverBox, "");
		this.add(saveButton, "");
		this.add(delButton,  "");
		this.add(pane, "newline, width 100%, height 60%");
		this.add(guildBagPane, "newline, width 100%, height 40%");

		updateButtonStatus();
	}
 
Example 30
Source Project: gameserver   Source File: MyTablePanel.java    License: Apache License 2.0 4 votes vote down vote up
/**
	 * Initialize method
	 */
	public void init() {
		this.setLayout(new MigLayout("ins 0, gap 0"));
		
		this.titleBorder.setTitleFont(MainFrame.BIG_FONT);
		this.setBorder(titleBorder);
		this.table.setEditable(false);
		this.table.setHighlighters(HighlighterFactory.createAlternateStriping());
		this.table.setDragEnabled(true);
		this.table.setHorizontalScrollEnabled(true);
		this.table.setColumnControlVisible(true);
		this.table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
		this.table.setEditorFactory(new DefaultEditorFactory(this));
		this.table.packAll();
		
		this.filterField.setColumns(10);
		this.filterField.setAction(new MongoRowFilterAction(this));
		
		this.undoButton.setMaximumSize(new Dimension(36, 36));
		this.undoButton.setToolTipText("撤销上一步操作");
		
		this.redoButton.setMaximumSize(new Dimension(36, 36));
		this.redoButton.setToolTipText("重做上一步操作");
		
		this.addRowButton.setEnabled(true);
		this.addRowButton.setMaximumSize(new Dimension(36, 36));
		this.addRowButton.setToolTipText("增加一行记录");
		
		this.delRowButton.setEnabled(false);
		this.delRowButton.setMaximumSize(new Dimension(36, 36));
		this.delRowButton.setToolTipText("删除一行记录");
		
		this.refreshButton.setEnabled(true);
		this.refreshButton.setMaximumSize(new Dimension(36, 36));
		this.refreshButton.setToolTipText("刷新数据");
		
		this.exportButton.setAction(new MongoExportAction(this));
		this.exportButton.setMaximumSize(new Dimension(36, 36));
		this.exportButton.setToolTipText("导出为CSV文件");
		
		this.saveButton.setEnabled(false);
		this.saveButton.setMaximumSize(new Dimension(36, 36));
		this.saveButton.setToolTipText("保存临时工作区的内容");
		
//		this.table.setPreferredSize(new Dimension(MainFrame.screenWidth, MainFrame.screenHeight));
		JScrollPane pane = new JScrollPane(table);
		
		buttonBarPanel.setLayout(new MigLayout("wrap 8, align right, insets 5"));
//		buttonBarPanel.setMaximumSize(new Dimension(500, 40));
		buttonBarPanel.add(undoButton,    "");
		buttonBarPanel.add(redoButton,    "");
		buttonBarPanel.add(addRowButton,  "");
		buttonBarPanel.add(delRowButton,  "");
		buttonBarPanel.add(refreshButton, "");
		buttonBarPanel.add(exportButton, 	"");
		buttonBarPanel.add(saveButton,    "");
		buttonBarPanel.add(filterField,   "height 36px");
		
		this.add(buttonBarPanel, "wrap, align right, shrink, height 50px");
		this.add(pane, "span, width 100%, height 100%");
		
		//Register key map
		this.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
				KeyStroke.getKeyStroke('z', InputEvent.CTRL_DOWN_MASK), ActionName.UNDO);
		this.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
				KeyStroke.getKeyStroke('r', InputEvent.CTRL_DOWN_MASK), ActionName.REDO);
		this.getActionMap().put(ActionName.UNDO, undoAction);
		this.getActionMap().put(ActionName.REDO, redoAction);
	}