org.jdesktop.swingx.JXLabel Java Examples

The following examples show how to use org.jdesktop.swingx.JXLabel. 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: ListSelectDialog.java    From gameserver with 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 #2
Source File: JSONValidator.java    From r2m-plugin-android with Apache License 2.0 6 votes vote down vote up
private static void setMessageToField(JComponent field, String text, boolean isNeedVisible) {
    if (field instanceof JXLabel) {
        ((JXLabel) field).setText(text);
        if (isNeedVisible) {
            ((JXLabel) field).setIcon(PluginIcon.errorIcon);
        } else {
            ((JXLabel) field).setIcon(PluginIcon.validIcon);
        }
    } else if (field instanceof JTextField) {
        ((JTextField) field).setText(text);
        field.setVisible(isNeedVisible);
    } else if (field instanceof JTextArea) {
        ((JTextArea) field).setText(text);
        field.setVisible(isNeedVisible);
    }
}
 
Example #3
Source File: GedEntryComponent.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
public GedEntryComponent(GedEntry e, int w,int h) 
{
	setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
	setLayout(new BorderLayout(0, 0));
	this.w=w;
	this.h=h;
	lblDelete = new JLabel("X");
	lblDelete.setHorizontalAlignment(SwingConstants.RIGHT);
	add(lblDelete, BorderLayout.NORTH);
	
	
	JXLabel l = new JXLabel();
	l.setHorizontalAlignment(SwingConstants.CENTER);
	this.entry = e;
	l.setText(entry.getName());
	l.setIcon(entry.getIcon());
	l.setLineWrap(true);
	defaultColor = getBackground();
	
	if(entry.isImage())
		l.setIcon(getThumbnail());
	
	l.setVerticalTextPosition(SwingConstants.BOTTOM);
	l.setHorizontalTextPosition(SwingConstants.CENTER);
	
	setToolTipText(e.getName());
	setOpaque(true);
	setPreferredSize(new Dimension(w,h));
	
	add(l);
	
}
 
Example #4
Source File: WelcomePanel.java    From dsworkbench with Apache License 2.0 5 votes vote down vote up
private void fireMouseEnterLinkEvent(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_fireMouseEnterLinkEvent
    JXLabel source = ((JXLabel) evt.getSource());
    source.setEnabled(true);
    String text = welcomeTooltipMap.get(source);
    if (text == null) {
        text = welcomeTooltipMap.get(jContentLabel);
    }

    jContentLabel.setText(text);
    repaint();
}
 
Example #5
Source File: DependecyWPanel.java    From BART with MIT License 5 votes vote down vote up
private void initJXLabelDependency()   {
    fadeInTimeline = new Timeline(this); 
    labelDependency = new JXLabel();
    labelDependency.setOpaque(true);
    labelDependency.setMinimumSize(new Dimension(589, 200));
    labelDependency.setPreferredSize(new Dimension(589, 200));
    labelDependency.setLineWrap(false);
    labelDependency.setTextAlignment(JXLabel.TextAlignment.JUSTIFY);       
    labelDependency.setIcon(ImageUtilities.image2Icon(ImageUtilities.loadImage(R.IMAGE_NODE_DCS)));
    labelDependency.setIconTextGap(20);
}
 
Example #6
Source File: UserTreeRenderer.java    From gameserver with Apache License 2.0 5 votes vote down vote up
@Override
	public Component getTreeCellRendererComponent(JTree tree, Object value,
			boolean selected, boolean expanded, boolean leaf, int row,
			boolean hasFocus) {
//		Component comp = super.getTreeCellRendererComponent(tree, value, selected, expanded,
//				leaf, row, hasFocus);
		String text = "";
		if ( value != null ) {
			text = value.toString();
		}
		JXLabel label = new JXLabel(text);
		return label;
	}
 
Example #7
Source File: WelcomePanel.java    From dsworkbench with Apache License 2.0 4 votes vote down vote up
private void fireMouseExitLinkEvent(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_fireMouseExitLinkEvent
    ((JXLabel) evt.getSource()).setEnabled(false);
    jContentLabel.setText(welcomeTooltipMap.get(jContentLabel));
    repaint();
}
 
Example #8
Source File: TaskDependenciesPanel.java    From ganttproject with GNU General Public License v3.0 4 votes vote down vote up
private void setUpPredecessorComboColumn(Task[] predecessorCandidates, TableColumn predecessorColumn, final JTable predecessorTable) {
  final JComboBox<DependencyTableModel.TaskComboItem> comboBox = new JComboBox<>();

  int maxDigits = 0;
  for (Task task : predecessorCandidates) {
    comboBox.addItem(new DependencyTableModel.TaskComboItem(task));
    maxDigits = Math.max(maxDigits, (int) Math.log10(task.getTaskID()));
  }
  final int maxWidth = (maxDigits + 1) * 10;

  comboBox.setRenderer(new DefaultListCellRenderer() {
    private JLabel myId = new JLabel();
    private JXLabel myLabel = new JXLabel();
    private JPanel myBox = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 3));

    {
      myId.setEnabled(false);
      myId.setHorizontalAlignment(SwingConstants.RIGHT);
      myBox.add(myId);
      myBox.add(myLabel);
      myBox.setOpaque(true);
    }

    @Override
    public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      DependencyTableModel.TaskComboItem item = (DependencyTableModel.TaskComboItem) value;
      TaskManager taskManager = item.myTask.getManager();
      JComponent superResult = (JComponent) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
      if (index == -1) {
        return superResult;
      }
      myId.setPreferredSize(new Dimension(maxWidth, 10));
      myId.setFont(superResult.getFont().deriveFont(superResult.getFont().getSize() * 0.85f));
      myId.setText(String.valueOf(item.myTask.getTaskID()));
      myLabel.setText(item.myTask.getName());
      myLabel.setBorder(BorderFactory.createEmptyBorder(0,
          10 * (taskManager.getTaskHierarchy().getDepth(item.myTask) - 1),
          0, 0));
      myBox.setBorder(superResult.getBorder());
      myBox.setBackground(superResult.getBackground());
      myBox.setForeground(superResult.getForeground());
      return myBox;
    }
  });
  comboBox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      if (predecessorTable.getEditingRow() != -1) {
        DependencyTableModel.TaskComboItem selectedItem = (DependencyTableModel.TaskComboItem) comboBox.getSelectedItem();
        if (selectedItem != null) {
          predecessorTable.setValueAt(selectedItem, predecessorTable.getEditingRow(), 0);
          predecessorTable.setValueAt(TaskDependenciesPanel.CONSTRAINTS[0], predecessorTable.getEditingRow(), 2);
        }
      }
    }
  });
  comboBox.setEditable(false);
  predecessorColumn.setCellEditor(new DefaultCellEditor(comboBox));
}
 
Example #9
Source File: AddDBObjectRowDialog.java    From gameserver with Apache License 2.0 4 votes vote down vote up
/**
	 * Set the prototype object to copy all hidden fields with.
	 * 
	 * @param prototype
	 */
	public void setPrototype(DBObject prototype) {
		this.prototype = prototype;
		
		this.okButton.setActionCommand(ActionName.OK.toString());
		this.okButton.addActionListener(this);
		this.cancelButton.setActionCommand(ActionName.CANCEL.toString());
		this.cancelButton.addActionListener(this);
		
		Set<String> keys = prototype.keySet();
		int columnCount = keys.size();
		
		if ( columnCount > 0 ) { 
			labels = new JXLabel[columnCount];
			fields = new JXTextField[columnCount];
		}
		
		panel.setLayout(new MigLayout("wrap 4", "[15%][35%,grow][15%][35%,grow]"));
		Iterator<String> columnKeyIter = keys.iterator();
		TableModel model = table.getModel();
		
		if ( model instanceof MyTableModel ) {
			hiddenFields.addAll( ((MyTableModel)model).getHiddenFields() );
		}
		for ( int i=0; i<columnCount; i++ ) {
			String columnName = columnKeyIter.next();
			String localName  = ColumnNames.translate(columnName);
			String columnValue = String.valueOf(prototype.get(columnName));
			labels[i] = new JXLabel(localName);
			fields[i] = new JXTextField(columnValue);
			fields[i].setColumns(20);
//			fields[i].setColumns(15);
			fields[i].setText(columnValue);
			if ( hiddenFields.contains(columnName) ) {
				fields[i].setEnabled(false);
			}
			
			panel.add(labels[i], "sizegroup label");
			panel.add(fields[i], "sizegroup field");
		}
		panel.add(okButton, "newline, span, split 2, align center");
		panel.add(cancelButton, "");
		
		this.add(panel);
		this.setSize(600, (columnCount/4+1)*70+70);
		Point p = WindowUtils.getPointForCentering(this);
		this.setLocation(p);
		this.setModal(true);
		this.setVisible(true);
	}
 
Example #10
Source File: MainFrame.java    From nextreports-designer with Apache License 2.0 4 votes vote down vote up
private void initComponents() {
        Globals.setMainFrame(this);

        // better text visualization for disabled components
    	Options.setPopupDropShadowEnabled(true); // add drop shadow to popup menu
        UIDefaults uiDefaults = UIManager.getDefaults();
        uiDefaults.put("ComboBox.disabledForeground", Color.DARK_GRAY);
        uiDefaults.put("TextField.inactiveForeground", Color.DARK_GRAY);
        uiDefaults.put("TextArea.inactiveBackground", Color.WHITE);
        uiDefaults.put("FormattedTextField.inactiveForeground",Color.DARK_GRAY);
        uiDefaults.put("PasswordField.inactiveForeground",Color.DARK_GRAY);
        uiDefaults.put("CheckBox.disabledText", Color.DARK_GRAY);

        // internationalization
        UIManager.put("OptionPane.yesButtonText", I18NSupport.getString("optionpanel.yes"));
        UIManager.put("OptionPane.cancelButtonText", I18NSupport.getString("optionpanel.cancel"));
        UIManager.put("OptionPane.noButtonText", I18NSupport.getString("optionpanel.no"));
        UIManager.put("OptionPane.okButtonText", I18NSupport.getString("optionpanel.ok"));
        UIManager.put("OptionPane.messageDialogTitle", I18NSupport.getString("optionpanel.message"));
        UIManager.put("ColorChooser.okText", I18NSupport.getString("colorchooser.ok"));
        UIManager.put("ColorChooser.cancelText", I18NSupport.getString("colorchooser.cancel"));
        UIManager.put("ColorChooser.resetText", I18NSupport.getString("colorchooser.reset"));
        UIManager.put("FileChooser.saveInLabelText", I18NSupport.getString("FileChooser.saveInLabelText"));
        UIManager.put("FileChooser.fileNameLabelText", I18NSupport.getString("FileChooser.fileNameLabelText"));
        UIManager.put("FileChooser.folderNameLabelText", I18NSupport.getString("FileChooser.folderNameLabelText"));
        UIManager.put("FileChooser.filesOfTypeLabelText", I18NSupport.getString("FileChooser.filesOfTypeLabelText"));
        UIManager.put("FileChooser.saveButtonText", I18NSupport.getString("FileChooser.saveButtonText"));
        UIManager.put("FileChooser.cancelButtonText", I18NSupport.getString("FileChooser.cancelButtonText"));
        UIManager.put("FileChooser.saveButtonToolTipText", I18NSupport.getString("FileChooser.saveButtonToolTipText"));
        UIManager.put("FileChooser.cancelButtonToolTipText", I18NSupport.getString("FileChooser.cancelButtonToolTipText"));
        UIManager.put("FileChooser.upFolderToolTipText", I18NSupport.getString("FileChooser.upFolderToolTipText"));
        UIManager.put("FileChooser.homeFolderToolTipText", I18NSupport.getString("FileChooser.homeFolderToolTipText"));
        UIManager.put("FileChooser.newFolderToolTipText", I18NSupport.getString("FileChooser.newFolderToolTipText"));
        UIManager.put("FileChooser.listViewButtonToolTipText", I18NSupport.getString("FileChooser.listViewButtonToolTipText"));
        UIManager.put("FileChooser.detailsViewButtonToolTipText", I18NSupport.getString("FileChooser.detailsViewButtonToolTipText"));

        // docking
        UIManager.put(MyDoggyKeySpace.DRAG_ENABLED, false); 
        
        // inside connections dir are kept the queries/reports for every data source
        DefaultDataSourceManager.getInstance().load();
        File  connections = new File(FileReportPersistence.CONNECTIONS_DIR);
        if (!connections.exists()) {
            connections.mkdir();
        }
        // inside reports dir are kept the generated reports
        File reports = new File(ExportAction.REPORTS_DIR);
        if (!reports.exists()) {
            reports.mkdir();
        }

        // create workspace panel
        workspacePanel = new JXPanel(new CardLayout());
        
        // create query builder panel before menu(!!! for docking)
        qbPanel = new QueryBuilderPanel();
        qbPanel.initWorkspace();

        setLayout(new BorderLayout());
//        add(new MainToolBar(), BorderLayout.NORTH);
        setToolBar(new MainToolBar());

        statusBar = new JXStatusBar();
        //statusBar.add(new JXLabel(""), JXStatusBar.Constraint.ResizeBehavior.FILL);
        statusBar.add(new JXLabel(""), new JXStatusBar.Constraint(JXStatusBar.Constraint.ResizeBehavior.FILL, new Insets(0,5,2,2)));        
        statusBar.add(new MemoryStatus());
        statusBar.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));                
        setStatusBar(statusBar);

        WorkspaceManager workspaceManager = WorkspaceManager.getInstance();
        workspacePanel.add((Component) workspaceManager.getQueryWorkspace().getToolWindowManager(), WorkspaceManager.QUERY_WORKSPACE);
        workspacePanel.add((Component) workspaceManager.getReportWorkspace().getToolWindowManager(), WorkspaceManager.REPORT_WORKSPACE);
        workspacePanel.add((Component) workspaceManager.getChartWorkspace().getToolWindowManager(), WorkspaceManager.CHART_WORKSPACE);
        add(workspacePanel, BorderLayout.CENTER);
        
        DataSource ds = DefaultDataSourceManager.getInstance().getConnectedDataSource();
        if (ds != null) {
            setStatusBarMessage("<html>" + I18NSupport.getString("datasource.active") + 
            		" <b>" + ds.getName() + "</b></html>");
        }

        setJMenuBar(new MainMenuBar());

        Globals.getMainMenuBar().actionUpdate(ds != null);
        Globals.getMainToolBar().actionUpdate(ds != null);
        
        String systemReport = Globals.getSystemReport();
        String systemChart = Globals.getSystemChart();
        String systemPath = Globals.getSystemPath();
        if (systemReport !=  null) {
        	openSystemReport(systemReport, systemPath);
        } else if (systemChart !=  null) {
        	openSystemChart(systemChart, systemPath);
        }
        
    }
 
Example #11
Source File: MainFrame.java    From nextreports-designer with Apache License 2.0 4 votes vote down vote up
public void setStatusBarMessage(String message) {
    if (statusBar != null) {
        ((JXLabel) statusBar.getComponent(0)).setText(message);
    }
}