/** * This function is used to re-run the analyser, and re-create the rows corresponding the its * results. */ private void refreshReviewTable() { reviewPanel.removeAll(); rows.clear(); GridBagLayout gbl = new GridBagLayout(); reviewPanel.setLayout(gbl); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridy = 0; try { Map<String, Long> sums = analyser.processLogFile(config.getLogFilename(), fromDate.getDate(), toDate.getDate()); for (Entry<String, Long> entry : sums.entrySet()) { String project = entry.getKey(); double hours = 1.0 * entry.getValue() / (1000 * 3600); addRow(gbl, gbc, project, hours); } for (String project : main.getProjectsTree().getTopLevelProjects()) if (!rows.containsKey(project)) addRow(gbl, gbc, project, 0); gbc.insets = new Insets(10, 0, 0, 0); addLeftLabel(gbl, gbc, "TOTAL"); gbc.gridx = 1; gbc.weightx = 1; totalLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 3)); gbl.setConstraints(totalLabel, gbc); reviewPanel.add(totalLabel); gbc.weightx = 0; addRightLabel(gbl, gbc); } catch (IOException e) { e.printStackTrace(); } recomputeTotal(); pack(); }
protected void displayNewTxf(String strLabel, String strValue) { strLabel = (strLabel == null) ? "" : strLabel.trim(); strValue = (strValue == null) ? "" : strValue.trim(); JCheckBox chkBox1 = new JCheckBox(Util.getImageIcon("boxGray.gif")); DataField txf1 = new DataField(strLabel); DataField txf2 = new DataField(strValue); JPanel pnlTxf = new JPanel(m_gbl); m_nRow = m_nRow + 1; txf1.setName("label"); txf2.setName("value"); /* 1st line of text field*/ m_gbc.weightx = 0; showComp(m_gbl, m_gbc, 0, m_nRow, 1, chkBox1); m_gbc.weightx = 1; showComp(m_gbl, m_gbc, GridBagConstraints.RELATIVE, m_nRow, 1, txf1); // showSpaces( gbl, gbc, 2, 6 ); showComp(m_gbl, m_gbc, GridBagConstraints.RELATIVE, m_nRow, 1, txf2); m_gbc.weightx = 0; txf1.addFocusListener(this); txf2.addFocusListener(this); m_objTxfValue.addToLabel(txf1); m_objTxfValue.addToValue(txf2); }
public DisplayResults() { GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); setLayout(gbl); gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; text.setForeground(Color.black); add(text, gbc); gbc.gridy = 0; gbc.gridwidth = GridBagConstraints.REMAINDER; add(emptyLabel, gbc); add(Box.createVerticalStrut(0), gbc); add(emptyLabel, gbc); /* gbc.gridy = 1; VTextMsg result = new VTextMsg(sshare, vnmrif, null); result.setPreferredSize(new Dimension(300, 30)); result.setForeground(Color.black); add( result, gbc ); */ setBorder( new CompoundBorder( BorderFactory.createTitledBorder(" Results "), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
/** Description of the Method */ public void init() { // super.init(); size = new Dimension(570, 570); contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(borderLayout1); Dimension d = messagePanel.getSize(); d.height += 20; messagePanel.setPreferredSize(d); contentPane.add(messagePanel, BorderLayout.SOUTH); contentPane.setOpaque(true); userPanel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(2, 2, 2, 2); messagePanel.setLayout(borderLayout5); contentPane.setOpaque(true); contentPane.setBackground(Color.white); this.setSize(size); messagePanel.add(labelMessage, BorderLayout.NORTH); // Logg.logg("MhClient: Före XttTree-skapande", 6); this.mhTable = new MhTable(root, false, this.labelMessage); // Logg.logg("MhClient: mhTable-skapande klart", 6); this.contentPane.add(this.mhTable.splitPane, BorderLayout.CENTER); }
/** * Adds a label that shows the percentage of hours spent on a particular project. * * @param gbl The layout to add the label to. * @param gbc The layout constraints to use. * @param row The row to link against. * @see {@link #addRow(GridBagLayout, GridBagConstraints, String, double)} */ private void addPercentLabel(GridBagLayout gbl, GridBagConstraints gbc, Row row) { gbc.gridx = 3; gbc.ipadx = 5; gbl.setConstraints(row.percentL, gbc); gbc.ipadx = 0; reviewPanel.add(row.percentL); }
protected void addComp(JPanel panel, Component comp, GridBagConstraints gbc, int x, int y) { gbc.gridx = x; gbc.gridy = y; gbc.fill = GridBagConstraints.HORIZONTAL; panel.add(comp, gbc); }
private void add(Component c, GridBagConstraints gbc, int x, int y, int w, int h) { gbc.gridx = x; gbc.gridy = y; gbc.gridwidth = w; gbc.gridheight = h; getContentPane().add(c, gbc); }
private void showSpaces(GridBagLayout gbl, GridBagConstraints gbc, int gridx, int gridy) { JLabel spaces = new JLabel(" "); gbc.gridx = gridx; gbc.gridy = gridy; gbl.setConstraints(spaces, gbc); m_pnlDisplay.add(spaces); }
/** * Adds a simple 'h' to show that the time period is specified in hours. * * @param gbl The layout to add the label to. * @param gbc The layout constraints to use. * @see {@link #addRow(GridBagLayout, GridBagConstraints, String, double)} */ private void addRightLabel(GridBagLayout gbl, GridBagConstraints gbc) { JLabel hLabel = new JLabel("h", SwingConstants.CENTER); gbc.gridx = 2; gbc.ipadx = 5; gbl.setConstraints(hLabel, gbc); gbc.ipadx = 0; reviewPanel.add(hLabel); }
/** * Adds an editable text field containing the hours spent on a project. * * @param gbl The layout to add the text field to. * @param gbc The layout constraints to use. * @param row The row to link against. * @param hours The number of hours spent on the project. * @see {@link #addRow(GridBagLayout, GridBagConstraints, String, double)} */ private void addMiddleField(GridBagLayout gbl, GridBagConstraints gbc, Row row, double hours) { row.hoursTF.setText(decimalFormat.format(hours)); gbc.gridx = 1; gbc.weightx = 1; gbl.setConstraints(row.hoursTF, gbc); gbc.weightx = 0; reviewPanel.add(row.hoursTF); }
private void setRow(GridBagConstraints c, GridBagLayout gridbag, Component obj1, Component obj2) { c.gridwidth = GridBagConstraints.RELATIVE; gridbag.setConstraints(obj1, c); add(obj1); c.gridwidth = GridBagConstraints.REMAINDER; // end row gridbag.setConstraints(obj2, c); add(obj2); c.fill = GridBagConstraints.BOTH; }
/** Get the panel for a given form. * */ public JPanel getPanelFor(ArrayList elements) { JPanel p = new JPanel(new GridBagLayout()); int maxCols = 1; int elementSize = elements.size(); for (int i = 0; i < elementSize; i++) { // count max number of cols // ((XmlUIElement)elements.get(i)).setEditable(true);//by jai int cols = ((XmlUIElement) elements.get(i)).getNumberOfColumns(); if (cols > maxCols) { maxCols = cols; } } GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; c.gridx = 0; c.gridy = 0; if (elementSize < 5) c.insets = new Insets(8, 8, 8, 14); else if (elementSize < 20) c.insets = new Insets(4, 4, 4, 10); else if ((elementSize > 40 && maxCols == 2) || (elementSize > 80 && maxCols == 4)) c.insets = new Insets(1, 1, 1, 8); else c.insets = new Insets(2, 2, 2, 8); int rowsAdded = 0; for (int i = 0; i < elementSize; i++) { elementsAndPanels.put(elements.get(i), p); rowsAdded += ((XmlUIElement) elements.get(i)).addComponents(p, c, 0, rowsAdded, maxCols); } return p; }
public void init(GUI gui) { m_gui = gui; // Create the display // width, height addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose(); } }); setSize(new Dimension(100, 100)); setBackground(Color.white); setFont(new Font("Helvetica", Font.PLAIN, 14)); GridBagLayout gridbag = new GridBagLayout(); setLayout(gridbag); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; recency = new TextField(Truline.userProps.getProperty("RecencyDays", "28"), 5); setRow(c, gridbag, new Label("Recency Days"), recency); maxdays = new TextField(Truline.userProps.getProperty("MaxDays", "120"), 5); setRow(c, gridbag, new Label("Max Days"), maxdays); maxvariant = new TextField(Truline.userProps.getProperty("MaxVariant", "25"), 5); setRow(c, gridbag, new Label("Max Variant"), maxvariant); maiden = new TextField(Truline.userProps.getProperty("UseMaiden", "Y"), 2); setRow(c, gridbag, new Label("Use Maiden"), maiden); betFactorVersion = new TextField(Truline.userProps.getProperty("BetFactorVersion", " "), 7); setRow(c, gridbag, new Label("Bet Factor Version"), betFactorVersion); datadir = new TextField(Truline.userProps.getProperty("DATADIR", "."), 40); setRow(c, gridbag, new Label("Data Directory"), datadir); fontsize = new TextField(Truline.userProps.getProperty("FontSize", "8"), 40); setRow(c, gridbag, new Label("Print Font Size (8,9,10)"), fontsize); printProgram = new TextField(Truline.userProps.getProperty("PrintProgram", "WordPad.exe /p"), 40); setRow(c, gridbag, new Label("Print program"), printProgram); // shell = new TextField(Truline.userProps.getProperty("Shell", "command"), // 40); // setRow(c, gridbag, new Label("Shell program"), shell); Panel panel1 = new Panel(); panel1.setLayout(new BorderLayout()); Button OKButton = new Button(" OK "); OKButton.setActionCommand("ok"); OKButton.addActionListener(this); panel1.add(OKButton, BorderLayout.CENTER); Panel panel2 = new Panel(); panel2.setLayout(new BorderLayout()); Button cancelButton = new Button("Cancel"); cancelButton.setActionCommand("cancel"); cancelButton.addActionListener(this); panel2.add(cancelButton, BorderLayout.CENTER); setRow(c, gridbag, panel2, panel1); pack(); show(); }
protected void buildPanel(String strPath) { strPath = FileUtil.openPath(strPath); ArrayList aListPath = new ArrayList(); BufferedReader reader = WFileUtil.openReadFile(strPath); if (reader == null) return; String strLine; try { while ((strLine = reader.readLine()) != null) { StringTokenizer strTok = new StringTokenizer(strLine, ":"); if (strTok.countTokens() < 4) continue; boolean bChecksum = false; boolean bShow = false; String strDir = strTok.nextToken(); String strChecksum = strTok.nextToken(); if (strChecksum.equalsIgnoreCase("checksum")) bChecksum = true; if (bChecksum && (strDir.equals("file") || strDir.equals("dir"))) { String strValue = strTok.nextToken(); String strShow = strTok.nextToken(); if (strShow.equalsIgnoreCase("yes")) bShow = true; if (bShow) aListPath.add(strValue); } } m_cmbPath = new JComboBox(aListPath.toArray()); JPanel pnlDisplay = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints( 0, 0, 1, 1, 0.2, 0.2, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0); pnlDisplay.add(m_cmbPath, gbc); gbc.gridx = 1; pnlDisplay.add(m_cmbChecksum, gbc); add(pnlDisplay, BorderLayout.NORTH); add(m_txaChecksum, BorderLayout.CENTER); } catch (Exception e) { e.printStackTrace(); } }
private void showComp( GridBagLayout gbl, GridBagConstraints gbc, int gridx, int gridy, int gridwidth, JComponent comp) { gbc.gridx = gridx; gbc.gridy = gridy; gbl.setConstraints(comp, gbc); m_pnlDisplay.add(comp); }
private void showInstruction( GridBagLayout gbl, GridBagConstraints gbc, int gridx, int gridy, int gridwidth, JLabel instruction) { gbc.gridwidth = gridwidth; gbc.gridx = gridx; gbc.gridy = gridy; gbl.setConstraints(instruction, gbc); instruction.setForeground(Color.black); m_pnlDisplay.add(instruction); }
public String[] promptKeyboardInteractive( String destination, String name, String instruction, String[] prompt, boolean[] echo) { panel = new JPanel(); panel.setLayout(new GridBagLayout()); gbc.weightx = 1.0; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.gridx = 0; panel.add(new JLabel(instruction), gbc); gbc.gridy++; gbc.gridwidth = GridBagConstraints.RELATIVE; JTextField[] texts = new JTextField[prompt.length]; for (int i = 0; i < prompt.length; i++) { gbc.fill = GridBagConstraints.NONE; gbc.gridx = 0; gbc.weightx = 1; panel.add(new JLabel(prompt[i]), gbc); gbc.gridx = 1; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weighty = 1; if (echo[i]) { texts[i] = new JTextField(20); } else { texts[i] = new JPasswordField(20); } panel.add(texts[i], gbc); gbc.gridy++; } if (JOptionPane.showConfirmDialog( null, panel, destination + ": " + name, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION) { String[] response = new String[prompt.length]; for (int i = 0; i < prompt.length; i++) { response[i] = texts[i].getText(); } return response; } else { return null; // cancel } }
private void addGrid( JPanel p, Component co, int x, int y, int w, int fill, double wx, int anchor) { GridBagConstraints c = new GridBagConstraints(); c.gridx = x; c.gridy = y; c.gridwidth = w; c.anchor = anchor; c.weightx = wx; c.fill = fill; if (fill == GridBagConstraints.BOTH || fill == GridBagConstraints.VERTICAL) c.weighty = 1.0; c.insets = new Insets(y == 0 ? 10 : 0, GAP, GAP, GAP); p.add(co, c); }
protected void displayNewTxf(String strLabel, String strValue) { strLabel = (strLabel != null) ? strLabel.trim() : ""; strValue = (strValue != null) ? strValue.trim() : ""; JCheckBox chk1 = new JCheckBox(Util.getImageIcon("boxGray.gif")); final DataField txf1 = new DataField(strLabel); final DataField txf2 = new DataField(strValue); m_nRow = m_nRow + 1; txf1.setName("label"); txf2.setName("value"); // new field if (strLabel.equals("") && strValue.equals("")) { txf2.setText(INFOSTR); txf2.addMouseListener(m_mlTxf); if (timer != null) timer.cancel(); timer = new java.util.Timer(); timer.schedule( new TimerTask() { public void run() { WUtil.blink(txf2, WUtil.FOREGROUND); } }, delay, delay); } /* 1st line of text field*/ m_gbc.weightx = 0; showComp(m_gbl, m_gbc, 0, m_nRow, 1, chk1); m_gbc.weightx = 1; showComp(m_gbl, m_gbc, GridBagConstraints.RELATIVE, m_nRow, 1, txf1); // showSpaces( gbl, gbc, 2, 6 ); showComp(m_gbl, m_gbc, GridBagConstraints.RELATIVE, m_nRow, 1, txf2); m_gbc.weightx = 0; txf1.addFocusListener(this); txf2.addFocusListener(this); // Add the textfields to the respective arrays, so that they // can be retreived later for writing to the file. m_objTxfValue.addToLabel(txf1); m_objTxfValue.addToValue(txf2); }
public DisplayUserDirectory() { GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); setLayout(gbl); gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; hmlabel.setForeground(Color.black); add(hmlabel, gbc); add(Box.createHorizontalStrut(10), gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; add(hmdir, gbc); add(Box.createVerticalStrut(15), gbc); gbc.gridwidth = 1; vjlabel.setForeground(Color.black); add(vjlabel, gbc); add(Box.createHorizontalStrut(10), gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; add(vjdir, gbc); add(Box.createVerticalStrut(0), gbc); gbc.gridwidth = 1; vjlabel2.setForeground(Color.black); add(vjlabel2, gbc); setBorder( new CompoundBorder( // i18n // BorderFactory.createTitledBorder(" User_Directories "), BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
private void setupWindowAndListeners() { // Initialize Objects title = new JLabel("Coordinated Behavior Tree", JLabel.CENTER); treeScroller = new JScrollPane(); treeNodes = new Vector<PBTreeNode>(); treeView = new JTree(treeNodes); stratView = new JList(); formView = new JList(); roleView = new JList(); subRoleView = new JList(); // Setup our display selection drop down list selectorList = new Vector<String>(); selectorList.add(PBTREE_ID); selectorList.add(STRAT_ID); selectorList.add(FORM_ID); selectorList.add(ROLE_ID); selectorList.add(SUBROLE_ID); displaySelector = new JComboBox(selectorList); displaySelector.addActionListener(this); treeScroller.getViewport().setView(treeView); treeMode = PBTREE_ID; treeScroller.setFocusable(false); treeScroller.addMouseListener(this); subRoleView.addMouseListener(this); // Setup Layout GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); // Add Items c.fill = GridBagConstraints.BOTH; c.gridwidth = GridBagConstraints.REMAINDER; gridbag.setConstraints(title, c); c.gridheight = 2; add(title); gridbag.setConstraints(displaySelector, c); add(displaySelector); c.gridheight = GridBagConstraints.REMAINDER; gridbag.setConstraints(treeScroller, c); add(treeScroller); }
// For setting the gridbagconstraints for this application public static void setConstraints(GridBagConstraints c, int fill, int col, int row) { c.fill = fill; c.weightx = 1.0; c.weighty = 1.0; c.gridx = col; c.gridy = row; c.gridwidth = 1; c.gridheight = 1; Insets insets = new Insets(5, 5, 5, 5); c.insets = insets; }
/** * The constructor. * * @param parent The parent. * @param idata The installation data. */ public FinishPanel(InstallerFrame parent, InstallData idata) { super(parent, idata); vs = new VariableSubstitutor(idata.getVariableValueMap()); // The 'super' layout GridBagLayout superLayout = new GridBagLayout(); setLayout(superLayout); GridBagConstraints gbConstraints = new GridBagConstraints(); gbConstraints.insets = new Insets(0, 0, 0, 0); gbConstraints.fill = GridBagConstraints.NONE; gbConstraints.anchor = GridBagConstraints.CENTER; // We initialize our 'real' layout centerPanel = new JPanel(); layout = new BoxLayout(centerPanel, BoxLayout.Y_AXIS); centerPanel.setLayout(layout); superLayout.addLayoutComponent(centerPanel, gbConstraints); add(centerPanel); }
public DisplayTemplate(String strDir, String strDefDirFile) { setLayout(m_gbl); m_gbc.anchor = GridBagConstraints.NORTHWEST; m_gbc.fill = GridBagConstraints.HORIZONTAL; m_strPathDir = strDir; m_strDefDirFile = strDefDirFile; setLayout(new BorderLayout()); m_pnlDisplay = new JPanel(m_gbl); JScrollPane spDisplay = new JScrollPane(m_pnlDisplay); add(spDisplay, BorderLayout.CENTER); JComponent pnlTool = getToolBar(); add(pnlTool, BorderLayout.NORTH); layoutUIComponents(FileUtil.openPath(m_strDefDirFile), true); VItemArea1.addChangeListener(this); VUserToolBar.addChangeListener(this); }
protected void layoutUIComponents(String strPath, boolean bDefaultFile) { JLabel label = null; // i18n // label = new JLabel( "File names can be constructed from a template. The LABEL field is " ); label = new JLabel( Util.getAdmLabel( "_admin_File_names_can_be_constructed_from_a_template._The_LABEL_field_is_")); label.setForeground(Color.black); // m_gbc.weightx = 0.5; showInstruction(m_gbl, m_gbc, 0, 0, 7, label); // i18n // label = new JLabel( "presented as the choice to the user in the \"Data save\" pop-up." ); label = new JLabel( Util.getAdmLabel( "_admin_presented_as_the_choice_to_the_user_in_the_Data_save_pop-up.")); showInstruction(m_gbl, m_gbc, 0, 1, 7, label); showInstruction(m_gbl, m_gbc, 0, 2, 1, new JLabel("")); label = new JLabel(Util.getAdmLabel("_adm_LABEL")); label.setForeground(Color.black); m_gbc.gridx = 1; m_gbc.gridy = 2; m_gbc.ipadx = 10; m_gbl.setConstraints(label, m_gbc); m_pnlDisplay.add(label); label = new JLabel(" "); m_gbc.gridx = 2; m_gbc.gridy = 2; m_gbc.ipadx = 0; // reset to default m_gbc.gridwidth = 5; m_gbl.setConstraints(label, m_gbc); // add( label ); showInstruction(m_gbl, m_gbc, 2, 2, 1, new JLabel(Util.getAdmLabel("_admin_TEMPLATE"))); m_nRow = 3; m_bDefaultFile = bDefaultFile; m_objTxfValue.clearArrays(); displayNewTxf(strPath); m_pnlDisplay.setBorder( new CompoundBorder( BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
// For setting the gridbagconstraints for this application public static void setConstraints( GridBagConstraints c, int fill, double wx, double wy, int gx, int gy, int gw, int gh, int ins) { c.fill = fill; c.weightx = (float) wx; c.weighty = (float) wy; c.gridx = gx; c.gridy = gy; c.gridwidth = gw; c.gridheight = gh; Insets insets = new Insets(ins, ins, ins, ins); c.insets = insets; }
protected void layoutUIComponents(String strPath, boolean bDefaultFile) { // gbc.weightx = 0.5; showInstructions(m_gbl, m_gbc, 0, 0, 7, infoLabel1); showInstructions(m_gbl, m_gbc, 0, 1, 7, infoLabel2); showInstructions(m_gbl, m_gbc, 0, 2, 7, infoLabel3); /*showInstructions( gbl, gbc, 0, 3, 7, infoLabel4 ); showInstructions( gbl, gbc, 0, 4, 7, infoLabel5 );*/ showInstructions(m_gbl, m_gbc, 0, 5, 1, new JLabel("")); // i18n // label = new JLabel( "LABEL" ); label = new JLabel(Util.getAdmLabel("_adm_LABEL")); label.setForeground(Color.black); m_gbc.gridx = 1; m_gbc.gridy = 5; // gbc.ipadx = 10; m_gbl.setConstraints(label, m_gbc); m_pnlDisplay.add(label); label = new JLabel(" "); m_gbc.gridx = 2; m_gbc.gridy = 5; m_gbc.ipadx = 0; m_gbc.gridwidth = 5; m_gbc.weightx = 0; m_gbl.setConstraints(label, m_gbc); // add( label ); // i18n // showInstructions( m_gbl, m_gbc, 2, 5, 1, new JLabel( "DIRECTORY" )); showInstructions(m_gbl, m_gbc, 2, 5, 1, new JLabel(Util.getAdmLabel("_adm_DIRECTORY"))); m_nRow = 5; m_bDefaultFile = bDefaultFile; m_objTxfValue.clearArrays(); displayNewTxf(strPath); m_pnlDisplay.setBorder( new CompoundBorder( // i18n // BorderFactory.createTitledBorder( " Parent Directories "), BorderFactory.createTitledBorder(Util.getAdmLabel("_adm_Parent_Directories")), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
private void išdėstymas() { setLocation(500, 20); // sudedame duomenis į paneles panAutoSąr.add(scrNeregZona); panAutoSąr.add(scrRegZona); panDuomenys.add(panRegNumeris); panDuomenys.add(panRez); panDuomenys.add(panMygt); GridBagLayout dėstymoBūdas = new GridBagLayout(); GridBagConstraints dėsnis = new GridBagConstraints(); panRegNumeris.setLayout(dėstymoBūdas); panRez.setLayout(dėstymoBūdas); dėsnis.fill = GridBagConstraints.NONE; dėsnis.insets = new Insets(5, 8, 0, 6); dėsnis.anchor = GridBagConstraints.LINE_END; dėsnis.gridy = GridBagConstraints.RELATIVE; dėsnis.gridx = 0; panRegNumeris.add(new JLabel("Auto Numeris"), dėsnis); panRez.add(new JLabel("Neregistruotų kiekis"), dėsnis); panRez.add(new JLabel("Registruotų kiekis"), dėsnis); dėsnis.anchor = GridBagConstraints.LINE_START; dėsnis.gridx = 1; panRegNumeris.add(tfAutoNr, dėsnis); panRez.add(tfNeregKiekis, dėsnis); panRez.add(tfRegKiekis, dėsnis); panMygt.setLayout(new BoxLayout(panMygt, BoxLayout.Y_AXIS)); panMygt.add(jbReg); panMygt.add(jbRasti); panMygt.add(jbSkaityti); panMygt.add(jbSaveObj); panMygt.add(jbLoadObj); }
private JComponent createButtons() { JPanel pane = new JPanel(new GridBagLayout()); JButton btnOK = new JButton(_I("ok")); btnOK.addActionListener(new ActionOK(this)); JButton btnApply = new JButton(_I("apply")); btnApply.addActionListener(new ActionApply(this)); JButton btnCancel = new JButton(_I("cancel")); btnCancel.addActionListener(new ActionCancel(this)); GridBagConstraints c = new GridBagConstraints(); c.gridy = 3; c.gridx = 0; c.insets = new Insets(5, 0, 10, 0); c.anchor = GridBagConstraints.LAST_LINE_END; pane.add(btnOK, c); c.gridx = 1; pane.add(btnApply, c); c.gridx = 2; pane.add(btnCancel, c); return pane; }
/** * Standard constructor: it needs the parent frame. * * @param parent the dialog's parent */ public DialogPrint(JFrame parent) { super(400, 350, parent, Globals.messages.getString("Print_dlg"), true); addComponentListener(this); export = false; // Ensure that under MacOSX >= 10.5 Leopard, this dialog will appear // as a document modal sheet getRootPane().putClientProperty("apple.awt.documentModalSheet", Boolean.TRUE); GridBagLayout bgl = new GridBagLayout(); GridBagConstraints constraints = new GridBagConstraints(); Container contentPane = getContentPane(); contentPane.setLayout(bgl); constraints.insets.right = 30; JLabel empty = new JLabel(" "); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; contentPane.add(empty, constraints); // Add " " label JLabel empty1 = new JLabel(" "); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 3; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; contentPane.add(empty1, constraints); // Add " " label mirror_CB = new JCheckBox(Globals.messages.getString("Mirror")); constraints.gridx = 1; constraints.gridy = 0; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.WEST; contentPane.add(mirror_CB, constraints); // Add Print Mirror cb fit_CB = new JCheckBox(Globals.messages.getString("FitPage")); constraints.gridx = 1; constraints.gridy = 1; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.WEST; contentPane.add(fit_CB, constraints); // Add Fit to page cb bw_CB = new JCheckBox(Globals.messages.getString("B_W")); constraints.gridx = 1; constraints.gridy = 2; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.WEST; contentPane.add(bw_CB, constraints); // Add BlackWhite cb landscape_CB = new JCheckBox(Globals.messages.getString("Landscape")); constraints.gridx = 1; constraints.gridy = 3; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.WEST; contentPane.add(landscape_CB, constraints); // Add landscape cb // Put the OK and Cancel buttons and make them active. JButton ok = new JButton(Globals.messages.getString("Ok_btn")); JButton cancel = new JButton(Globals.messages.getString("Cancel_btn")); constraints.gridx = 0; constraints.gridy = 4; constraints.gridwidth = 4; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.EAST; // Put the OK and Cancel buttons and make them active. Box b = Box.createHorizontalBox(); b.add(Box.createHorizontalGlue()); ok.setPreferredSize(cancel.getPreferredSize()); if (Globals.okCancelWinOrder) { b.add(ok); b.add(Box.createHorizontalStrut(12)); b.add(cancel); } else { b.add(cancel); b.add(Box.createHorizontalStrut(12)); b.add(ok); } ok.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { export = true; setVisible(false); } }); cancel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { setVisible(false); } }); // Here is an action in which the dialog is closed AbstractAction cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { setVisible(false); } }; contentPane.add(b, constraints); // Add OK/cancel dialog DialogUtil.addCancelEscape(this, cancelAction); pack(); DialogUtil.center(this); getRootPane().setDefaultButton(ok); }