org.jdesktop.swingx.JXHyperlink Java Examples

The following examples show how to use org.jdesktop.swingx.JXHyperlink. 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: SendStatsConfigView.java    From otroslogviewer with Apache License 2.0 6 votes vote down vote up
public SendStatsConfigView(OtrosApplication otrosApplication) {
  super("sendStats", "Stats sending", DESCRIPTION);
  view = new JPanel(new MigLayout());

  JXHyperlink statsLink = new JXHyperlink(new AbstractAction("Open page with usage report") {
    @Override
    public void actionPerformed(ActionEvent e) {
      try {
        Desktop.getDesktop().browse(new URI("https://github.com/otros-systems/otroslogviewer-stats"));
      } catch (IOException | URISyntaxException e1) {
        LOGGER.warn("Can't open page with stats");
      }
    }
  });


  view.add(sendAnonymousStatsData, "wrap");
  view.add(notifyAboutSending, "wrap");
  view.add(new JXHyperlink(new ShowStats(otrosApplication)), "wrap");
  view.add(statsLink, "wrap");
  view.add(nextSend, "wrap");
}
 
Example #2
Source File: FlatDatePickerUI.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
@Override
public void installUI( JComponent c ) {
	// must get UI defaults here because installDefaults() is invoked after
	// installComponents(), which uses these values to create popup button

	padding = UIManager.getInsets( "ComboBox.padding" );

	arrowType = UIManager.getString( "Component.arrowType" );
	borderColor = UIManager.getColor( "Component.borderColor" );
	disabledBorderColor = UIManager.getColor( "Component.disabledBorderColor" );

	disabledBackground = UIManager.getColor( "ComboBox.disabledBackground" );

	buttonBackground = UIManager.getColor( "ComboBox.buttonBackground" );
	buttonArrowColor = UIManager.getColor( "ComboBox.buttonArrowColor" );
	buttonDisabledArrowColor = UIManager.getColor( "ComboBox.buttonDisabledArrowColor" );
	buttonHoverArrowColor = UIManager.getColor( "ComboBox.buttonHoverArrowColor" );

	super.installUI( c );

	LookAndFeel.installProperty( datePicker, "opaque", false );

	// hack JXDatePicker.TodayPanel colors
	// (there is no need to uninstall these changes because only UIResources are used,
	// which are automatically replaced when switching LaF)
	JPanel linkPanel = datePicker.getLinkPanel();
	if( linkPanel instanceof JXPanel && linkPanel.getClass().getName().equals( "org.jdesktop.swingx.JXDatePicker$TodayPanel" ) ) {
		((JXPanel)linkPanel).setBackgroundPainter( null );
		linkPanel.setBackground( UIManager.getColor( "JXMonthView.background" ) );

		if( linkPanel.getComponentCount() >= 1 && linkPanel.getComponent( 0 ) instanceof JXHyperlink ) {
			JXHyperlink todayLink = (JXHyperlink) linkPanel.getComponent( 0 );
			todayLink.setUnclickedColor( UIManager.getColor( "Hyperlink.linkColor" ) );
			todayLink.setClickedColor( UIManager.getColor( "Hyperlink.visitedColor" ) );
		}
	}
}
 
Example #3
Source File: LinkUtil.java    From chipster with MIT License 5 votes vote down vote up
public static JXHyperlink createLink(String text, Action action) {
	JXHyperlink link = new JXHyperlink();
	link.setBorder(null);
	link.setMargin(new Insets(0, 0, 0, 0));
	link.setAction(action);
	link.setText(text); // must be after setAction
	return link;
}
 
Example #4
Source File: DataDetails.java    From chipster with MIT License 5 votes vote down vote up
private JXHyperlink createHistoryLink(final DataBean data) {
	JXHyperlink link = new JXHyperlink();
	link.setText("Analysis history");
	link.addActionListener(new ActionListener() {		
		@Override
		public void actionPerformed(ActionEvent e) {				
			application.showHistoryScreenFor(data);
		}
	});
	return link;		
}
 
Example #5
Source File: GanttTaskPropertiesBean.java    From ganttproject with GNU General Public License v3.0 5 votes vote down vote up
private void constructEarliestBegin(Container propertiesPanel) {
  final JXHyperlink copyFromBeginDate = new JXHyperlink(new GPAction("option.taskProperties.main.earliestBegin.copyBeginDate") {
    @Override
    public void actionPerformed(ActionEvent e) {
      setThird(myTaskScheduleDates.getStart());
    }

    @Override
    protected String getLocalizedName() {
      String fallbackLabel = String.format("%s %s", language.getText("copy"), language.getText("generic.startDate.label"));
      return MoreObjects.firstNonNull(super.getLocalizedName(), fallbackLabel);
    }

  });
  myEarliestBeginDatePicker = UIUtil.createDatePicker();
  Box valueBox = Box.createHorizontalBox();
  myOnEarliestBeginToggle = new AbstractAction() {
    @Override
    public void actionPerformed(ActionEvent e) {
      myEarliestBeginDatePicker.setEnabled(myEarliestBeginEnabled.isSelected());
      if (getThird() == null) {
        setThird(myTaskScheduleDates.getStart());
      }
      copyFromBeginDate.setEnabled(myEarliestBeginEnabled.isSelected());
    }
  };
  myEarliestBeginEnabled = new JCheckBox(myOnEarliestBeginToggle);
  valueBox.add(myEarliestBeginEnabled);
  valueBox.add(Box.createHorizontalStrut(10));
  valueBox.add(myEarliestBeginDatePicker);
  valueBox.add(Box.createHorizontalStrut(5));
  valueBox.add(copyFromBeginDate);
  propertiesPanel.add(new JLabel(language.getText("earliestBegin")));
  propertiesPanel.add(valueBox);
}
 
Example #6
Source File: LookAndFeelUtil.java    From otroslogviewer with Apache License 2.0 5 votes vote down vote up
@Override
protected void addBasicDefaults(LookAndFeelAddons addon, DefaultsList defaults) {
  super.addBasicDefaults(addon, defaults);
  defaults.add(JXHyperlink.uiClassID, "org.jdesktop.swingx.plaf.basic.BasicHyperlinkUI");
  //register color that works for light and dark theme
  defaults.add("Hyperlink.linkColor", new ColorUIResource(80, 0x80, 0xFF));
}
 
Example #7
Source File: DesktopLink.java    From cuba with Apache License 2.0 5 votes vote down vote up
public DesktopLink() {
    impl = new JXHyperlink();
    impl.setAction(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String targetUrl = DesktopLink.this.url;
            if (StringUtils.isNotEmpty(targetUrl)) {
                DesktopWindowManager wm = App.getInstance().getMainFrame().getWindowManager();
                wm.showWebPage(targetUrl, Collections.<String, Object>emptyMap());
            }
        }
    });
}
 
Example #8
Source File: CollectStatsPage.java    From otroslogviewer with Apache License 2.0 5 votes vote down vote up
CollectStatsPage() {
  super("Send anonymous usage data", "Sends anonymous statistic");
  this.setLayout(new MigLayout());

  final JCheckBox checkVersionOnStartup = new JCheckBox("Check for new version on startup", true);
  checkVersionOnStartup.setName(Config.CHECK_FOR_NEW_VERSION);

  final JCheckBox sendAnonymousStatsData = new JCheckBox("Send anonymous stats data", true);
  sendAnonymousStatsData.setName(Config.COLLECT_STATS);

  final JCheckBox notifyAboutSending = new JCheckBox("Notify when sending stats", false);
  checkVersionOnStartup.setName(Config.COLLECT_STATS_NOTIFY);

  JXHyperlink statsLink = new JXHyperlink(new AbstractAction("Stats will be available here") {
    @Override
    public void actionPerformed(ActionEvent e) {
      try {
        Desktop.getDesktop().browse(new URI("https://github.com/otros-systems/otroslogviewer-stats"));
      } catch (IOException | URISyntaxException e1) {
       LOGGER.warn("Can't open page with stats");
      }
    }
  });

  final JTextArea textArea = new JTextArea(EXAMPLE_STATS);
  textArea.setEditable(false);
  textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, textArea.getFont().getSize()));
  final JScrollPane scrollPane = new JScrollPane(textArea);
  scrollPane.setBorder(BorderFactory.createTitledBorder("Example stats"));
  this.add(checkVersionOnStartup, "wrap,left");
  this.add(sendAnonymousStatsData, "wrap, left");
  this.add(notifyAboutSending, "wrap, left");
  this.add(statsLink, "wrap, left");
  this.add(scrollPane);
}
 
Example #9
Source File: DesktopRowsCount.java    From cuba with Apache License 2.0 5 votes vote down vote up
public RowsCountComponent() {
    LC lc = new LC();
    lc.hideMode(2);
    lc.insetsAll("2");

    layout = new MigLayout(lc);
    if (LayoutAdapter.isDebug()) {
        lc.debug(1000);
    }
    setLayout(layout);

    firstButton = new JButton("<<");
    add(firstButton);
    firstButton.setPreferredSize(size);
    firstButton.setMinimumSize(size);

    prevButton = new JButton("<");
    add(prevButton);
    prevButton.setPreferredSize(size);
    prevButton.setMinimumSize(size);

    label = new JLabel();
    label.setMinimumSize(size);
    add(label);

    countButton = new JXHyperlink();
    countButton.setText("[?]");
    add(countButton);

    nextButton = new JButton(">");
    add(nextButton);
    nextButton.setPreferredSize(size);
    nextButton.setMinimumSize(size);

    lastButton = new JButton(">>");
    add(lastButton);
    lastButton.setPreferredSize(size);
    lastButton.setMinimumSize(size);
}
 
Example #10
Source File: WindowBreadCrumbs.java    From cuba with Apache License 2.0 5 votes vote down vote up
public void update() {
    removeAll();
    btn2win.clear();
    for (Iterator<Window> it = windows.iterator(); it.hasNext();) {
        Window window = it.next();
        JButton button = new JXHyperlink();
        button.setFocusable(false);
        button.setText(StringUtils.trimToEmpty(window.getCaption()));
        button.addActionListener(new ValidationAwareActionListener() {
            @Override
            public void actionPerformedAfterValidation(ActionEvent e) {
                JButton btn = (JButton) e.getSource();
                Window win = btn2win.get(btn);
                if (win != null) {
                    fireListeners(win);
                }
            }
        });

        btn2win.put(button, window);

        if (it.hasNext()) {
            add(button);
            JLabel separatorLab = new JLabel(">");
            add(separatorLab);
        } else {
            add(new JLabel(window.getCaption()));
        }
    }
}
 
Example #11
Source File: LinkUtil.java    From chipster with MIT License 4 votes vote down vote up
public static void addLink(String description, JXHyperlink link, ImageIcon icon, GridBagConstraints c, JComponent component, int maxRowChars, Color background) {
	List<JXHyperlink> list = new LinkedList<JXHyperlink>();
	list.add(link);
	addLinks(description, list, icon, c, component, maxRowChars, background);
}
 
Example #12
Source File: DarkTaskPaneUI.java    From darklaf with MIT License 4 votes vote down vote up
@Override
protected void configure(final JXHyperlink link) {
    super.configure(link);
    link.setFocusPainted(false);
}
 
Example #13
Source File: QuickLinkPanel.java    From chipster with MIT License 4 votes vote down vote up
public static void addLinks(String description, List<JXHyperlink> links, String iconPath, GridBagConstraints c, JComponent component) {
	LinkUtil.addLinks(description, links, VisualConstants.getIcon(iconPath), c, component, MAX_ROW_CHARS, Color.white);
}
 
Example #14
Source File: DataDetails.java    From chipster with MIT License 4 votes vote down vote up
public LinkMouseListener(JXHyperlink link) {
	this.link = link;
}
 
Example #15
Source File: BasicModule.java    From chipster with MIT License 4 votes vote down vote up
@Override
public void addImportLinks(QuickLinkPanel quickLinkPanel, List<JXHyperlink> importLinks) {
	// do nothing
}
 
Example #16
Source File: MicroarrayModule.java    From chipster with MIT License 4 votes vote down vote up
@Override
public void addImportLinks(QuickLinkPanel quickLinkPanel, List<JXHyperlink> importLinks) {
	// do nothing
}
 
Example #17
Source File: KielipankkiModule.java    From chipster with MIT License 4 votes vote down vote up
@Override
public void addImportLinks(QuickLinkPanel quickLinkPanel, List<JXHyperlink> importLinks) {
	// do nothing
}
 
Example #18
Source File: DesktopLinkButton.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
protected JButton createImplementation() {
    final JXHyperlink link = new JXHyperlink();
    return link;
}
 
Example #19
Source File: GanttTaskPropertiesBean.java    From ganttproject with GNU General Public License v3.0 4 votes vote down vote up
/** Construct the general panel */
private void constructGeneralPanel() {
  final JPanel propertiesPanel = new JPanel(new SpringLayout());

  propertiesPanel.add(new JLabel(language.getText("name")));
  nameField1 = new JTextField(20);
  nameField1.setName("name_of_task");
  propertiesPanel.add(nameField1);
  Pair<String, JCheckBox> checkBox = constructCheckBox();
  if (checkBox != null) {
    propertiesPanel.add(new JLabel(checkBox.first()));
    propertiesPanel.add(checkBox.second());
  }
  addEmptyRow(propertiesPanel);

  myTaskScheduleDates.insertInto(propertiesPanel);

  constructEarliestBegin(propertiesPanel);
  addEmptyRow(propertiesPanel);

  propertiesPanel.add(new JLabel(language.getText("priority")));
  priorityComboBox = new JComboBox();
  for (Task.Priority p : Task.Priority.values()) {
    priorityComboBox.addItem(language.getText(p.getI18nKey()));
  }
  priorityComboBox.setEditable(false);
  propertiesPanel.add(priorityComboBox);

  propertiesPanel.add(new JLabel(language.getText("advancement")));
  SpinnerNumberModel spinnerModel = new SpinnerNumberModel(0, 0, 100, 1);
  percentCompleteSlider = new JSpinner(spinnerModel);
  propertiesPanel.add(percentCompleteSlider);

  addEmptyRow(propertiesPanel);

  propertiesPanel.add(new JLabel(language.getText("option.taskProperties.main.showInTimeline.label")));
  myShowInTimeline = new JCheckBox();
  propertiesPanel.add(myShowInTimeline);

  propertiesPanel.add(new JLabel(language.getText("shape")));
  shapeComboBox = new JPaintCombo(ShapeConstants.PATTERN_LIST);
  propertiesPanel.add(shapeComboBox);

  OptionsPageBuilder builder = new OptionsPageBuilder(GanttTaskPropertiesBean.this, OptionsPageBuilder.TWO_COLUMN_LAYOUT);
  builder.setUiFacade(myUIfacade);
  JPanel colorBox = new JPanel(new BorderLayout(5, 0));
  colorBox.add(builder.createColorComponent(myTaskColorOption).getJComponent(), BorderLayout.WEST);
  //colorBox.add(Box.createHorizontalStrut(5));
  colorBox.add(new JXHyperlink(mySetDefaultColorAction), BorderLayout.CENTER);
  //colorBox.add(Box.createHorizontalGlue());
  //colorBox.add(Box.createHorizontalGlue());
  //colorBox.add(Box.createHorizontalGlue());

  propertiesPanel.add(new JLabel(language.getText("colors")));
  propertiesPanel.add(colorBox);

  Box weblinkBox = Box.createHorizontalBox();
  tfWebLink = new JTextField(20);
  weblinkBox.add(tfWebLink);
  weblinkBox.add(Box.createHorizontalStrut(2));
  bWebLink = new TestGanttRolloverButton(new ImageIcon(getClass().getResource("/icons/web_16.gif")));
  bWebLink.setToolTipText(GanttProject.getToolTip(language.getText("openWebLink")));
  weblinkBox.add(bWebLink);

  bWebLink.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      // link to open the web link
      if (!BrowserControl.displayURL(tfWebLink.getText())) {
        GanttDialogInfo gdi = new GanttDialogInfo(null, GanttDialogInfo.ERROR, GanttDialogInfo.YES_OPTION,
            language.getText("msg4"), language.getText("error"));
        gdi.setVisible(true);
      }
    }
  });
  propertiesPanel.add(new JLabel(language.getText("webLink")));
  propertiesPanel.add(weblinkBox);

  SpringUtilities.makeCompactGrid(propertiesPanel, propertiesPanel.getComponentCount() / 2, 2, 1, 1, 5, 5);

  JPanel propertiesWrapper = new JPanel(new BorderLayout());
  propertiesWrapper.add(propertiesPanel, BorderLayout.NORTH);
  generalPanel = new JPanel(new SpringLayout());
  //generalPanel.add(new JLayer<JPanel>(propertiesPanel, layerUi));
  generalPanel.add(propertiesWrapper);
  generalPanel.add(notesPanel);
  SpringUtilities.makeCompactGrid(generalPanel, 1, 2, 1, 1, 10, 5);
}
 
Example #20
Source File: EmptyViewPanel.java    From otroslogviewer with Apache License 2.0 4 votes vote down vote up
private void initGui() {
  GridBagLayout bagLayout = new GridBagLayout();
  GridBagConstraints bagConstraints = new GridBagConstraints();
  bagConstraints.anchor = GridBagConstraints.EAST;
  bagConstraints.gridwidth = 3;
  bagConstraints.ipadx = 10;
  bagConstraints.ipady = 10;
  bagConstraints.gridy = 0;
  bagConstraints.fill = GridBagConstraints.NONE;
  this.setLayout(bagLayout);

  bagConstraints.insets = new Insets(5, 0, 0, 0);

  bagConstraints.insets = new Insets(2, 5, 1, 5);
  bagConstraints.anchor = GridBagConstraints.CENTER;
  bagConstraints.gridy++;

  this.add(jLabel, bagConstraints);
  bagConstraints.fill = GridBagConstraints.HORIZONTAL;
  bagConstraints.gridy++;

  final Action tailAction = new TailLogWithAutoDetectActionListener(otrosApplication);
  final JButton tailButton = new JButton(tailAction);
  tailButton.setName("Open log files");
  OtrosSwingUtils.fontSize2(tailButton);
  tailButton.setIcon(Icons.FOLDER_OPEN);
  this.add(tailButton, bagConstraints);
  bagConstraints.gridy++;

  final AdvanceOpenAction advanceOpenAction = new AdvanceOpenAction(otrosApplication);
  final JButton advanceOpenButton = new JButton(advanceOpenAction);
  advanceOpenButton.setName("Merge log files");
  OtrosSwingUtils.fontSize2(advanceOpenButton);
  advanceOpenButton.setIcon(Icons.ARROW_JOIN_24);
  this.add(advanceOpenButton, bagConstraints);
  bagConstraints.gridy++;

  OpenLogInvestigationAction openLogInvestigationAction = new OpenLogInvestigationAction(otrosApplication);
  JButton jb2 = new JButton("Open log investigation", Icons.IMPORT_24);
  OtrosSwingUtils.fontSize2(jb2);
  jb2.addActionListener(openLogInvestigationAction);
  this.add(jb2, bagConstraints);
  bagConstraints.gridy++;


  final JButton clipboardButton = new JButton(new ParseClipboard(otrosApplication));
  clipboardButton.setName("Parse clipboard");
  this.add(OtrosSwingUtils.fontSize2(clipboardButton), bagConstraints);
  bagConstraints.gridy++;

  final JButton startSocketButton = new JButton(new StartSocketListener(otrosApplication, logReaders));
  startSocketButton.setName("Start socket listener");
  this.add(OtrosSwingUtils.fontSize2(startSocketButton), bagConstraints);
  bagConstraints.gridy++;

  bagConstraints.insets = new Insets(20, 5, 20, 5);
  this.add(new JSeparator(SwingConstants.HORIZONTAL), bagConstraints);
  bagConstraints.insets = new Insets(2, 5, 0, 5);
  bagConstraints.gridy++;

  final JButton convertPatterButton = OtrosSwingUtils.fontSize2(new JButton(new ConvertLogbackLog4jPatternAction(otrosApplication)));
  this.add(convertPatterButton, bagConstraints);
  bagConstraints.gridy++;

  bagConstraints.gridy++;
  JTextArea visitTf = new JTextArea(
    "Have a different log format? Go to https://github.com/otros-systems/otroslogviewer/wiki/Log4jPatternLayout\nto check how to create a log parser based on the log4j PatternLayout.");
  visitTf.setEditable(false);
  visitTf.setBackground(new JLabel().getBackground());
  visitTf.setBorder(null);
  bagConstraints.gridwidth = 2;
  bagConstraints.gridx = 0;
  this.add(visitTf, bagConstraints);

  GoToDonatePageAction goToDonatePageAction = new GoToDonatePageAction(otrosApplication);
  JXHyperlink jxHyperlink = new JXHyperlink(goToDonatePageAction);
  bagConstraints.gridy++;
  bagConstraints.gridwidth = 2;
  bagConstraints.anchor = GridBagConstraints.EAST;
  bagConstraints.fill = GridBagConstraints.NONE;

  this.add(jxHyperlink, bagConstraints);
}
 
Example #21
Source File: DataDetails.java    From chipster with MIT License 3 votes vote down vote up
private Component createVisualisations() {
	JPanel panel = getPanelBase("wrap 1");
	
	List<VisualisationMethod> visualisations = VisualisationToolBar.getMethodsFor(datas);
		
	for (VisualisationMethod method : visualisations) {

		JXHyperlink link = new JXHyperlink();
		
		link.setBackground(new Color(0.95f, 0.95f, 0.95f));					
		
		link.addMouseListener(new LinkMouseListener(link));
		//hide focus border because it doesn't obey component size
		link.setFocusPainted(false);

		link.setIcon(method.getIcon());
		link.setIconTextGap(16);
		link.addActionListener(new VisualisationStarter(method, Session.getSession().getApplication()));
		link.setText(method.getName());
		
		panel.add(link, "width 300!, height 50!");
		
		focusableLinks.add(link);
	}
	
	return panel;
}
 
Example #22
Source File: Module.java    From chipster with MIT License 2 votes vote down vote up
/**
 * Adds import links link list.
 * 
 * @param quickLinkPanel quick link panel used when creating the links
 * @param importLinks link list to add to
 */
public void addImportLinks(QuickLinkPanel quickLinkPanel, List<JXHyperlink> importLinks);
 
Example #23
Source File: QuickLinkPanel.java    From chipster with MIT License 2 votes vote down vote up
public static void addLink(String description, JXHyperlink link, String iconPath, GridBagConstraints c, JComponent component) {

	LinkUtil.addLink(description, link, VisualConstants.getIcon(iconPath), c, component, MAX_ROW_CHARS, Color.white);
}