com.alee.laf.text.WebTextArea Java Examples

The following examples show how to use com.alee.laf.text.WebTextArea. 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: NotesTabPanel.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public void initializeUI() {
	uiDone = true;
	
	// Initialize location header.
	WebPanel titlePane = new WebPanel(new FlowLayout(FlowLayout.CENTER));
	topContentPanel.add(titlePane);

	WebLabel titleLabel = new WebLabel(Msg.getString("NotesTabPanel.title"), WebLabel.CENTER); //$NON-NLS-1$
	titleLabel.setFont(new Font("Serif", Font.BOLD, 16));
	// titleLabel.setForeground(new Color(102, 51, 0)); // dark brown
	titlePane.add(titleLabel);
	
	// Create notes panel
	WebPanel notesPanel = new WebPanel(new BorderLayout(5, 5));
	notesPanel.setBorder(new MarsPanelBorder());
	notesPanel.setBorder(new EmptyBorder(1, 1, 1, 1));
	centerContentPanel.add(notesPanel);
	
	notesCache = unit.getNotes();
	
	textArea = new WebTextArea(StyleId.textareaDecorated);
	notesPanel.add(textArea);
	
	if (notesCache == null || notesCache.equals(""))
		textArea.setInputPrompt("Enter Here");
	else {
		textArea.append(notesCache);
	}

}
 
Example #2
Source File: Notifier.java    From desktopclient-java with GNU General Public License v3.0 5 votes vote down vote up
void confirmNewKey(final Contact contact, final PGPUtils.PGPCoderKey key) {
     final boolean overwriting = contact.hasKey();

    WebPanel panel = panel(overwriting ?
            Tr.tr("Received a new public key for contact") :
            Tr.tr("Public key for contact was found"), contact);

    panel.add(new WebLabel(Tr.tr("Key fingerprint:")));
    WebTextArea fpArea = Utils.createFingerprintArea();
    fpArea.setText(Utils.fingerprint(key.fingerprint));
    panel.add(fpArea);

    String expl = overwriting ?
            Tr.tr("When declining the key, communication with this contact will be blocked.") :
            Tr.tr("When accepting the key, communication with this contact will be encrypted.");
    panel.add(textArea(expl));

    WebNotificationPopup popup = NotificationManager.showNotification(mWindow, panel,
            NotificationOption.accept, NotificationOption.decline,
            NotificationOption.cancel);
    popup.setClickToClose(false);
    popup.addNotificationListener(new NotificationListener() {
        @Override
        public void optionSelected(NotificationOption option) {
            switch (option) {
                case accept :
                    mView.getControl().acceptKey(contact, key);
                    break;
                case decline :
                    if (overwriting)
                         mView.getControl().declineKey(contact);
            }
        }
        @Override
        public void accepted() {}
        @Override
        public void closed() {}
    });
}
 
Example #3
Source File: Utils.java    From desktopclient-java with GNU General Public License v3.0 5 votes vote down vote up
static WebTextArea createFingerprintArea() {
    WebTextArea area = new WebTextArea();
    area.setEditable(false);
    area.setOpaque(false);
    area.setFontName(Font.DIALOG);
    area.setFontSizeAndStyle(13, true, false);
    return area;
}
 
Example #4
Source File: WebTextAreaExample.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
@Override
protected List<? extends JComponent> createPreviewElements ()
{
    final WebTextArea textArea = new WebTextArea ( getStyleId (), 3, 20 );
    textArea.setInputPrompt ( getPreviewLanguagePrefix () + "prompt" );
    return CollectionUtils.asList ( new WebScrollPane ( textArea ) );
}
 
Example #5
Source File: WebTextAreaExample.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
@Override
protected List<? extends JComponent> createPreviewElements ()
{
    final WebTextArea textArea = new WebTextArea ( getStyleId (), "Sample\nmultiline\ntext", 3, 20 );
    return CollectionUtils.asList ( textArea );
}
 
Example #6
Source File: WebAccordionExample.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns single collapsible pane content.
 *
 * @return single collapsible pane content
 */
protected JComponent createContent ()
{
    final String text = new LoremIpsum ().getParagraphs ( 3 );
    final WebTextArea textArea = new WebTextArea ( StyleId.textareaNonOpaque, text );
    textArea.setLineWrap ( true );
    textArea.setWrapStyleWord ( true );
    final WebScrollPane scrollPane = new WebScrollPane ( StyleId.scrollpaneTransparentHovering, textArea );
    scrollPane.setPreferredSize ( 150, 100 );
    return scrollPane;
}
 
Example #7
Source File: WebCollapsiblePaneExample.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns {@link JComponent} content for {@link WebCollapsiblePane}.
 * New {@link JComponent} is created upon every call to avoid any UI issues.
 *
 * @return {@link JComponent} content for {@link WebCollapsiblePane}
 */
protected JComponent createContent ()
{
    final String text = new LoremIpsum ().getParagraphs ( 3 );
    final WebTextArea textArea = new WebTextArea ( StyleId.textareaNonOpaque, text );
    textArea.setLineWrap ( true );
    textArea.setWrapStyleWord ( true );
    final WebScrollPane scrollPane = new WebScrollPane ( StyleId.scrollpaneTransparentHovering, textArea );
    scrollPane.setPreferredSize ( 150, 100 );
    return scrollPane;
}
 
Example #8
Source File: BuildingPanelResourceProcessing.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
	 * Constructor.
	 * @param processor the resource processing building this panel is for.
	 * @param desktop The main desktop.
	 */
	public BuildingPanelResourceProcessing(ResourceProcessing processor, MainDesktopPane desktop) {

		// Use BuildingFunctionPanel constructor
		super(processor.getBuilding(), desktop);

		// Initialize variables.
		this.processor = processor;

		// Set layout
		setLayout(new BorderLayout());

		// Prepare resource processes label
		// 2014-11-21 Changed font type, size and color and label text
		// 2014-11-21 Added internationalization for labels
		WebLabel resourceProcessesLabel = new WebLabel(Msg.getString("BuildingPanelResourceProcessing.title"), WebLabel.CENTER);
		resourceProcessesLabel.setFont(new Font("Serif", Font.BOLD, 16));
		//resourceProcessesLabel.setForeground(new Color(102, 51, 0)); // dark brown
		add(resourceProcessesLabel, BorderLayout.NORTH);

		WebLabel supportedProcessesLabel = new WebLabel(Msg.getString("BuildingPanelResourceProcessing.supportedProcesses"), WebLabel.CENTER);
		add(supportedProcessesLabel, BorderLayout.CENTER);

		// Get all processes at building.
		List<ResourceProcess> processes = processor.getProcesses();
		int size = processes.size();
		// Prepare resource processes list panel.
//		WebPanel resourceProcessesListPanel = new WebPanel(new GridLayout(processes.size(), 2, 10, 3));
//		resourceProcessesListPanel.setBorder(new EmptyBorder(3, 20, 3, 20)); //(int top, int left, int bottom, int right)
		//resourceProcessesListPanel.setOpaque(false);
		//resourceProcessesListPanel.setBackground(new Color(0,0,0,128));

		WebTextArea processesTA = new WebTextArea();
		processesTA.setEditable(false);
		processesTA.setFont(new Font("SansSerif", Font.ITALIC, 12));
		processesTA.setColumns(12);

		// For each specialty, add specialty name panel.
		for (ResourceProcess p : processes) {
			processesTA.append(" " + p.getProcessName()+ " ");
			if (!p.equals(processes.get(size-1)))
				//if it's NOT the last one
				processesTA.append("\n");
			
//			if (p.isProcessRunning()) {
//				processLabel.setIcon(greenDot);
//				processLabel.setToolTipText(p.getProcessName() + " process is running.");
//			}
//			else {
//				processLabel.setIcon(redDot);
//				processLabel.setToolTipText(p.getProcessName() + " process is not running.");
//			}
			
		}

		WebPanel listPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		listPanel.add(processesTA);
		processesTA.setBorder(new MarsPanelBorder());
//		resourceProcessesListPanel.setBorder(new MarsPanelBorder());
//		listPanel.add(resourceProcessesListPanel);
		add(listPanel, BorderLayout.SOUTH);
		//listPanel.setOpaque(false);
		//listPanel.setBackground(new Color(0,0,0,128));

		// Load green and red dots.
//		greenDot = new ImageIcon("images/GreenDot.png", "Process is running.");
//		redDot = new ImageIcon("images/RedDot.png", "Process is not running");

		// For each resource process, add a label.
//		processLabels = new ArrayList<WebLabel>(processes.size());
//		Iterator<ResourceProcess> i = processes.iterator();
//		while (i.hasNext()) {
//			ResourceProcess process = i.next();
//			WebLabel processLabel = new WebLabel(process.getProcessName(), WebLabel.LEFT);
//			//processLabel.setForeground(Color.DARK_GRAY);
//			//processLabel.setBackground(Color.WHITE);
//			processLabel.setFont(new Font("SansSerif", Font.ITALIC, 12));
//
//			if (process.isProcessRunning()) {
//				processLabel.setIcon(greenDot);
//				processLabel.setToolTipText(process.getProcessName() + " process is running.");
//			}
//			else {
//				processLabel.setIcon(redDot);
//				processLabel.setToolTipText(process.getProcessName() + " process is not running.");
//			}
//
////			resourceProcessesListPanel.add(processLabel);
//			processLabels.add(processLabel);
//		}
	}
 
Example #9
Source File: BuildingPanelResearch.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor.
 * @param lab the research building this panel is for.
 * @param desktop The main desktop.
 */
public BuildingPanelResearch(Research lab, MainDesktopPane desktop) {

	// Use BuildingFunctionPanel constructor
	super(lab.getBuilding(), desktop);

	// Initialize data members
	this.lab = lab;

	// Set panel layout
	setLayout(new BorderLayout());

	// Prepare label panel
	WebPanel labelPanel = new WebPanel(new GridLayout(4, 1, 0, 0));
	add(labelPanel, BorderLayout.NORTH);
	labelPanel.setOpaque(false);
	labelPanel.setBackground(new Color(0,0,0,128));

	// Prepare research label
	WebLabel researchLabel = new WebLabel(Msg.getString("BuildingPanelResearch.title"), WebLabel.CENTER); //$NON-NLS-1$
	researchLabel.setFont(new Font("Serif", Font.BOLD, 16));
	//researchLabel.setForeground(new Color(102, 51, 0)); // dark brown
	labelPanel.add(researchLabel);

	// Prepare researcher number label
	researchersCache = lab.getResearcherNum();
	researchersLabel = new WebLabel(Msg.getString("BuildingPanelResearch.numberOfResearchers", researchersCache), WebLabel.CENTER);
	labelPanel.add(researchersLabel);

	// Prepare researcher capacityLabel
	WebLabel researcherCapacityLabel = new WebLabel(Msg.getString("BuildingPanelResearch.researcherCapacity",
			lab.getLaboratorySize()),
			WebLabel.CENTER);
	labelPanel.add(researcherCapacityLabel);

	// Prepare specialties label
	WebLabel specialtiesLabel = new WebLabel(Msg.getString("BuildingPanelResearch.namesOfSpecialties"), WebLabel.CENTER);
	labelPanel.add(specialtiesLabel);

	// Get the research specialties of the building.
	ScienceType[] specialties = lab.getTechSpecialties();
	int size = specialties.length;

	WebTextArea specialtyTA = new WebTextArea();
	specialtyTA.setEditable(false);
	specialtyTA.setFont(new Font("SansSerif", Font.ITALIC, 12));
	specialtyTA.setColumns(7);

	// For each specialty, add specialty name panel.
	for (ScienceType specialty : specialties) {
		specialtyTA.append(" " + specialty.getName()+ " ");
		if (!specialty.equals(specialties[size-1]))
			//if it's NOT the last one
			specialtyTA.append("\n");
	}

	WebPanel listPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
	listPanel.add(specialtyTA);
	specialtyTA.setBorder(new MarsPanelBorder());

	add(listPanel, BorderLayout.CENTER);
	listPanel.setOpaque(false);
	listPanel.setBackground(new Color(0,0,0,128));

}
 
Example #10
Source File: LaboratoryTabPanel.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void initializeUI() {
		uiDone = true;

		Lab lab = rover.getLab();
		
		// Prepare laboratory panel
		WebPanel laboratoryPanel = new WebPanel(new BorderLayout());
		topContentPanel.add(laboratoryPanel);
		
		// Prepare name panel
		WebPanel titlePanel = new WebPanel();
		laboratoryPanel.add(titlePanel, BorderLayout.NORTH);

		// Prepare laboratory label
		WebLabel titleLabel = new WebLabel("Laboratory", WebLabel.CENTER);
		titleLabel.setFont(new Font("Serif", Font.BOLD, 16));
		titlePanel.add(titleLabel);
		
		// Prepare the top panel using spring layout.
		WebPanel springPanel = new WebPanel(new SpringLayout());
//		springPanel.setPadding(10, 0, 0, 0);
		laboratoryPanel.add(springPanel, BorderLayout.CENTER);
		
		// Prepare label panel
//		WebPanel labelPanel = new WebPanel(new GridLayout(3, 1));
//		laboratoryPanel.add(labelPanel, BorderLayout.CENTER);

		// Prepare researcher number label
		WebLabel headerLabel0 = new WebLabel("Number of Researchers : ", WebLabel.CENTER);
		springPanel.add(headerLabel0);
		
		researchersCache = lab.getResearcherNum();
		researchersLabel = new WebLabel("" + researchersCache, WebLabel.CENTER);
		springPanel.add(researchersLabel);

		// Prepare researcher capacityLabel
		WebLabel headerLabel1 = new WebLabel("Researcher Capacity : ", WebLabel.CENTER);
		springPanel.add(headerLabel1);
		
		WebLabel researcherCapacityLabel = new WebLabel("" + lab.getLaboratorySize(),
				WebLabel.CENTER);
		springPanel.add(researcherCapacityLabel);

        // Lay out the spring panel.
     	SpringUtilities.makeCompactGrid(springPanel,
     		                                2, 2, //rows, cols
     		                               90, 10,        //initX, initY
    		                               10, 4);       //xPad, yPad
				
		// Get the research specialties of the building.
		ScienceType[] specialties = lab.getTechSpecialties();
		int size = specialties.length;
		
		// Prepare specialty text area
		WebTextArea specialtyTA = new WebTextArea();
		specialtyTA.setEditable(false);
		specialtyTA.setFont(new Font("SansSerif", Font.ITALIC, 12));
		specialtyTA.setColumns(10);
//		specialtyTA.setSize(100, 60);
		specialtyTA.setBorder(new MarsPanelBorder());
		
		
		WebPanel listPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		listPanel.setSize(150, 80);
		listPanel.add(specialtyTA);
		
		TitledBorder titledBorder = BorderFactory.createTitledBorder(null, "Specialties",
				javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION,
				new Font("Serif", Font.BOLD, 14), java.awt.Color.darkGray);
		listPanel.setBorder(titledBorder);
		
		// Prepare specialties label
//		WebLabel specialtiesLabel = new WebLabel("Specialties : ", WebLabel.CENTER);
//		listPanel.add(specialtiesLabel, BorderLayout.NORTH);		
		laboratoryPanel.add(listPanel, BorderLayout.SOUTH);
		
		// For each specialty, add specialty name panel.
		for (ScienceType specialty : specialties) {
			specialtyTA.append(" " + specialty.getName()+ " ");
			if (!specialty.equals(specialties[size-1]))
				//if it's NOT the last one
				specialtyTA.append("\n");
		}
	}
 
Example #11
Source File: TabPanelGeneral.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void createBigFive() {
		PersonalityTraitManager p = person.getMind().getTraitManager();
		
//		int o = p.getPersonalityTrait(PersonalityTraitType.OPENNESS);
//		int c = p.getPersonalityTrait(PersonalityTraitType.CONSCIENTIOUSNESS);
//		int e = p.getPersonalityTrait(PersonalityTraitType.EXTRAVERSION); //getIntrovertExtrovertScore();
//		int a = p.getPersonalityTrait(PersonalityTraitType.AGREEABLENESS);
//		int n = p.getPersonalityTrait(PersonalityTraitType.NEUROTICISM);
		
		String[] types = new String[5];
		int[] scores = new int[5];
		
    	for (PersonalityTraitType t : PersonalityTraitType.values()) {
    		types[t.ordinal()] = t.getName();
    		scores[t.ordinal()] = p.getPersonalityTrait(t);
    	}
    	
		// Prepare MBTI text area
		WebTextArea ta = new WebTextArea();
		ta.setEditable(false);
		ta.setFont(new Font("Monospaced", Font.PLAIN, 12));
		ta.setColumns(14);
//		specialtyTA.setSize(100, 60);
		ta.setBorder(new MarsPanelBorder());
		
		WebPanel listPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		listPanel.setSize(110, 150);
		listPanel.add(ta);

		centerContentPanel.add(listPanel, BorderLayout.SOUTH);
		
		TitledBorder titledBorder = BorderFactory.createTitledBorder(null, "Personality scores based on Big Five",
				javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION,
				new Font("Serif", Font.PLAIN, 12), java.awt.Color.darkGray);
		listPanel.setBorder(titledBorder);
		
    
		for (int i = 0; i < 5; i++) {
//			StringBuffer sb = new StringBuffer();
			String s = types[i];
			int size = 18 - s.length();
			while (size > 0) {
				ta.append(" ");
				size--;
			}
			ta.append(" " + s + " : " + scores[i] + "  ");
			if (i < 4)
				//if it's NOT the last one
				ta.append("\n");
		}
		
	}
 
Example #12
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 #13
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);
}