Java Code Examples for com.alee.laf.text.WebTextArea#setMargin()

The following examples show how to use com.alee.laf.text.WebTextArea#setMargin() . 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: MainFrame.java    From desktopclient-java with GNU General Public License v3.0 4 votes vote down vote up
private static WebPanel createListPanel(final WebTable list,
                                        String overlayText,
                                        WebToggleButton button) {
    // overlay for empty list
    WebOverlay listOverlay = new WebOverlay(list);
    listOverlay.setOverlayMargin(20);
    final WebTextArea overlayArea = new WebTextArea();
    overlayArea.setText(overlayText);
    overlayArea.setLineWrap(true);
    overlayArea.setWrapStyleWord(true);
    overlayArea.setMargin(View.MARGIN_DEFAULT);
    overlayArea.setFontSize(View.FONT_SIZE_BIG);
    overlayArea.setEditable(false);
    BorderPainter<WebTextArea> borderPainter = new BorderPainter<>(Color.LIGHT_GRAY);
    borderPainter.setRound(15);
    overlayArea.setPainter(borderPainter);
    list.getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            overlayArea.setVisible(list.getModel().getRowCount() == 0);
        }
    });
    overlayArea.setVisible(list.getModel().getRowCount() == 0);
    listOverlay.addOverlay(overlayArea, SwingConstants.CENTER, SwingConstants.CENTER);

    WebScrollPane scrollPane = new ComponentUtils.ScrollPane(listOverlay);
    scrollPane.setDrawBorder(false);

    // button as overlay
    button.setOpaque(false);
    button.setUndecorated(true);
    WebOverlay chatListOverlay = new WebOverlay(scrollPane,
            button, SwingConstants.TRAILING, SwingConstants.BOTTOM);
    chatListOverlay.setOverlayMargin(0, 0, View.GAP_BIG, View.GAP_BIG + SCROLL_BAR_WIDTH);
    // fixing overlay button paint bug on startup, dont wanna know whats happening here
    SwingUtils.delayInvokeLater(0, new Runnable() {
        @Override
        public void run() {
            TooltipManager.showOneTimeTooltip(list, new Point(1,1), "");
        }
    });

    return chatListOverlay;
}
 
Example 2
Source File: Popup.java    From Spade with GNU General Public License v3.0 4 votes vote down vote up
public static void showException(String title, Exception e, String msg2)
{
	WebDialog dialog = new WebDialog(Spade.main.gui.frame, title);
	dialog.setModal(true);
	
	WebTextArea text = new WebTextArea();
	text.setEditable(false);
	text.setWrapStyleWord(true);
	text.setLineWrap(true);
	text.setFontName(Font.MONOSPACED);
	
	StringWriter msg = new StringWriter();
	e.printStackTrace(new PrintWriter(msg));
	text.append(msg.toString());
	
	JPanel panel = (JPanel) dialog.getContentPane();
	panel.setLayout(new BorderLayout());
	
	panel.setPreferredSize(new Dimension(800, 400));
	
	WebScrollPane scroll = new WebScrollPane(text);
	
	panel.add(new WebLabel("An Exception Occured: ").setMargin(5), BorderLayout.NORTH);
	panel.add(scroll, BorderLayout.CENTER);
	
	WebPanel bottom = new WebPanel();
	bottom.setLayout(new BorderLayout());
	
	WebTextArea report =
			new WebTextArea("Please copy the above message and report it to " + Spade.REPO_URL
					+ " along with details of what you were doing when it happened.");
	report.setLineWrap(true);
	report.setWrapStyleWord(true);
	report.setEditable(false);
	report.setMargin(5);
	
	WebTextArea endMsg = new WebTextArea(msg2);
	endMsg.setLineWrap(true);
	endMsg.setWrapStyleWord(true);
	endMsg.setEditable(false);
	endMsg.setMargin(5);
	
	bottom.add(report, BorderLayout.NORTH);
	bottom.add(endMsg, BorderLayout.CENTER);
	
	panel.add(bottom, BorderLayout.SOUTH);
	
	dialog.pack();
	dialog.setResizable(true);
	dialog.setVisible(true);
	dialog.setLocationRelativeTo(Spade.main.gui.frame);
}