public MasterConfigPanel() { this.setLayout(layout); Border blackline = BorderFactory.createLineBorder(Color.BLACK); for (int i = 0; i < textfield.length; i++) { label[i] = new JLabel(labels[i]); textfield[i] = new JTextField(20); this.add(label[i]); this.add(textfield[i]); textfield[i].addFocusListener(this); } label[5] = new JLabel(labels[5]); this.add(label[5]); combo = new JComboBox(trust); combo.setSelectedIndex(0); combo.addActionListener(this); this.add(combo); textfield[0].setText("<For Example: 10>"); textfield[1].setText("<For Example: AM10>"); textfield[2].setText("<For Example: modelbase.PurchaseLogicCollusion>"); textfield[3].setText("<For Example: modelbase.RatingLogicCollusion>"); textfield[4].setText("<For Example: 0,4,5,7,9>"); next_config = new JButton("Config"); this.add(next_config); brsConfig = new BRSConfigPanel(); TitledBorder brsTitle = BorderFactory.createTitledBorder(blackline, "BRS Trust Model Configuration"); brsConfig.setBorder(brsTitle); travosConfig = new TRAVOSConfigPanel(); TitledBorder travosTitle = BorderFactory.createTitledBorder(blackline, "TRAVOS Trust Model Configuration"); travosConfig.setBorder(travosTitle); personalizedConfig = new PersonalizedConfigPanel(); TitledBorder personalizedTitle = BorderFactory.createTitledBorder(blackline, "Personalized Trust Model Configuration"); personalizedConfig.setBorder(personalizedTitle); othersConfig = new OthersConfigPanel(); TitledBorder othersTitle = BorderFactory.createTitledBorder(blackline, "Others Trust Model Configuration"); othersConfig.setBorder(othersTitle); this.add(brsConfig); this.add(travosConfig); this.add(personalizedConfig); this.add(othersConfig); layout.putConstraint(SpringLayout.WEST, label[0], 5, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, label[0], 5, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, textfield[0], 95, SpringLayout.EAST, label[0]); layout.putConstraint(SpringLayout.NORTH, textfield[0], 5, SpringLayout.NORTH, this); for (int i = 1; i < textfield.length; i++) { layout.putConstraint(SpringLayout.WEST, label[i], 5, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, label[i], 5, SpringLayout.SOUTH, textfield[i - 1]); layout.putConstraint(SpringLayout.WEST, textfield[i], 0, SpringLayout.WEST, textfield[i - 1]); layout.putConstraint( SpringLayout.NORTH, textfield[i], 5, SpringLayout.SOUTH, textfield[i - 1]); layout.putConstraint(SpringLayout.EAST, textfield[i], 0, SpringLayout.EAST, textfield[0]); } layout.putConstraint(SpringLayout.WEST, label[5], 5, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, label[5], 5, SpringLayout.SOUTH, textfield[4]); layout.putConstraint(SpringLayout.WEST, combo, 0, SpringLayout.WEST, textfield[4]); layout.putConstraint(SpringLayout.NORTH, combo, 5, SpringLayout.SOUTH, textfield[4]); layout.putConstraint(SpringLayout.EAST, combo, 0, SpringLayout.EAST, textfield[0]); layout.putConstraint(SpringLayout.WEST, brsConfig, 5, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, brsConfig, 5, SpringLayout.SOUTH, combo); layout.putConstraint(SpringLayout.EAST, brsConfig, 5, SpringLayout.EAST, combo); layout.putConstraint(SpringLayout.WEST, travosConfig, 5, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, travosConfig, 5, SpringLayout.SOUTH, combo); layout.putConstraint(SpringLayout.EAST, travosConfig, 5, SpringLayout.EAST, combo); layout.putConstraint(SpringLayout.WEST, personalizedConfig, 5, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, personalizedConfig, 5, SpringLayout.SOUTH, combo); layout.putConstraint(SpringLayout.EAST, personalizedConfig, 5, SpringLayout.EAST, combo); layout.putConstraint(SpringLayout.WEST, othersConfig, 5, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, othersConfig, 5, SpringLayout.SOUTH, combo); layout.putConstraint(SpringLayout.EAST, othersConfig, 5, SpringLayout.EAST, combo); layout.putConstraint(SpringLayout.WEST, next_config, 0, SpringLayout.WEST, textfield[0]); layout.putConstraint( SpringLayout.NORTH, next_config, 5, SpringLayout.SOUTH, personalizedConfig); layout.putConstraint(SpringLayout.SOUTH, this, 5, SpringLayout.SOUTH, next_config); this.setVisible(false); }
private void makeGUI() { // Set Frames properties this.setTitle("Search And Edit Student"); this.setSize(700, 500); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // Add components to panel_1 FlowLayout layout = new FlowLayout(); layout.setAlignment(FlowLayout.LEFT); panel_1.setLayout(layout); panel_1.add(searchcombobox); panel_1.add(searchtextfield); panel_1.add(searchbutton); panel_1.add(allfieldcheckbox); panel_1.setBackground(Color.WHITE); // Add panel_1 to frame this.add(panel_1, BorderLayout.PAGE_START); // Add components to panel_2 panel_2.add(totalstudentlabel); panel_2.setBackground(Color.WHITE); // Add panel_2 to frame this.add(panel_2, BorderLayout.PAGE_END); // Add components to panel_3 panel_3.setLayout(new GridLayout(1, 0)); // Design panel_5 GridBagLayout gbl = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; panel_5.setLayout(gbl); c.gridx = 0; c.gridy = 0; c.gridheight = 4; c.gridwidth = GridBagConstraints.REMAINDER; panel_5.add(panel_3, c); c.gridx = 0; c.gridy = 5; c.gridheight = 2; c.gridwidth = GridBagConstraints.REMAINDER; panel_5.add(panel_4, c); // Add components to panel_4 panel_4.setLayout(new GridLayout(1, 2)); panel_4.add(panel_6); // Lower Left panel_4.add(panel_7); // Lower Right // Design panel 6 SpringLayout sl = new SpringLayout(); panel_6.setLayout(sl); sl.putConstraint(SpringLayout.WEST, feespayedlabel, 2, SpringLayout.WEST, panel_6); sl.putConstraint(SpringLayout.NORTH, feespayedlabel, 2, SpringLayout.NORTH, panel_6); sl.putConstraint(SpringLayout.WEST, addfeestextfield, 2, SpringLayout.EAST, feespayedlabel); sl.putConstraint(SpringLayout.NORTH, addfeestextfield, 2, SpringLayout.NORTH, panel_6); sl.putConstraint(SpringLayout.WEST, addfeesbutton, 2, SpringLayout.EAST, addfeestextfield); sl.putConstraint(SpringLayout.NORTH, addfeesbutton, 2, SpringLayout.NORTH, panel_6); sl.putConstraint(SpringLayout.WEST, feesduelabel, 2, SpringLayout.WEST, panel_6); sl.putConstraint(SpringLayout.NORTH, feesduelabel, 2, SpringLayout.SOUTH, addfeesbutton); sl.putConstraint(SpringLayout.WEST, totalfeeslabel, 2, SpringLayout.WEST, panel_6); sl.putConstraint(SpringLayout.NORTH, totalfeeslabel, 2, SpringLayout.SOUTH, feesduelabel); sl.putConstraint(SpringLayout.WEST, coursecombobox, 2, SpringLayout.WEST, panel_6); sl.putConstraint(SpringLayout.NORTH, coursecombobox, 3, SpringLayout.SOUTH, totalfeeslabel); sl.putConstraint(SpringLayout.WEST, spinner, 2, SpringLayout.EAST, coursecombobox); sl.putConstraint(SpringLayout.NORTH, spinner, 3, SpringLayout.SOUTH, totalfeeslabel); sl.putConstraint(SpringLayout.WEST, addcoursebutton, 2, SpringLayout.WEST, panel_6); sl.putConstraint(SpringLayout.NORTH, addcoursebutton, 3, SpringLayout.SOUTH, coursecombobox); panel_6.add(feespayedlabel); panel_6.add(addfeestextfield); panel_6.add(addfeesbutton); panel_6.add(feesduelabel); panel_6.add(totalfeeslabel); panel_6.add(coursecombobox); panel_6.add(spinner); panel_6.add(addcoursebutton); // Set panel 7 layout panel_7.setLayout(new GridLayout(1, 0)); panel_7.setBackground(Color.WHITE); // Add panel_5 to frame this.add(panel_5); update(); // Show frame this.validate(); this.setVisible(true); }
public Marketplace_Master() { this.setLayout(layout); for (int i = 0; i < textfield.length; i++) { label[i] = new JLabel(labels[i]); textfield[i] = new JTextField(20); this.add(label[i]); this.add(textfield[i]); textfield[i].addFocusListener(this); } label[5] = new JLabel(labels[5]); this.add(label[5]); combo = new JComboBox(trust); combo.setSelectedIndex(0); this.add(combo); this.setTextField(); layout.putConstraint(SpringLayout.WEST, label[0], 10, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, label[0], 10, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, textfield[0], 101, SpringLayout.EAST, label[0]); layout.putConstraint(SpringLayout.NORTH, textfield[0], 10, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.EAST, textfield[0], -10, SpringLayout.EAST, this); for (int i = 1; i < textfield.length; i++) { layout.putConstraint(SpringLayout.WEST, label[i], 10, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, label[i], 10, SpringLayout.SOUTH, textfield[i - 1]); layout.putConstraint(SpringLayout.WEST, textfield[i], 0, SpringLayout.WEST, textfield[i - 1]); layout.putConstraint( SpringLayout.NORTH, textfield[i], 10, SpringLayout.SOUTH, textfield[i - 1]); layout.putConstraint(SpringLayout.EAST, textfield[i], 0, SpringLayout.EAST, textfield[0]); } layout.putConstraint(SpringLayout.WEST, label[5], 5, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, label[5], 5, SpringLayout.SOUTH, textfield[4]); layout.putConstraint(SpringLayout.WEST, combo, 0, SpringLayout.WEST, textfield[4]); layout.putConstraint(SpringLayout.NORTH, combo, 5, SpringLayout.SOUTH, textfield[4]); layout.putConstraint(SpringLayout.EAST, combo, 0, SpringLayout.EAST, textfield[0]); layout.putConstraint(SpringLayout.SOUTH, this, 10, SpringLayout.SOUTH, combo); this.setVisible(false); }
/** creates a JTextfield with JLabel (contains labelText) and an identifier id */ public TLangTextField(String labelText, int id, FieldPopup popup) { super(); // this.setOpaque( false ) ; this.setLayout(new OverlayLayout(this)); // this.setBorder( BorderFactory.createEtchedBorder()); listenerList = new EventListenerList(); // build the labeled textfield -------------------------------------------- textField = new IDTextField(id, popup) { public void paint(Graphics g) { super.paint(g); if (currentImage != null) { Graphics2D g2 = (Graphics2D) g; g2.drawImage(currentImage, -8, -2, this); } // System.out.println( "paint " +(counter++) ) ; } }; textField.addKeyListener(this); textField.addFocusListener(this); textField.setPopupName(labelText); textField.setMaximumSize(new Dimension(2000, 30)); textField.setFont(GUIGlobals.defaultLanguageFont); // charat position leerInsets = textField.getMargin(); label = new JLabel(labelText, JLabel.TRAILING); label.setLabelFor(textField); label.addFocusListener(this); // insert label and textfield layout = new SpringLayout(); bigPanel = new JPanel(layout); // bigPanel.setOpaque( false ) ; bigPanel.add(label); bigPanel.add(textField); // Adjust constraints for the label so it's at (5,5). layout.putConstraint(SpringLayout.WEST, label, 10, SpringLayout.WEST, bigPanel); layout.putConstraint(SpringLayout.NORTH, label, 6, SpringLayout.NORTH, bigPanel); // Adjust constraints for the text field so it's at // (<label's right edge> + 5, 5). layout.putConstraint(SpringLayout.WEST, textField, 10, SpringLayout.EAST, label); layout.putConstraint(SpringLayout.NORTH, textField, -2, SpringLayout.NORTH, label); // Adjust constraints for the content pane: Its right // edge should be 5 pixels beyond the text field's right // edge, and its bottom edge should be 5 pixels beyond // the bottom edge of the tallest component (which we'll // assume is textField). layout.putConstraint(SpringLayout.EAST, bigPanel, 5, SpringLayout.EAST, textField); layout.putConstraint( SpringLayout.SOUTH, bigPanel, // 8, // SpringLayout.SOUTH, label ) ; 5, SpringLayout.SOUTH, textField); // build image section ---------------------------------------------------- imageLabel = new JLabel(); imageLabel.setOpaque(false); fieldState = REQUIRE_STATE; setImage(); textField.other = imageLabel; // insert image and labeled-field ----------------------------------------- this.add(imageLabel); this.add(bigPanel); // pipe all focus events to local class methods super.addFocusListener(this); }