下面列出了javax.swing.JTextPane#setBorder ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private static JTextPane createInfoPanel(String notification) {
JTextPane balloon = new JTextPane();
balloon.setContentType("text/html");
String text = getDetails(notification).replaceAll("(\r\n|\n|\r)", "<br>");
balloon.setText(text);
balloon.setOpaque(false);
balloon.setEditable(false);
balloon.setBorder(new EmptyBorder(0, 0, 0, 0));
if (UIManager.getLookAndFeel().getID().equals("Nimbus")) {
//#134837
//http://forums.java.net/jive/thread.jspa?messageID=283882
balloon.setBackground(new Color(0, 0, 0, 0));
}
balloon.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
URLDisplayer.getDefault().showURL(e.getURL());
}
}
});
return balloon;
}
@Override
public Component getListCellRendererComponent(
JList<? extends TransactionBean> list,
TransactionBean value, int index, boolean isSelected,
boolean cellHasFocus)
{
JTextPane client = new JTextPane();
client.setEditable(false);
client.setContentType("text/html");
TransactionRenderOpsBean ops = mRuntime.getRenderOps();
String html = TransactionLogic.renderAsHTML(value, ops);
int w = list.getFixedCellWidth();
if (w < 0)
w = 750;
else
w = w*3/4;
html = "<html><body><table width=\""+w+"px\">"+html+"</table></body></html>";
client.setText(html);
if (cellHasFocus)
client.setBorder(new MatteBorder(1, 5, 1, 1, Color.DARK_GRAY));
client.setBackground(isSelected ? SELECTED : DESELECTED);
return client;
}
@Override
public Component getListCellRendererComponent(
JList<? extends TransactionBean> list,
TransactionBean value, int index, boolean isSelected,
boolean cellHasFocus)
{
JTextPane client = new JTextPane();
client.setEditable(false);
client.setContentType("text/html");
TransactionRenderOpsBean ops = mRuntime.getRenderOps();
String html = TransactionLogic.renderAsHTML(value, ops);
int w = list.getFixedCellWidth();
if (w < 0)
w = 750;
else
w = w*3/4;
html = "<html><body><table width=\""+w+"px\">"+html+"</table></body></html>";
client.setText(html);
if (cellHasFocus)
client.setBorder(new MatteBorder(1, 5, 1, 1, Color.DARK_GRAY));
client.setBackground(isSelected ? SELECTED : DESELECTED);
return client;
}
/**
* This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
infoScrollPane = new JScrollPane();
infoTextPane = new JTextPane();
infoScrollPane.setBorder(null);
infoTextPane.setEditable(false);
infoTextPane.setBorder(null);
infoTextPane.setContentType("text/html"); // NOI18N
infoTextPane.setText(NbBundle.getMessage(NetworkErrorPanel.class, "NetworkErrorPanel.infoTextPane.text")); // NOI18N
infoTextPane.setOpaque(false);
infoScrollPane.setViewportView(infoTextPane);
GroupLayout layout = new GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(infoScrollPane)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(infoScrollPane)
.addContainerGap())
);
}
private void initTextPane (JTextPane pane) {
pane.setBorder(null);
pane.setLayout(null);
//fix for nimbus laf
pane.setOpaque(false);
pane.setBackground(new Color(0, 0, 0, 0));
}
private void setupTextPane(final JTextPane textPane, String comment) {
if( UIUtils.isNimbus() ) {
textPane.setUI( new BasicTextPaneUI() );
}
textPane.setText(comment);
Caret caret = textPane.getCaret();
if (caret instanceof DefaultCaret) {
((DefaultCaret)caret).setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
}
// attachments
if (!attachmentIds.isEmpty()) {
AttachmentHyperlinkSupport.Attachement a = AttachmentHyperlinkSupport.findAttachment(comment, attachmentIds);
if (a != null) {
String attachmentId = a.id;
if (attachmentId != null) {
int index = attachmentIds.indexOf(attachmentId);
if (index != -1) {
BugzillaIssue.Attachment attachment = attachments.get(index);
AttachmentLink attachmentLink = new AttachmentLink(attachment);
HyperlinkSupport.getInstance().registerLink(textPane, new int[] {a.idx1, a.idx2}, attachmentLink);
} else {
Bugzilla.LOG.log(Level.WARNING, "couldn''t find attachment id in: {0}", comment); // NOI18N
}
}
}
}
// pop-ups
textPane.setComponentPopupMenu(commentsPopup);
textPane.setBackground(blueBackground);
textPane.setBorder(BorderFactory.createEmptyBorder(3,3,3,3));
textPane.setEditable(false);
textPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(CommentsPanel.class, "CommentsPanel.textPane.AccessibleContext.accessibleName")); // NOI18N
textPane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CommentsPanel.class, "CommentsPanel.textPane.AccessibleContext.accessibleDescription")); // NOI18N
}
/**
* Create the frame.
*/
public LicenseWindow(final String path) {
setTitle("Coder HPMSA - [License]");
setBounds(100, 100, 550, 550);
setBackground(Color.decode("#066d95"));
setLocationRelativeTo(null);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.setIconImage(Toolkit.getDefaultToolkit().
getImage(getClass().getResource(LOGOPATH)));
final JScrollPane scrollPane = new JScrollPane();
scrollPane.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
getContentPane().add(scrollPane, BorderLayout.CENTER);
editorPane = new JTextPane();
editorPane.setBackground(new Color(255, 255, 240));
editorPane.setFont(new Font("Verdana", Font.PLAIN, 13));
editorPane.setBorder(new EtchedBorder(EtchedBorder.RAISED, null, null));
editorPane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
editorPane.setEditable(false);
scrollPane.setViewportView(editorPane);
final StyledDocument doc = editorPane.getStyledDocument();
final SimpleAttributeSet center = new SimpleAttributeSet();
StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
doc.setParagraphAttributes(0, doc.getLength()-1, center, false);
fillEditorPane(path);
setVisible(true);
}
public JAboutFrame(JByteMod jbm) {
this.setTitle(JByteMod.res.getResource("about") + " " + jbm.getTitle());
this.setModal(true);
setBounds(100, 100, 400, 300);
JPanel cp = new JPanel();
cp.setLayout(new BorderLayout());
cp.setBorder(new EmptyBorder(10, 10, 10, 10));
setResizable(false);
JButton close = new JButton(JByteMod.res.getResource("close"));
close.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JAboutFrame.this.dispose();
}
});
JPanel jp = new JPanel(new GridLayout(1, 4));
for (int i = 0; i < 3; i++)
jp.add(new JPanel());
jp.add(close);
cp.add(jp, BorderLayout.PAGE_END);
JTextPane title = new JTextPane();
title.setContentType("text/html");
title.setText(TextUtils.toHtml(jbm.getTitle()
+ "<br/>Copyright \u00A9 2016-2018 noverify<br/><font color=\"#0000EE\"><u>https://github.com/GraxCode/JByteMod-Beta</u></font><br/>Donate LTC: <font color=\"#333333\">LhwXLVASzb6t4vHSssA9FQwq2X5gAg8EKX</font>"));
UIDefaults defaults = new UIDefaults();
defaults.put("TextPane[Enabled].backgroundPainter", this.getBackground());
title.putClientProperty("Nimbus.Overrides", defaults);
title.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
title.setBackground(null);
title.setEditable(false);
title.setBorder(null);
cp.add(title, BorderLayout.CENTER);
getContentPane().add(cp);
}
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setIconImage(MainWin.icon);
setSize(500, 300);
setResizable(false);
setLocationRelativeTo(this.getParent());
setTitle("About " + AppConfig.appTitle);
JPanel mainPanel = new JPanel(new BorderLayout());
add(mainPanel);
JPanel leftPanel = new JPanel();
mainPanel.add(leftPanel, BorderLayout.WEST);
ImageIcon iconImg = new ImageIcon(MainWin.icon);
iconImg.setImage(iconImg.getImage().getScaledInstance((int) (iconImg.getIconWidth() * 0.5), (int) (iconImg.getIconHeight() * 0.5), Image.SCALE_SMOOTH));
JLabel iconLabel = new JLabel(iconImg);
iconLabel.setBorder(BorderFactory.createEmptyBorder(6, 10, 6, 10));
leftPanel.add(iconLabel);
HyperlinkListener hlLsnr = new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED)
return;
// 超链接标记中必须带有协议指定,e.getURL()才能得到,否则只能用e.getDescription()得到href的内容。
// JOptionPane.showMessageDialog(InfoDialog.this, "URL:"+e.getURL()+"\nDesc:"+ e.getDescription());
URL linkUrl = e.getURL();
if (linkUrl != null) {
try {
Desktop.getDesktop().browse(linkUrl.toURI());
} catch (Exception e1) {
e1.printStackTrace();
JOptionPane.showMessageDialog(AboutDialog.this, "超链接错误", "无法打开超链接:" + linkUrl + "\n详情:" + e1, JOptionPane.ERROR_MESSAGE);
}
} else {
JOptionPane.showMessageDialog(AboutDialog.this, "超链接错误", "超链接信息不完整:" + e.getDescription() + "\n请确保链接带有协议信息,如http://,mailto:", JOptionPane.ERROR_MESSAGE);
}
}
};
JTextPane infoArea = new JTextPane();
//设置css单位(px/pt)和chrome一致
infoArea.putClientProperty(JTextPane.W3C_LENGTH_UNITS, true);
infoArea.addHyperlinkListener(hlLsnr);
infoArea.setContentType("text/html");
infoArea.setText(getInfo());
infoArea.setEditable(false);
infoArea.setBorder(BorderFactory.createEmptyBorder(2, 10, 6, 10));
infoArea.setFocusable(false);
JScrollPane infoAreaScrollPane = new JScrollPane(infoArea);
infoAreaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
infoAreaScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
infoAreaScrollPane.getViewport().setBackground(Color.WHITE);
mainPanel.add(infoAreaScrollPane, BorderLayout.CENTER);
}
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setIconImage(MainWin.icon);
setSize(500, 300);
setResizable(false);
setLocationRelativeTo(this.getParent());
setTitle("About " + AppConfig.appTitle);
JPanel mainPanel = new JPanel(new BorderLayout());
add(mainPanel);
JPanel leftPanel = new JPanel();
mainPanel.add(leftPanel, BorderLayout.WEST);
ImageIcon iconImg = new ImageIcon(MainWin.icon);
iconImg.setImage(iconImg.getImage().getScaledInstance((int) (iconImg.getIconWidth() * 0.5), (int) (iconImg.getIconHeight() * 0.5), Image.SCALE_SMOOTH));
JLabel iconLabel = new JLabel(iconImg);
iconLabel.setBorder(BorderFactory.createEmptyBorder(6, 10, 6, 10));
leftPanel.add(iconLabel);
HyperlinkListener hlLsnr = new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED)
return;
// 超链接标记中必须带有协议指定,e.getURL()才能得到,否则只能用e.getDescription()得到href的内容。
// JOptionPane.showMessageDialog(InfoDialog.this, "URL:"+e.getURL()+"\nDesc:"+ e.getDescription());
URL linkUrl = e.getURL();
if (linkUrl != null) {
try {
Desktop.getDesktop().browse(linkUrl.toURI());
} catch (Exception e1) {
e1.printStackTrace();
JOptionPane.showMessageDialog(AboutDialog.this, "超链接错误", "无法打开超链接:" + linkUrl + "\n详情:" + e1, JOptionPane.ERROR_MESSAGE);
}
} else {
JOptionPane.showMessageDialog(AboutDialog.this, "超链接错误", "超链接信息不完整:" + e.getDescription() + "\n请确保链接带有协议信息,如http://,mailto:", JOptionPane.ERROR_MESSAGE);
}
}
};
JTextPane infoArea = new JTextPane();
//设置css单位(px/pt)和chrome一致
infoArea.putClientProperty(JTextPane.W3C_LENGTH_UNITS, true);
infoArea.addHyperlinkListener(hlLsnr);
infoArea.setContentType("text/html");
infoArea.setText(getInfo());
infoArea.setEditable(false);
infoArea.setBorder(BorderFactory.createEmptyBorder(2, 10, 6, 10));
infoArea.setFocusable(false);
JScrollPane infoAreaScrollPane = new JScrollPane(infoArea);
infoAreaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
infoAreaScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
infoAreaScrollPane.getViewport().setBackground(Color.WHITE);
mainPanel.add(infoAreaScrollPane, BorderLayout.CENTER);
}
/**
* Constructs a {@link ClipboardFrame}.
*
* @param content
* the content as a string
*/
public ClipboardFrame(final String content) {
final JTextPane text = new JTextPane() {
private static final long serialVersionUID = 1L;
@Override
public void processMouseEvent(MouseEvent me) {
switch (me.getID()) {
case MouseEvent.MOUSE_CLICKED:
switch (me.getButton()) {
case MouseEvent.BUTTON1:
StringSelection stringSelection = new StringSelection(content);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, ClipboardFrame.this);
break;
default:
break;
}
ClipboardFrame.this.dispose();
break;
default:
break;
}
}
};
this.addMouseListener(new MouseAdapter() {
@Override
public void mouseExited(MouseEvent e) {
ClipboardFrame.this.dispose();
}
});
text.setCaretColor(Color.WHITE);
text.setEditable(false);
text.setHighlighter(null);
text.setBorder(BorderFactory.createLineBorder(Color.WHITE, 4));
final StyledDocument doc = text.getStyledDocument();
try {
doc.insertString(doc.getLength(), content, null);
doc.remove(doc.getLength() - 1, 1);
} catch (BadLocationException e1) {
e1.printStackTrace();
}
JPanel panel = new JPanel(new BorderLayout());
panel.add(text);
panel.add(BorderLayout.SOUTH, new JLabel(" left-click: copy to clipboard"));
panel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
add(panel);
setUndecorated(true);
Point2D p = MouseInfo.getPointerInfo().getLocation();
setLocation((int) p.getX() - 8, (int) p.getY() - 8);
}
/** Creates a Gtp Console Window */
public GtpConsolePane(Window owner) {
super(owner);
setTitle("Gtp Console");
JSONArray pos = WindowPosition.gtpWindowPos();
if (pos != null) {
this.setBounds(pos.getInt(0), pos.getInt(1), pos.getInt(2), pos.getInt(3));
} else {
Insets oi = owner.getInsets();
setBounds(
0,
owner.getY() - oi.top,
Math.max(owner.getX() - oi.left, 400),
Math.max(owner.getHeight() + oi.top + oi.bottom, 300));
}
htmlKit = new LizziePane.HtmlKit();
htmlDoc = (HTMLDocument) htmlKit.createDefaultDocument();
htmlStyle = htmlKit.getStyleSheet();
htmlStyle.addRule(Lizzie.config.gtpConsoleStyle);
console = new JTextPane();
console.setBorder(BorderFactory.createEmptyBorder());
console.setEditable(false);
console.setEditorKit(htmlKit);
console.setDocument(htmlDoc);
scrollPane = new JScrollPane();
scrollPane.setBorder(BorderFactory.createEmptyBorder());
txtCommand.setBackground(Color.DARK_GRAY);
txtCommand.setForeground(Color.WHITE);
lblCommand.setFont(new Font("Tahoma", Font.BOLD, 11));
lblCommand.setOpaque(true);
lblCommand.setBackground(Color.DARK_GRAY);
lblCommand.setForeground(Color.WHITE);
lblCommand.setText(Lizzie.leelaz == null ? "GTP>" : Lizzie.leelaz.currentShortWeight() + ">");
pnlCommand.setLayout(new BorderLayout(0, 0));
pnlCommand.add(lblCommand, BorderLayout.WEST);
pnlCommand.add(txtCommand);
getContentPane().add(scrollPane, BorderLayout.CENTER);
getContentPane().add(pnlCommand, BorderLayout.SOUTH);
scrollPane.setViewportView(console);
getRootPane().setBorder(BorderFactory.createEmptyBorder());
getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
txtCommand.addActionListener(e -> postCommand(e));
}
/** Creates a window */
public CommentPane(LizzieMain owner) {
super(owner);
setLayout(new BorderLayout(0, 0));
htmlKit = new LizziePane.HtmlKit();
htmlDoc = (HTMLDocument) htmlKit.createDefaultDocument();
htmlStyle = htmlKit.getStyleSheet();
String style =
"body {background:#"
+ String.format(
"%02x%02x%02x",
Lizzie.config.commentBackgroundColor.getRed(),
Lizzie.config.commentBackgroundColor.getGreen(),
Lizzie.config.commentBackgroundColor.getBlue())
+ "; color:#"
+ String.format(
"%02x%02x%02x",
Lizzie.config.commentFontColor.getRed(),
Lizzie.config.commentFontColor.getGreen(),
Lizzie.config.commentFontColor.getBlue())
+ "; font-family:"
+ Lizzie.config.fontName
+ ", Consolas, Menlo, Monaco, 'Ubuntu Mono', monospace;"
+ (Lizzie.config.commentFontSize > 0
? "font-size:" + Lizzie.config.commentFontSize
: "")
+ "}";
htmlStyle.addRule(style);
commentPane = new JTextPane();
commentPane.setBorder(BorderFactory.createEmptyBorder());
commentPane.setEditorKit(htmlKit);
commentPane.setDocument(htmlDoc);
commentPane.setText("");
commentPane.setEditable(false);
commentPane.setFocusable(false);
commentPane.addMouseListener(
new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
Lizzie.frame.getFocus();
}
});
scrollPane = new JScrollPane();
scrollPane.setBorder(BorderFactory.createEmptyBorder());
scrollPane.setVerticalScrollBarPolicy(
javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
add(scrollPane);
scrollPane.setViewportView(commentPane);
setVisible(false);
// mouseMotionAdapter = new MouseMotionAdapter() {
// @Override
// public void mouseDragged(MouseEvent e) {
// System.out.println("Mouse Dragged");
// owner.dispatchEvent(e);
// }
// };
// commentPane.addMouseMotionListener(mouseMotionAdapter);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
projectFolderCheckBox = new JCheckBox();
projectFolderLabel = new JLabel();
projectFolderTextField = new JTextField();
projectFolderBrowseButton = new JButton();
projectFolderScrollPane = new JScrollPane();
projectFolderTextPane = new JTextPane();
Mnemonics.setLocalizedText(projectFolderCheckBox, NbBundle.getMessage(ProjectFolder.class, "LBL_SeparateProjectFolder")); // NOI18N
projectFolderLabel.setLabelFor(projectFolderTextField);
Mnemonics.setLocalizedText(projectFolderLabel, NbBundle.getMessage(ProjectFolder.class, "LBL_MetadataFolder")); // NOI18N
projectFolderLabel.setEnabled(false);
projectFolderTextField.setColumns(20);
projectFolderTextField.setEnabled(false);
Mnemonics.setLocalizedText(projectFolderBrowseButton, NbBundle.getMessage(ProjectFolder.class, "LBL_BrowseProject")); // NOI18N
projectFolderBrowseButton.setEnabled(false);
projectFolderBrowseButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
projectFolderBrowseButtonActionPerformed(evt);
}
});
projectFolderScrollPane.setBorder(null);
projectFolderTextPane.setBackground(UIManager.getDefaults().getColor("Label.background"));
projectFolderTextPane.setBorder(null);
projectFolderTextPane.setFont(new Font("Dialog", 1, 12)); // NOI18N
projectFolderTextPane.setText(NbBundle.getMessage(ProjectFolder.class, "TXT_MetadataInfo")); // NOI18N
projectFolderScrollPane.setViewportView(projectFolderTextPane);
projectFolderTextPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderTextPane.AccessibleContext.accessibleName")); // NOI18N
projectFolderTextPane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderTextPane.AccessibleContext.accessibleDescription")); // NOI18N
GroupLayout layout = new GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(Alignment.LEADING)
.addGroup(Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(Alignment.LEADING)
.addComponent(projectFolderCheckBox)
.addGroup(layout.createSequentialGroup()
.addComponent(projectFolderLabel)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(projectFolderTextField, GroupLayout.DEFAULT_SIZE, 242, Short.MAX_VALUE)))
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(projectFolderBrowseButton))
.addComponent(projectFolderScrollPane, GroupLayout.DEFAULT_SIZE, 485, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(projectFolderCheckBox)
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
.addComponent(projectFolderTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(projectFolderLabel)
.addComponent(projectFolderBrowseButton))
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(projectFolderScrollPane))
);
projectFolderCheckBox.getAccessibleContext().setAccessibleName(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderCheckBox.AccessibleContext.accessibleName")); // NOI18N
projectFolderCheckBox.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderCheckBox.AccessibleContext.accessibleDescription")); // NOI18N
projectFolderLabel.getAccessibleContext().setAccessibleName(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderLabel.AccessibleContext.accessibleName")); // NOI18N
projectFolderLabel.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderLabel.AccessibleContext.accessibleDescription")); // NOI18N
projectFolderTextField.getAccessibleContext().setAccessibleName(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderTextField.AccessibleContext.accessibleName")); // NOI18N
projectFolderTextField.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderTextField.AccessibleContext.accessibleDescription")); // NOI18N
projectFolderBrowseButton.getAccessibleContext().setAccessibleName(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderBrowseButton.AccessibleContext.accessibleName")); // NOI18N
projectFolderBrowseButton.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderBrowseButton.AccessibleContext.accessibleDescription")); // NOI18N
projectFolderScrollPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderScrollPane1.AccessibleContext.accessibleName")); // NOI18N
projectFolderScrollPane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderScrollPane1.AccessibleContext.accessibleDescription")); // NOI18N
getAccessibleContext().setAccessibleName(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.AccessibleContext.accessibleName")); // NOI18N
getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.AccessibleContext.accessibleDescription")); // NOI18N
}
/**
* Create the frame.
*/
public ReadLogsWindow() {
setTitle("Coder HPMSA - [Read Logs]");
setBounds(100, 100, 660, 550);
setBackground(Color.decode("#066d95"));
setLocationRelativeTo(null);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.setIconImage(Toolkit.getDefaultToolkit().
getImage(getClass().getResource(LOGOPATH)));
final JScrollPane scrollPane = new JScrollPane();
scrollPane.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
getContentPane().add(scrollPane, BorderLayout.CENTER);
editorPane = new JTextPane();
editorPane.setBackground(new Color(255, 255, 240));
editorPane.setFont(new Font("Verdana", Font.PLAIN, 13));
editorPane.setBorder(new EtchedBorder(EtchedBorder.RAISED, null, null));
editorPane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
editorPane.setEditable(false);
scrollPane.setViewportView(editorPane);
final JPanel filesPanel = new JPanel();
filesPanel.setPreferredSize(new Dimension(200, 10));
getContentPane().add(filesPanel, BorderLayout.EAST);
filesPanel.setLayout(new BorderLayout(0, 0));
final JScrollPane listScrollPane = new JScrollPane();
listScrollPane.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
listScrollPane.setViewportView(logFilesList());
filesPanel.add(listScrollPane, BorderLayout.CENTER);
final JPanel titlePanel = new JPanel();
titlePanel.setPreferredSize(new Dimension(10, 40));
titlePanel.setBackground(Color.decode("#066d95"));
titlePanel.setAutoscrolls(true);
getContentPane().add(titlePanel, BorderLayout.NORTH);
titlePanel.setLayout(new BorderLayout(0, 0));
final JLabel lblTitle = new JLabel("SYSTEM LOG RECORDS");
lblTitle.setHorizontalTextPosition(SwingConstants.CENTER);
lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
lblTitle.setAutoscrolls(true);
lblTitle.setFont(new Font("Verdana", Font.BOLD, 25));
lblTitle.setForeground(UIManager.getColor("Button.highlight"));
titlePanel.add(lblTitle, BorderLayout.CENTER);
final StyledDocument doc = editorPane.getStyledDocument();
final SimpleAttributeSet center = new SimpleAttributeSet();
StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
doc.setParagraphAttributes(0, doc.getLength(), center, false);
setVisible(true);
}
/**
* This method displays the about box.
*/
public Runner doAbout() {
if (wrap)
return wrapMe();
// Old about message
// OurDialog.showmsg("About Alloy Analyzer " + Version.version(), OurUtil.loadIcon("images/logo.gif"), "Alloy Analyzer " + Version.version(), "Build date: " + " git: " + Version.commit, " ", "Lead developer: Felix Chang", "Engine developer: Emina Torlak", "Graphic design: Julie Pelaez", "Project lead: Daniel Jackson", " ", "Please post comments and questions to the Alloy Community Forum at http://alloy.mit.edu/", " ", "Thanks to: Ilya Shlyakhter, Manu Sridharan, Derek Rayside, Jonathan Edwards, Gregory Dennis,", "Robert Seater, Edmond Lau, Vincent Yeung, Sam Daitch, Andrew Yip, Jongmin Baek, Ning Song,", "Arturo Arizpe, Li-kuo (Brian) Lin, Joseph Cohen, Jesse Pavel, Ian Schechter, and Uriel Schafer.");
HTMLEditorKit kit = new HTMLEditorKit();
StyleSheet styleSheet = kit.getStyleSheet();
styleSheet.addRule("body {color:#000; font-family:Verdana, Trebuchet MS,Geneva, sans-serif; font-size: 10px; margin: 4px; }");
styleSheet.addRule("h1 {color: blue;}");
styleSheet.addRule("h2 {color: #ff0000;}");
styleSheet.addRule("pre {font : 10px monaco; color : black; background-color: #C0C0C0; padding: 4px; margin: 4px; }");
styleSheet.addRule("th {text-align:left;}");
JTextPane ta = new JTextPane();
ta.setEditorKit(kit);
ta.setContentType("text/html");
ta.setBackground(null);
ta.setBorder(null);
ta.setFont(new JLabel().getFont());
// @formatter:off
ta.setText("<html><h1>Alloy Analyzer " + Version.getShortversion() + "</h1>"
+ "<br/>"
+ "<html>"
+ "<tr><th>Project Lead</th><td>Daniel Jackson</td></tr>"
+ "<tr><th>Chief Developer</th><td>Aleksandar Milicevic</td></tr>"
+ "<tr><th>Kodkod Engine</th><td>Emina Torlak</td></tr>"
+ "<tr><th>Open Source</th><td>Peter Kriens</td></tr>"
+ "</table><br/>"
+ "<p>For more information about Alloy, <a href='http://alloytools.org'>http://alloytools.org</a></p>"
+ "<p>Questions and comments about Alloy are welcome at the community forum:</p>"
+ "<p>Alloy Community Forum: <a href='https://groups.google.com/forum/#!forum/alloytools'>https://groups.google.com/forum/#!forum/alloytools</a></p>"
+ "<p>Alloy experts also respond to <a href='https://stackoverflow.com/questions/tagged/alloy'>https://stackoverflow.com</a> questions tagged <code>alloy</code>.</p>"
+ "<p>Major contributions to earlier versions of Alloy were made by: Felix Chang (v4);<br/>"
+ "Jonathan Edwards, Eunsuk Kang, Joe Near, Robert Seater, Derek Rayside, Greg Dennis,<br/>"
+ "Ilya Shlyakhter, Mana Taghdiri, Mandana Vaziri, Sarfraz Khurshid (v3); Manu Sridharan<br/>"
+ "(v2); Edmond Lau, Vincent Yeung, Sam Daitch, Andrew Yip, Jongmin Baek, Ning Song,<br/>"
+ "Arturo Arizpe, Li-kuo (Brian) Lin, Joseph Cohen, Jesse Pavel, Ian Schechter, Uriel<br/>"
+ "Schafer (v1).</p>"
+ "<p>The development of Alloy was funded by part by the National Science Foundation under<br/>"
+ "Grant Nos. 0325283, 0541183, 0438897 and 0707612; by the Air Force Research Laboratory<br/>"
+ "(AFRL/IF) and the Disruptive Technology Office (DTO) in the National Intelligence<br/>"
+ "Community Information Assurance Research (NICIAR) Program; and by the Nokia<br/>"
+ "Corporation as part of a collaboration between Nokia Research and MIT CSAIL.</p>"
+ "<br/><pre>"
+ "Build Date: " + Version.buildDate() + "<br/>"
+ "Git Commit: " + Version.commit
+ "</pre>");
// @formatter:on
ta.setEditable(false);
ta.addHyperlinkListener((e) -> {
if (e.getEventType() == EventType.ACTIVATED) {
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
try {
Desktop.getDesktop().browse(e.getURL().toURI());
} catch (IOException | URISyntaxException e1) {
// ignore
}
}
}
});
OurDialog.showmsg("About Alloy Analyzer " + Version.version(), ta);
return null;
}
@Override
public Component getComponent(int width, int height) throws IOException {
final JPanel base = new JPanel();
base.setOpaque(false);
base.setPreferredSize(new Dimension(width, height));
base.setLayout(new BorderLayout());
final JPanel controls = new JPanel();
final JButton runBtn = new JButton("Run");
runBtn.setActionCommand("run");
runBtn.addActionListener(this);
controls.add(runBtn);
base.add(controls, BorderLayout.NORTH);
textArea = new RSyntaxTextArea(20, 60);
Font font = textArea.getFont();
font = font.deriveFont(font.getStyle(), 18);
textArea.setFont(font);
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_GROOVY);
textArea.setCodeFoldingEnabled(true);
textArea.setText(initialScript);
final RTextScrollPane inputScrollPane = new RTextScrollPane(textArea);
outputPane = new JTextPane();
outputPane.setEditable(false);
outputPane.setFont(new Font("Monospaced", Font.PLAIN, 18));
outputPane.setBorder(new EmptyBorder(4, 4, 4, 4));
final JScrollPane outputScrollPane = new JScrollPane(outputPane);
splitPane = new JSplitPane(orientation, inputScrollPane, outputScrollPane);
splitPane.setOneTouchExpandable(true);
splitPane.setDividerLocation(width / 2);
final Dimension minimumSize = new Dimension(100, 50);
inputScrollPane.setMinimumSize(minimumSize);
outputScrollPane.setMinimumSize(minimumSize);
final JPanel body = new JPanel();
body.setBackground(Color.RED);
body.setLayout(new BoxLayout(body, BoxLayout.Y_AXIS));
body.add(splitPane);
base.add(body, BorderLayout.CENTER);
installInterceptors();
return base;
}