📄 demo.java
字号:
frame.setLocation(20, 30);
frame.setVisible(true);
JNLabel title = new JNLabel("JNode Widgets");
title.setFont(new Font("Dialog", Font.BOLD, 24));
int w = (int) title.getPreferredSize().getWidth();
int h = (int) title.getPreferredSize().getHeight();
title.setSize(w + 30, h + 10);
title.setLocation(140, 20);
frame.add(title);
JNTabbedPane tabpane = new JNTabbedPane();
tabpane.setLocation(30, 100);
tabpane.setSize(450, 400);
JNPanel yellowpanel = new JNPanel();
yellowpanel.setBackground(Color.yellow);
JNButton rad = new JNButton("YELLOW");
rad.setLocation(50, 160);
yellowpanel.add(rad);
/* tabpane.add( getLabelsPanel(), "Label's" );
tabpane.add( getButtonsPanel(), "Button's" );
tabpane.add( getCheckBoxPanel(), "CheckBox's" );
tabpane.add( getRadioBoxPanel(), "RadioButton's" );
tabpane.add( getScrollbars(), "ScrollBar's" );
tabpane.add( getListBox(), "List" );
tabpane.add( getComboBox(), "ComboBox" );
tabpane.add( getTextFeild(), "TextFeild" );
tabpane.add( yellowpanel, "TabbedPane" ); */
tabpane.setTabPlacement(JNDefaultLookAndFeel.LEFT);
frame.add(tabpane);
tabpane.setSelected(1);
return frame;
}
JNPanel getImagePane(Dimension d) {
JNPanel panel = new JNPanel();
panel.setLayout(null);
panel.setBackground(background);
panel.setVisible(false);
panel.setName("Image panel");
panel.setSize(d);
JNLabel lab = new JNLabel("ScrollPane");
lab.setLocation(115, 30);
lab.setAlignment(JNLabel.CENTER);
Font f = lab.getFont();
lab.setFont(new Font(f.getName(), Font.BOLD, f.getSize()));
lab.setBackground(Color.blue);
lab.setForeground(Color.white);
lab.setSize(lab.getPreferredSize());
panel.add(lab);
if (isApplet) {
imgfromfile = Widgetsapplet.img1;
} else {
imgfromfile = Imageutil.getImage();
}
// JNImage img = new JNImage( ic.getIconWidth(), ic.getIconHeight() , JNBufferedImage.TYPE_INT_RGB);
JNImage img = new JNImage(719, 574, JNBufferedImage.TYPE_INT_RGB);
// JNImage img = new JNImage(img1.getWidth(null), img1.getHeight(null) , JNBufferedImage.TYPE_INT_RGB);
//System.out.println(imgfromfile+" from Demo ");
Graphics g = img.getGraphics();
g.drawImage(imgfromfile, 0, 0, null);
JNScrollPane sp = new JNScrollPane(250, 300);
sp.setLocation(40, 100);
sp.setImage(img);
sp.setInitialLocation(0, 0);
panel.add(sp);
return panel;
}
JNPanel getLabelsPanel(Dimension d) {
JNPanel panel = new JNPanel();
panel.setLayout(null);
panel.setBackground(background);
panel.setVisible(false);
panel.setName("labels panel");
panel.setSize(d);
JNLabel lab = new JNLabel("Label's");
lab.setLocation(115, 10);
lab.setAlignment(JNLabel.CENTER);
Font f = lab.getFont();
lab.setFont(new Font(f.getName(), Font.BOLD, f.getSize()));
lab.setBackground(Color.blue);
lab.setForeground(Color.white);
lab.setSize(lab.getPreferredSize());
JNLabel lab1 = new JNLabel("LEFT Alignment");
lab1.setLocation(50, 40);
lab1.setSize(200, 30);
lab1.setAlignment(JNLabel.LEFT);
JNLabel lab2 = new JNLabel("CENTER ");
lab2.setLocation(50, 90);
lab2.setSize(200, 30);
lab2.setAlignment(JNLabel.CENTER);
JNLabel lab3 = new JNLabel("Right Alignment");
lab3.setLocation(50, 140);
lab3.setSize(200, 30);
lab3.setAlignment(JNLabel.RIGHT);
JNLabel lab4 = new JNLabel("Longger Text than size");
// JNLabel lab4 = new JNLabel("Bigger than Label Size");
lab4.setBackground(Color.yellow);
lab4.setLocation(90, 190);
lab4.setSize(100, 30);
lab4.setAlignment(JNLabel.RIGHT);
JNLabel noborder = new JNLabel("Label without Border");
noborder.setSize(noborder.getPreferredSize());
noborder.setLocation(80, 230);
noborder.setEnableBorderLine(false);
noborder.setBackground(Color.lightGray);
JNLabel opa = new JNLabel("Label");
opa.setSize(opa.getPreferredSize());
opa.setLocation(80, 280);
opa.setOpaque(true);
opa.setBackground(background);
opa.setEnableBorderLine(false);
// ---
JNImage img = new JNImage(50, 50, JNBufferedImage.TYPE_INT_RGB);
Graphics g = img.getGraphics();
g.setColor(Color.red);
g.fillOval(3, 3, 45, 45);
// g.drawImage( getImagefromFile());
JNLabel imglab = new JNLabel("Image Label");
imglab.setSize(imglab.getPreferredSize());
imglab.setLocation(100, 330);
imglab.setImage(img);
imglab.setSelectedImage(img);
//---
panel.add(lab);
panel.add(lab1);
panel.add(lab2);
panel.add(lab3);
panel.add(lab4);
panel.add(noborder);
panel.add(opa);
panel.add(imglab);
return panel;
}
JNPanel getListBox(Dimension d) {
JNPanel panel = new JNPanel();
panel.setLayout(null);
panel.setBackground(background);
panel.setVisible(false);
panel.setName("list panel");
panel.setSize(d);
JNLabel lab = new JNLabel("List Box");
lab.setLocation(90, 20);
lab.setAlignment(JNLabel.CENTER);
Font f = lab.getFont();
lab.setFont(new Font(f.getName(), Font.BOLD, f.getSize()));
lab.setBackground(Color.blue);
lab.setForeground(Color.white);
lab.setSize(lab.getPreferredSize());
panel.add(lab);
JNList alist = new JNList();
alist.setLocation(50, 60);
alist.setSize(150, 150);
panel.add(alist);
alist.add("AWT");
alist.add("SWING");
alist.add("Thinlet");
alist.add("Zaval");
alist.add("SWT");
for (int i = 0; i <= 20; i++) {
alist.add(i + " KWT");
}
return panel;
}
JNPanel getMenu(Dimension d) {
JNPanel panel = new JNPanel();
panel.setLayout(null);
panel.setBackground(background);
panel.setVisible(false);
panel.setName("Menu Bar");
panel.setSize(d);
JNMenuBar menubar = new JNMenuBar();
menubar.setLocation(5, 5);
JNMenu amenu = new JNMenu("File");
amenu.add("Open");
amenu.add("Close");
amenu.add("Save");
amenu.addSeparator();
amenu.add("Save As");
amenu.add("Dont Save As");
amenu.add("Exit");
amenu.setSize(amenu.getPreferredSize());
JNMenu amenu2 = new JNMenu("WindowsStyle");
amenu2.add("Search");
amenu2.add("Replace");
amenu2.add("Replace .Net with J2EE");
amenu2.add("Replace your Boss");
amenu2.setSize(amenu2.getPreferredSize());
JNMenu amenu3 = new JNMenu("JavaStyle");
amenu3.setMenuStyle(JNDefaultLookAndFeel.JAVA_STYLE_MENU);
amenu3.add("Save WorkSpace");
amenu3.add("Save File");
amenu3.add("Open WorkSpace");
amenu3.add("Open a File");
amenu3.setSize(amenu3.getPreferredSize());
JNMenu amenuh = new JNMenu("Help");
amenuh.add("Help X");
amenuh.add("Help Y");
amenuh.add("Help Z");
amenuh.add("About ?");
amenuh.setSize(amenuh.getPreferredSize());
menubar.add(amenu);
menubar.add(amenu2);
menubar.add(amenu3);
menubar.add(amenuh);
menubar.setSize((int) d.getWidth() - (menubar.getX() * 2),
//(int)menubar.getPreferredSize().getHeight());
32);
menubar.setBackground(Color.lightGray);
panel.add(menubar);
return panel;
}
JNPanel getRadioBoxPanel(Dimension d) {
JNPanel panel = new JNPanel();
panel.setLayout(null);
panel.setBackground(background);
panel.setVisible(false);
panel.setName("radio panel");
panel.setSize(d);
JNLabel lab = new JNLabel("Radio Button's");
lab.setLocation(100, 10);
lab.setAlignment(JNLabel.CENTER);
Font f = lab.getFont();
lab.setFont(new Font(f.getName(), Font.BOLD, f.getSize()));
lab.setBackground(Color.blue);
lab.setForeground(Color.white);
lab.setSize(lab.getPreferredSize());
panel.add(lab);
int x = 90;
JNRadioButton one = new JNRadioButton("Selected");
one.setLocation(x, 100);
one.setSize(140, 30);
one.setSelected(true);
panel.add(one);
one = new JNRadioButton("Un Selected");
one.setLocation(x, 150);
one.setSize(140, 30);
one.setSelected(false);
panel.add(one);
JNRadioButton imgb = new JNRadioButton("Image CheckBox");
imgb.setLocation(x, 220);
int w = (int) imgb.getSize().getWidth();
int h = (int) imgb.getSize().getHeight();
JNImage img1 = new JNImage(w, h, JNBufferedImage.TYPE_INT_RGB);
Graphics g = img1.getGraphics();
g.setColor(Color.red);
g.fillOval(3, 1, w - 2, h - 1);
// g.setColor(Color.blue);
// g.drawRect((w/2)-15,5,30,20);
// g.drawImage( getImagefromFile());
JNImage img2 = new JNImage(w, h, JNBufferedImage.TYPE_INT_RGB);
g = img2.getGraphics();
g.setColor(Color.green);
g.fillOval(3, 1, w - 2, h - 1);
// g.setColor(Color.cyan);
// g.drawRect((w/2)-15,5,30,20);
imgb.setImage(img1);
imgb.setSelectedImage(img2);
panel.add(imgb);
return panel;
}
JNPanel getScrollbars(Dimension d) {
JNPanel panel = new JNPanel();
panel.setLayout(null);
panel.setBackground(background);
panel.setVisible(false);
panel.setName("scrollbar panel");
panel.setSize(d);
JNLabel lab = new JNLabel("ScrollBar's");
lab.setLocation(115, 10);
lab.setAlignment(JNLabel.CENTER);
Font f = lab.getFont();
lab.setFont(new Font(f.getName(), Font.BOLD, f.getSize()));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -