📄 helpframe.java
字号:
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ResourceBundle;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.SwingConstants;
import javax.swing.WindowConstants;
/**
* @author ThunellE AnderssonA
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
public class HelpFrame extends JFrame
{
/**
* Comment for <code>serialVersionUID</code>
*/
private static final long serialVersionUID = -7797849179421833321L;
ResourceBundle littleBundle;
private JLabel help1;
private JLabel help2;
private JLabel help3;
private JLabel help4;
private JLabel help5;
JLabel [] helpLabels = { help1, help2, help3, help4, help5 };
private JSplitPane helpPane;
private JScrollPane rightScroll;
private JLabel rightLabel;
private String[] titles = {
"Element",
"JDF Element",
"RefElement",
"Element with Error",
"Attribute",
"Inherited Attribute",
"PartIDKey Attribute",
"Inherited PartIDKey Attribute",
"Attriubte with Error" };
ImageIcon imgUp = Editor.getImageIcon(getClass(), "/icons/UpButton.gif");
ImageIcon imgVal = Editor.getImageIcon(getClass(), "/icons/RevalidateButton.gif");
private ImageIcon[] icons =
{
Editor.getImageIcon(getClass(), "/icons/ElemIcon.gif"),
Editor.getImageIcon(getClass(), "/icons/JDFElemIcon.gif"),
Editor.getImageIcon(getClass(), "/icons/rRefElemIcon.gif"),
Editor.getImageIcon(getClass(), "/icons/ErrorElemIcon.gif"),
Editor.getImageIcon(getClass(), "/icons/AttIconSelected.gif"),
Editor.getImageIcon(getClass(), "/icons/InhAttIconSelected.gif"),
Editor.getImageIcon(getClass(), "/icons/PartIDKeysAttIconSelected.gif"),
Editor.getImageIcon(getClass(), "/icons/InhPartIDKeysAttIconSelected.gif"),
Editor.getImageIcon(getClass(), "/icons/ErrorAttIconSelected.gif")
};
String startTags = "<html><font size=2 color=black face=verdana> ";
String startTagsLarge = "<html><font size=3 color=black face=verdana><b> ";
String startTagsSmall = "<html><font size=2 color=black face=verdana><b> ";
String startTagsSmallSel = "<html><font size=2 color=#6EC8F0 face=verdana><b> <u>";
String endTags = "</b></font></html>";
String endTag = "</font></html>";
/**
* Constructor for HelpFrame.
*/
public HelpFrame(ResourceBundle bundle)
{
super();
this.littleBundle = bundle;
this.setTitle(littleBundle.getString("HelpCIP4Key"));
final Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
this.setBounds(d.width / 3, 0, d.width * 2 / 3, d.height - 30);
this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
final WindowListener winLis = new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
Editor.getEditor().getFrame().setHelpExit();
dispose();
}
};
this.addWindowListener(winLis);
this.toFront();
init();
}
/**
* Method init.
*
*/
private void init()
{
final Dimension d = new Dimension(this.getSize());
final JPanel leftPanel = drawLeftPanel();
leftPanel.setBackground(Color.white);
final JPanel rightPanel = drawRightPanel();
rightPanel.setBackground(Color.white);
final JScrollPane leftScroll = new JScrollPane(leftPanel);
leftScroll.setBackground(Color.white);
leftScroll.getVerticalScrollBar().setUnitIncrement(20);
leftScroll.getHorizontalScrollBar().setUnitIncrement(20);
final JLabel leftLabel = new JLabel(startTagsLarge + littleBundle.getString("ContentsKey") + endTags);
leftLabel.setBackground(Color.white);
leftLabel.setBorder(BorderFactory.createLineBorder(Color.black));
leftScroll.setColumnHeaderView(leftLabel);
rightScroll = new JScrollPane(rightPanel);
rightScroll.setBackground(Color.white);
rightScroll.getVerticalScrollBar().setUnitIncrement(20);
rightScroll.getHorizontalScrollBar().setUnitIncrement(20);
rightLabel = new JLabel(startTagsLarge + endTags);
rightLabel.setBackground(Color.white);
rightLabel.setBorder(BorderFactory.createLineBorder(Color.black));
rightScroll.setColumnHeaderView(rightLabel);
helpPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftScroll, rightScroll);
helpPane.setDividerLocation(d.width / 3);
getContentPane().add(helpPane);
}
/**
* Method drawLeftPanel.
* @return JPanel
*/
private JPanel drawLeftPanel()
{
final int x = 10;
int y = 10;
int w = 0;
final String[] labelStrings = {
littleBundle.getString("GettingStartedKey"),
littleBundle.getString("ViewKey"),
littleBundle.getString("EditingKey"),
littleBundle.getString("ValidationKey"),
littleBundle.getString("DevelopmentNotesKey")};
final JPanel leftPanel = new JPanel(null);
final Dimension d = new Dimension(this.getSize());
leftPanel.setBounds(0, 0, d.width / 3, d.height);
leftPanel.setBackground(Color.white);
for (int i = 0; i < helpLabels.length; i++)
{
helpLabels[i] = createDefaultLabel(startTagsSmall + labelStrings[i] + endTags);
helpLabels[i].setBorder(BorderFactory.createEmptyBorder());
helpLabels[i].setToolTipText(labelStrings[i]);
helpLabels[i].addMouseListener(new LabelMouseListener());
final Dimension dim = helpLabels[i].getPreferredSize();
helpLabels[i].setBounds(x, y, dim.width, dim.height);
leftPanel.add(helpLabels[i]);
y += dim.height + 5;
w = w < dim.width ? dim.width : w;
}
leftPanel.setPreferredSize(new Dimension(w + 2 * x, y));
return leftPanel;
}
/**
* Method drawRightPanel.
* @return JPanel
*/
private JPanel drawRightPanel()
{
final JPanel rp = new JPanel(null);
final JLabel textLabel = createDefaultLabel(startTags + littleBundle.getString("RightView") + endTags);
final Dimension d = textLabel.getPreferredSize();
textLabel.setBounds(20, 20, d.width, d.height);
rp.add(textLabel);
rp.setPreferredSize(new Dimension(d.width + 40, d.height + 40));
return rp;
}
private JLabel createDefaultLabel(String text)
{
final JLabel label = new JLabel(text, SwingConstants.LEFT);
label.setVerticalTextPosition(SwingConstants.TOP);
label.setBackground(Color.white);
label.setOpaque(true);
return label;
}
/**
* Method helpGettingStarted.
*/
void helpGettingStarted()
{
final JPanel rp = new JPanel(null);
final JLabel startLabel = createDefaultLabel(startTags + littleBundle.getString("GettingStarted") + endTags);
final Dimension d = startLabel.getPreferredSize();
startLabel.setBounds(20, 20, d.width, d.height);
rp.add(startLabel);
rp.setBackground(Color.white);
rp.setPreferredSize(new Dimension(d.width + 40, d.height + 40));
rightScroll.getViewport().setView(rp);
rightLabel.setText(startTagsLarge + littleBundle.getString("GettingStartedKey") + endTags);
}
/**
* Method helpViews.
*/
void helpViews()
{
final int x = 20;
int y = 20;
int w = 0;
final JPanel rp = new JPanel(null);
final JLabel treeLabel = createDefaultLabel(startTags + littleBundle.getString("TreeView") + endTags);
Dimension d = treeLabel.getPreferredSize();
treeLabel.setBounds(x, y, d.width, d.height);
rp.add(treeLabel);
w = w < d.width ? d.width : w;
y += d.height;
for(int i = 0; i < titles.length; i++)
{
final JLabel label = drawIconLabel(titles[i], icons[i]);
d = label.getPreferredSize();
label.setBounds(50, y, d.width, d.height);
rp.add(label);
w = w < d.width ? d.width : w;
y += d.height + 5;
}
final JLabel errorLabel = createDefaultLabel(startTags + littleBundle.getString("ErrorView") + endTags);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -