jiconfont.swing.IconFontSwing Java Examples

The following examples show how to use jiconfont.swing.IconFontSwing. 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: ChatPanel.java    From btdex with GNU General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) {
	IconFontSwing.register(FontAwesome.getIconFont());

	JFrame f = new JFrame("Chat test");
	f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	
	ChatPanel chat = new ChatPanel();
	f.getContentPane().add(chat);
	
	chat.appendFriendMessage("Message from friend");
	chat.appendMeMyMessage("Message from me");
	chat.appendFriendMessage("Another from friend");
	chat.appendMeMyMessage("Another from me, but this is a very long message, very very very long message");
	
	f.pack();
	f.setLocationRelativeTo(null);
	f.setVisible(true);
}
 
Example #2
Source File: SocialButton.java    From btdex with GNU General Public License v3.0 5 votes vote down vote up
public SocialButton(Type type, Color color) {
	this.type = type;
	IconCode icon = null;
	String name = null;
	int size = 18;
	switch (type) {
	case FACEBOOK:
		icon = Icons.FACEBOOK;
		name = "Facebook";
		break;
	case INSTAGRAM:
		icon = Icons.INSTAGRAM;
		name = "Instagram";
		break;
	case GOOGLE_PLUS:
		icon = Icons.GOOGLE_PLUS;
		name = "Google Plus";
		break;
	case REDDIT:
		icon = Icons.REDDIT;
		name = "Reddit";
		break;
	case TELEGRAM:
		icon = Icons.TELEGRAM;
		name = "Reddit";
		break;
	case WHATSAPP:
		icon = Icons.WHATSAPP;
		name = "Reddit";
		break;
	default:
		icon = Icons.TWITTER;
		name = "Twitter";
		tags = "\n#DEX #crypto @btdex_trade";
		break;
	}
	setIcon(IconFontSwing.buildIcon(icon, size, color));
	setToolTipText(Translation.tr("social_share", name));
	addActionListener(this);
}
 
Example #3
Source File: Icons.java    From btdex with GNU General Public License v3.0 5 votes vote down vote up
public Icon get(IconCode icon) {
	Icon ret = icons.get(icon);
	if(ret == null) {
		ret = IconFontSwing.buildIcon(icon, size, color);
	}
	return ret;
}
 
Example #4
Source File: Application.java    From 07kit with GNU General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
    Logger.getRootLogger().addAppender(new Appender(new SimpleLayout()));
    final Logger logger = Logger.getLogger(Application.class);
    try {
        if (args.length > 0 && args[0] != null && args[0].trim().equals("-dev")) {
            devMode = true;
        }

        setOSXDockIcon();
        prepareEnvironment();

        SwingUtilities.invokeAndWait(() -> {
            IconFontSwing.register(FontAwesome.getIconFont());
            COLOUR_SCHEME.init();
            new SidebarController();
            new MainController();
            new LoginController();
            new SettingsDebugController();
            new WidgetDebugController();
            new SettingsController();
            new GalleryController();

            Session.get().onAuthenticated();
            ControllerManager.get(MainController.class).show();
        });
    } catch (Throwable t) {
        logger.error("Initialization failed.", t);
    }
}
 
Example #5
Source File: MaterialImageFactory.java    From material-ui-swing with MIT License 5 votes vote down vote up
/**
 * This method utilized this library for make the icons https://jiconfont.github.io/swing
 * by default the material-ui-swing utilized the Google font https://jiconfont.github.io/swing
 * but you can set other type of font with method
 * @param iconCode
 * @param dimension: Is the dimension of icons, by default this library used dimension = 20
 * @param color: Is the color of icons, by default this library used color = MaterialColors.BLACK;
 * @return
 */
public ImageIconUIResource getImage(IconCode iconCode, int dimension, Color color){
	if(iconCode == null || dimension <= 0){
		String errorMessage = "Don't know motivation this exceptions";
		if(iconCode == null){
			if(errorMessage.contains("Don\'t know motivation this exceptions")){
				errorMessage = "";
			}
			errorMessage += "\n- Icon code null, you can found the name icon color here: " +
					"https://material.io/resources/icons/?style=baseline\n" +
					"an valid code can be this: " +
					"MaterialImageFactory.getInstance().getImage(" +
					"GoogleMaterialDesignIcons.KEYBOARD_ARROW_RIGHT, Color.BLUE);";
		}
		if(dimension <= 0){
			if(errorMessage.contains("Don\'t know motivation this exceptions")){
				errorMessage = "";
			}
			errorMessage += "\n- Dimension of icon doesn't valid, you should insert the dimension > 0";
		}
		errorMessage += "\n\n";
		throw new IllegalArgumentException(errorMessage);
	}
	String key;
	if(color == null){
		color = MaterialColors.BLACK;
	}
	key = iconCode.name() + dimension + color.toString();

	if(cacheImage.containsKey(key)){
		return cacheImage.get(key);
	}

	ImageIconUIResource icon = new ImageIconUIResource(IconFontSwing.buildImage(iconCode, dimension, color));
	cacheImage.put(key, icon);
	return icon;
}
 
Example #6
Source File: TransactionsPanel.java    From btdex with GNU General Public License v3.0 4 votes vote down vote up
public TransactionsPanel() {
	super(new BorderLayout());

	table = new JTable(model = new MyTableModel());
	table.setRowHeight(table.getRowHeight()+10);
	table.setRowSelectionAllowed(false);
	table.getTableHeader().setReorderingAllowed(false);
	
	copyIcon = IconFontSwing.buildIcon(Icons.COPY, 12, table.getForeground());
	expIcon = IconFontSwing.buildIcon(Icons.EXPLORER, 12, table.getForeground());

	JScrollPane scrollPane = new JScrollPane(table);
	table.setFillsViewportHeight(true);

	// Center header and all columns
	DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
	centerRenderer.setHorizontalAlignment( JLabel.CENTER );
	for (int i = 0; i < table.getColumnCount(); i++) {
		table.getColumnModel().getColumn(i).setCellRenderer( centerRenderer );			
	}
	JTableHeader jtableHeader = table.getTableHeader();
	DefaultTableCellRenderer rend = (DefaultTableCellRenderer) table.getTableHeader().getDefaultRenderer();
	rend.setHorizontalAlignment(JLabel.CENTER);
	jtableHeader.setDefaultRenderer(rend);

	table.setAutoCreateColumnsFromModel(false);

	table.getColumnModel().getColumn(COL_ID).setCellRenderer(OrderBook.BUTTON_RENDERER);
	table.getColumnModel().getColumn(COL_ID).setCellEditor(OrderBook.BUTTON_EDITOR);
	table.getColumnModel().getColumn(COL_ACCOUNT).setCellRenderer(OrderBook.BUTTON_RENDERER);
	table.getColumnModel().getColumn(COL_ACCOUNT).setCellEditor(OrderBook.BUTTON_EDITOR);
	//
	table.getColumnModel().getColumn(COL_ACCOUNT).setPreferredWidth(200);
	table.getColumnModel().getColumn(COL_ID).setPreferredWidth(200);
	table.getColumnModel().getColumn(COL_TIME).setPreferredWidth(120);
	
	statusLabel = new JLabel(" ", JLabel.RIGHT);
	statusLabel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));

	add(statusLabel, BorderLayout.PAGE_START);
	add(scrollPane, BorderLayout.CENTER);
}
 
Example #7
Source File: ChatPanel.java    From btdex with GNU General Public License v3.0 4 votes vote down vote up
public ChatPanel() {
  	super(new BorderLayout());

JPanel addressPanel = new JPanel(new BorderLayout());
addressPanel.setBorder(BorderFactory.createTitledBorder("Your contacts"));
addressList = new JList<>();
addressList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
addressList.setPreferredSize(new Dimension(300, 300));
addressPanel.add(addressList, BorderLayout.CENTER);		
add(addressPanel, BorderLayout.LINE_START);
addressList.addListSelectionListener(this);

pinField = new JPasswordField(12);
pinField.addActionListener(this);

  	JPanel panelSendMessage = new JPanel(new BorderLayout());
      inputField = new JTextField();
      inputField.setToolTipText("Enter your message");
      panelSendMessage.add(new Desc("Enter your message", inputField), BorderLayout.CENTER);
      inputField.addActionListener(this);
      inputField.setEnabled(false);

      btnSend = new JButton("");
Icon sendIcon = IconFontSwing.buildIcon(FontAwesome.PAPER_PLANE_O, 24, btnSend.getForeground());
      btnSend.setIcon(sendIcon);
      btnSend.setToolTipText("Send your message");
      btnSend.addActionListener(this);
      btnSend.setEnabled(false);
      panelSendMessage.add(new Desc(" ", btnSend), BorderLayout.EAST);

      displayField = new JTextPane();
      displayField.setContentType("text/html");
      displayField.setEditable(false);
      displayField.setText(HTML_FORMAT);

      scrollPane = new JScrollPane(displayField);
      scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
      
      JPanel panelCenter = new JPanel(new BorderLayout());
      panelCenter.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
      add(panelCenter, BorderLayout.CENTER);
      
      panelCenter.add(scrollPane, BorderLayout.CENTER);
      panelCenter.add(panelSendMessage, BorderLayout.SOUTH);
      
      setSize(280, 400);
  }
 
Example #8
Source File: Save.java    From Hollow-Knight-SaveManager with GNU General Public License v3.0 4 votes vote down vote up
/**
 * This SavePanel creates a user data manager and its necessary buttons.
 * 
 * @param gui the listener to the SavePanel 
 * @param file the name of the file to be opened or created
 */
public Save(GUI gui, String file){
	/* ******** *
	 * PRE-INIT *
	 * ******** */
	IconFontSwing.register(FontAwesome.getIconFont());
	this.setLayout(new BorderLayout());
	
	/* Set & Load start values for Save Overview Labels */
	initializeLabels(gui, file);
	
	/* ******* *
	 * BUTTONS *
	 * ******* */
	
	/* Load < */
	load = new JButton();
	load.setIcon(IconFontSwing.buildIcon(FontAwesome.CHEVRON_LEFT, 18));
	load.addActionListener(new Listeners.Load(gui, fileName));
	
	/* Save > */
	save = new JButton();
	save.setIcon(IconFontSwing.buildIcon(FontAwesome.CHEVRON_RIGHT, 18));
	save.addActionListener(new Listeners.Save(gui, fileName));
	
	/* Save As [] */
	saveAs = new JButton();
	saveAs.setIcon(IconFontSwing.buildIcon(FontAwesome.FLOPPY_O, 18));
	saveAs.addActionListener(new Listeners.SaveAs(gui, fileName));
	
	/* ************ *
	 * CONTENT INIT *
	 * ************ */
	
	Content = new JPanel();
	Content.setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.fill = GridBagConstraints.BOTH;
	
	/* Overview */
	Overview = new JPanel();
	Overview.setLayout(new GridBagLayout());
	
	setGBC(c, 0, 0, 1, 1);
	Overview.add(hpLabel, c);
	setGBC(c, 0, 1, 1, 1);
	Overview.add(regionLabel, c);
	setGBC(c, 0, 2, 1, 1);
	Overview.add(geoLabel, c);
	setGBC(c, 0, 3, 1, 1);
	Overview.add(permaLabel, c);
	setGBC(c, 0, 0, 1, 1);
	Content.add(Overview, c);
	
	/* Functions */
	Functions = new JPanel();
	Functions.setLayout(new GridBagLayout());
	
	setGBC(c, 0, 0, 1, 1);
	Functions.add(load,c);
	setGBC(c, 0, 1, 1, 1);
	Functions.add(save,c);
	setGBC(c, 0, 2, 1, 1);
	Functions.add(saveAs,c);
	setGBC(c, 1, 0, 0, 1);
	Content.add(Functions, c);
	
	/* Build */
	this.add(this.Title, BorderLayout.PAGE_START);
	this.add(Content, BorderLayout.CENTER);
	this.add(new JSeparator(), BorderLayout.PAGE_END);
}