📄 lwcomplexpan.java
字号:
} private static LwComponent getSplitPanel() { LwPanel sc1 = new LwPanel(); sc1.getViewMan(true).setBorder("br.sunken"); sc1.getViewMan(true).setBg(new LwImgRender("rs/demo/cosmo3.jpg", LwImgRender.STRETCH)); LwPanel sc2 = new LwPanel(); sc2.getViewMan(true).setBorder("br.sunken"); sc2.getViewMan(true).setBg(new LwImgRender("rs/demo/cosmo2.jpg", LwImgRender.STRETCH)); LwSplitPan sp1 = new LwSplitPan(sc1, sc2, LwToolkit.HORIZONTAL); sp1.setGripperLoc(250); LwPanel sc3 = new LwPanel(); sc3.getViewMan(true).setBorder("br.sunken"); sc3.getViewMan(true).setBg(new LwImgRender("rs/demo/cosmo1.jpg", LwImgRender.STRETCH)); LwSplitPan c2 = new LwSplitPan(sp1, sc3, LwToolkit.VERTICAL); c2.setGripperLoc(190); return c2; } private static LwComponent getListPanel() { LwContainer root = makeRoot(); LwLabel lab1 = makeTitle(" Simple list...", 10); LwList list1 = new LwList(); list1.setLocation(20, 50); list1.setPSSize(-1, -1); list1.getViewMan(true).setBorder("br.sunken"); list1.add("......... Text Item."); list1.add(makeImageLabel("flag2", "Image item 0")); list1.add(makeImageLabel("tick", "Image item 1")); list1.add(makeImageLabel("paw", "Image item 2")); list1.add(makeImageLabel("flag1", "Multiline items\nare supported.")); list1.getPosController().setOffset(0); LwList list2 = new LwList(); list2.setLwLayout(new LwGridLayout(2,2)); list2.setLocation(180, 50); list2.setPSSize(-1, -1); list2.getViewMan(true).setBorder("br.sunken"); list2.add(makeImageLabel("flag2", "Image item 0")); list2.add(makeImageLabel("tick", "Image item 1")); list2.add(makeImageLabel("paw", "Image item 2")); list2.add(makeImageLabel("flag1", "Multiline items\nare supported.")); list2.getPosController().setOffset(0); LwLabel lab2 = makeTitle(" Components and list component inside list...", 220); LwList list3 = new LwList(); list3.setLocation(20, 260); list3.setPSSize(-1, -1); list3.setOpaque (false); list3.getViewMan(true).setBorder("br.etched"); list3.add(new LwButton("Button Item")); list3.add(new LwCheckbox("Checkbox Item 1")); list3.add(new LwCheckbox("Checkbox Item 2")); list3.add(new LwCheckbox("Checkbox Item 3")); LwTextField tf1 = new LwTextField("TextField(max 15)", 18); tf1.getViewMan(true).setBorder("br.sunken"); list3.add(tf1); list3.getPosController().setOffset(0); LwList list4 = new LwList(); list4.setLocation(250, 260); list4.setPSSize(200, -1); list4.getViewMan(true).setBorder("br.sunken"); list4.add(makeImageLabel("tick", "Image item 1")); list4.add(makeImageLabel("paw", "Image item 2")); LwList list41 = new LwList(); list41.add(new LwButton("Button Item")); list41.add(new LwCheckbox("Checkbox Item 1")); list41.add(new LwCheckbox("Checkbox Item 2")); LwBorderPan list41cont = new LwBorderPan(new LwLabel("Internal List"), list41); list4.add (list41cont); list4.getPosController().setOffset(0); root.add(lab1); root.add(list1); root.add(list2); root.add(lab2); root.add(list3); root.add(list4); return root; } private static LwComponent getTextFieldPanel() { LwContainer root = makeRoot(); LwLabel lab0 = makeTitle(" Text Fields ...", 10); LwLabel lab1 = makeComment ("Password (8 chars):", 20, 50, 150); LwTextField tf1 = new LwTextField("", 8); tf1.getViewMan(true).setBorder("br.plain"); tf1.setLocation(180, 50); tf1.setPSSize(100, -1); tf1.setOpaque(false); tf1.getViewMan(true).setView(new LwPasswordText(tf1.getTextModel())); LwLabel lab2 = makeComment("Single Line (15 chars):", 20, 90, 150); LwTextField tf2 = new LwTextField("", 15); tf2.getViewMan(true).setBorder("br.sunken"); tf2.setLocation(180, 90); tf2.setPSSize(100, -1); LwLabel lab3 = makeComment("Text Area:", 20, 130, 150); LwTextField tf3 = new LwTextField("This is text area component\nthat allows multiline text inputting."); tf3.getViewMan(true).setBorder("br.sunken"); tf3.setLocation(180, 130); tf3.setPSSize(200, 150); tf3.setOpaque(false); root.add(lab0); root.add(lab1); root.add(tf1); root.add(lab2); root.add(tf2); root.add(lab3); root.add(tf3); return root; } private static LwComponent getCheckboxPanel() { LwContainer root = makeRoot(); LwView rdOn = LwManager.getView("ron1"); LwView rdOff = LwManager.getView("roff1"); LwView chOn1 = LwManager.getView("con1"); LwView chOff1= LwManager.getView("coff1"); LwView chOn2 = LwManager.getView("con2"); LwView chOff2= LwManager.getView("coff2"); LwLabel lab1 = makeTitle(" Standard and custom radio groups ...", 10); LwBorderPan bp1 = new LwBorderPan(); bp1.setLocation(20, 40); bp1.setPSSize(180, -1); bp1.setOpaque (false); bp1.add(LwBorderPan.TITLE, makeImageLabel("flag1", "Standard radio group")); LwContainer c51 = new LwPanel(); c51.setLwLayout(new LwFlowLayout(Alignment.LEFT, Alignment.TOP, LwToolkit.VERTICAL)); bp1.add(LwBorderPan.CENTER, c51); LwGroup gr = new LwGroup(); LwCheckbox ch1 = new LwCheckbox("Radio 1"); ch1.setBoxType(LwCheckbox.RADIO); LwCheckbox ch2 = new LwCheckbox("Radio 2"); ch2.setBoxType(LwCheckbox.RADIO); LwCheckbox ch3 = new LwCheckbox("Radio 3"); ch3.setBoxType(LwCheckbox.RADIO); ch1.setSwitchManager(gr); ch2.setSwitchManager(gr); ch3.setSwitchManager(gr); c51.add(ch1); c51.add(ch2); c51.add(ch3); LwBorderPan bp2 = new LwBorderPan(); bp2.setLocation(220, 40); bp2.setPSSize(180, -1); bp2.setOpaque (false); bp2.add(LwBorderPan.TITLE, new LwLabel("Custom radio group")); LwContainer c52 = new LwPanel(); c52.setLwLayout(new LwFlowLayout(Alignment.LEFT, Alignment.TOP, LwToolkit.VERTICAL)); bp2.add(LwBorderPan.CENTER, c52); LwGroup gr2 = new LwGroup(); LwAdvViewMan m1 = new LwAdvViewMan(); m1.put("radio.on", rdOn); m1.put("radio.off",rdOff); LwCheckbox gr2ch1 = new LwCheckbox("Radio 1"); gr2ch1.setBoxType(LwCheckbox.RADIO); gr2ch1.getBox().setViewMan(m1); LwAdvViewMan m2 = new LwAdvViewMan(); m2.put("radio.on", rdOn); m2.put("radio.off",rdOff); LwCheckbox gr2ch2 = new LwCheckbox("Radio 2"); gr2ch2.setBoxType(LwCheckbox.RADIO); gr2ch2.getBox().setViewMan(m2); LwAdvViewMan m3 = new LwAdvViewMan(); m3.put("radio.on", rdOn); m3.put("radio.off",rdOff); LwCheckbox gr2ch3 = new LwCheckbox("Radio 3"); gr2ch3.setBoxType(LwCheckbox.RADIO); gr2ch3.getBox().setViewMan(m3); gr2ch1.setSwitchManager(gr2); gr2ch2.setSwitchManager(gr2); gr2ch3.setSwitchManager(gr2); c52.add(gr2ch1); c52.add(gr2ch2); c52.add(gr2ch3); LwLabel lab2 = makeTitle(" Standard and custom check boxes ...", 200); LwBorderPan bp3 = new LwBorderPan(); bp3.setLocation(20, 240); bp3.setPSSize(180, -1); bp3.setOpaque (false); bp3.add(LwBorderPan.TITLE, new LwLabel("Standard check boxes")); LwCheckbox ch4 = new LwCheckbox("Check 1"); LwCheckbox ch5 = new LwCheckbox("Check 2"); ch5.setEnabled(false); LwCheckbox ch6 = new LwCheckbox("Check 3"); LwPanel c53 = new LwPanel(); c53.setLwLayout(new LwFlowLayout(Alignment.LEFT, Alignment.TOP, LwToolkit.VERTICAL)); c53.add(ch4); c53.add(ch5); c53.add(ch6); bp3.add(LwBorderPan.CENTER, c53); LwBorderPan bp4 = new LwBorderPan(); bp4.setLocation(220, 240); bp4.setPSSize(180, -1); bp4.setOpaque (false); bp4.add(LwBorderPan.TITLE, new LwLabel("Custom check boxes")); LwAdvViewMan m4 = new LwAdvViewMan(); m4.put("check.on", chOn1); m4.put("check.off",chOff1); LwCheckbox bp4ch1 = new LwCheckbox("Check 1"); bp4ch1.getBox().setViewMan(m4); LwAdvViewMan m5 = new LwAdvViewMan(); m5.put("check.on", chOn2); m5.put("check.off",chOff2); LwCheckbox bp4ch2 = new LwCheckbox("Check 2"); bp4ch2.getBox().setViewMan(m5); LwAdvViewMan m6 = new LwAdvViewMan(); m6.put("check.on", LwManager.getView("flag1")); m6.put("check.off", LwManager.getView("flag2")); LwCheckbox bp4ch3 = new LwCheckbox("Check 3"); bp4ch3.getBox().setViewMan(m6); LwPanel c54 = new LwPanel(); c54.setLwLayout(new LwFlowLayout(Alignment.LEFT, Alignment.TOP, LwToolkit.VERTICAL)); c54.add(bp4ch1); c54.add(bp4ch2); c54.add(bp4ch3); bp4.add(LwBorderPan.CENTER, c54); bp1.setOpaque(false); bp2.setOpaque(false); bp3.setOpaque(false); bp4.setOpaque(false); root.add(lab1); root.add(bp1); root.add(bp2); root.add(lab2); root.add(bp3); root.add(bp4); return root; } private static LwComponent getTreePanel() { LwContainer root = makeRoot(); LwLabel lab1 = makeTitle(" Tree view ...", 10); Tree cont = new Tree(new Item("root")); cont.add(cont.getRoot(), new Item("Item 1")); cont.add(cont.getRoot(), new Item("Item 2")); cont.add(cont.getRoot(), new Item("Checkbox View")); cont.add(cont.getRoot(), new Item("Bordered Item")); cont.add(cont.getChildAt(cont.getRoot(), 0), new Item("Image Item 1.1")); cont.add(cont.getChildAt(cont.getRoot(), 2), new Item("Multi line\nitem is supported\ntoo. Item 3.1")); cont.add(cont.getChildAt(cont.getRoot(), 2), new Item("Item 3.2")); cont.add(cont.getChildAt(cont.getRoot(), 2), new Item("Item 3.3")); LwTree tree = new LwTree(cont); tree.setViewProvider(new TVP()); tree.setLocation(20, 40); tree.setPSSize(430, 350); tree.setOpaque(false); tree.getViewMan(true).setBorder("br.etched"); tree.setSelectionColor(LwToolkit.darkBlue, false); root.add(lab1); root.add(tree); tree.select(cont.getRoot()); return root; } private static LwComponent getNotebookPanel() { LwContainer c1 = makeRoot(); LwNotebook nb1 = new LwNotebook(Alignment.TOP); nb1.addPage(new LwTabRender("Left"), makeNotebook(Alignment.LEFT)); nb1.addPage(new LwTabRender("Right"), makeNotebook(Alignment.RIGHT)); nb1.addPage(new LwTabRender("Bottom"), makeNotebook(Alignment.BOTTOM)); nb1.setOpaque(false); nb1.setLocation(20, 20); nb1.setPSSize(470, 500); c1.add (nb1); return c1; } private static LwComponent getComboBoxPanel() { LwContainer root = makeRoot(); LwLabel lab1 = makeTitle(" ComboBox ...", 10); LwCombo combo1 = new LwCombo(); combo1.setLocation(20, 40); combo1.setPSSize(120, -1); combo1.getList().add("Item 1"); combo1.getList().add("Item 2"); combo1.getList().add("Item 3"); combo1.getList().select(1); LwCombo combo2 = new LwCombo(); combo2.setLocation(220, 40); combo2.setPSSize(180, -1); combo2.getList().add(makeImageLabel("flag1", "Image Item 1")); combo2.getList().add(makeImageLabel("tick", "Image Item 2")); combo2.getList().add(makeImageLabel("flag2", "Image Item 3")); combo2.getList().select(1); LwLabel lab2 = makeTitle(" ComboBox with scroll bar...", 120); LwCombo combo3 = new LwCombo(); combo3.setLocation(20, 150); combo3.setPSSize(120, -1); combo3.setMaxPadHeight(100); for (int i=0; i<20; i++) combo3.getList().add("Item " + i); root.add(lab1); root.add(combo1); root.add(combo2); root.add(lab2); root.add(combo3); return root; } private static LwComponent getScrollPanel() throws Exception { LwContainer root = makeRoot(); LwLabel lab1 = makeTitle(" TextArea and List inside scroll panel...", 10); LwTextField tf1 = new LwTextField(readPropFile()); LwScrollPan sp1 = new LwScrollPan(tf1); sp1.setLocation(20, 40); sp1.setPSSize(200, 200); LwList list1 = new LwList(); list1.getViewMan(true).setBorder("br.sunken"); for (int i=0; i<25; i++) list1.add (new LwLabel("Item " + i)); list1.getPosController().setOffset(0); LwScrollPan sp2 = new LwScrollPan(list1); sp2.setLocation(260, 40); sp2.setPSSize(220, 200); LwLabel lab2 = makeTitle(" Image and tree inside scroll panel...", 260); LwImage img1 = new LwImage("rs/demo/cosmo1.jpg"); img1.getViewMan(true).setBorder("br.plain"); LwScrollPan sp3 = new LwScrollPan(img1); sp3.setLocation(20, 290); sp3.setPSSize(200, 230); LwTree tree = getTree(true); tree.select(tree.getModel().getRoot()); tree.getViewMan(true).setBorder("br.sunken"); LwScrollPan sp4 = new LwScrollPan(tree); sp4.setLocation(260, 290); sp4.setPSSize(230, 230); lab1.setOpaque(true); root.add(lab1); root.add(sp1); root.add(sp2); root.add(lab2); root.add(sp3); root.add(sp4); return root; } private static LwComponent getGridPanel() { LwContainer root = makeRoot(); LwLabel lab1 = makeTitle(" Simple grid ...", 10); Matrix m1 = new Matrix(4, 7); LwGrid g1 = new LwGrid(m1); g1.setCellInsets(3,3,3,3); g1.usePsMetric(true); for (int i=0; i<m1.getRows(); i++) for (int j=0; j<m1.getCols(); j++) m1.put (i, j, "Cell [" + i + "]" + "[" + j + "]"); Dimension ps = g1.getPreferredSize(); g1.setSize(ps.width, ps.height); g1.setLocation(20, 40); g1.getPosController().setOffset(0); LwLabel lab2 = makeTitle(" Customized views grid (try to work with the components inside)...", 140); Matrix m2 = new Matrix(2, 3); LwGrid g2 = new LwGrid(m2); LwGridCaption cap1 = new LwGridCaption(g2); cap1.putTitle (0, "Title 1"); cap1.putTitle (1, "Title 2"); cap1.putTitle (2, "Title 3"); g2.add(LwGrid.TOP_CAPTION_EL, cap1); g2.usePsMetric(true); g2.setPosController (null); g2.setViewProvider(new LwCompViews()); g2.setEditorProvider(new LwCompEditors()); m2.put(0, 1, new LwLabel(new Text("You can put\nmulti-line\ntext, image or\nany component\ninside cell."))); LwTree tree = getTree(false); m2.put(0, 2, tree); LwGrid g1_1 = getGrid(false); m2.put(1, 0, g1_1); m2.put(1, 1, new LwCheckbox("Off")); m2.put(1, 2, new LwButton("Button")); LwPanel cc1 = new LwPanel(); cc1.getViewMan(true).setView(new LwImgRender("rs/demo/cosmo1.jpg", LwImgRender.STRETCH)); cc1.setPSSize(g1_1.getPreferredSize().width, tree.getPreferredSize().height); m2.put(0, 0, cc1); ps = g2.getPreferredSize(); g2.setSize(ps.width, ps.height); g2.setLocation(20, 170);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -