protected void populateDialog(JDialog dlg) { dlg.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dlg.setResizable(false); dlg.setSize(new Dimension(350, 135)); dlg.setTitle("New TurboVNC Connection"); dlg.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { if (VncViewer.nViewers == 1) { if (cc.viewer instanceof VncViewer) { ((VncViewer) cc.viewer).exit(1); } } else { ret = false; endDialog(); } } }); dlg.getContentPane().setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.LINE_START; gbc.fill = GridBagConstraints.BOTH; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.gridheight = 1; gbc.insets = new Insets(0, 0, 0, 0); gbc.ipadx = 0; gbc.ipady = 0; gbc.weightx = 1; gbc.weighty = 1; dlg.getContentPane().add(topPanel, gbc); dlg.getContentPane().add(buttonPanel); dlg.pack(); }
public void createDialogBox(String Roll, String ExamYear) { RPS = new JDialog(); this.NumberOfCourses = DataTransfer.Courses.size(); this.Roll = Roll; this.ExamYear = ExamYear; this.Session = setSession(); final int Final = NumberOfCourses; final int Height = (Final * 40 + 270 > 600) ? Final * 40 + 270 : 600; Panel = new JPanel() { protected void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage( new ImageIcon(getClass().getResource("/Icons/8.jpg")).getImage(), 0, 0, 950, Height, null); ButtonBorder.paintBorder(this, g, 284, 84 + Final * 40 + 60 + 60, 252, 32); } }; Panel.setPreferredSize( new Dimension( 600, NumberOfCourses * 40 + 150 + 60 + 60)); // 50+(100*5+3*5)+50, 120+NumberOfCourses*30+(NumberOfCourses-1)*10+50+60 Panel.setLayout(null); RollLabel = new JLabel("Roll : " + this.Roll, SwingConstants.CENTER); RollLabel.setForeground(Color.WHITE); RollLabel.setFont(new Font("SERRIF", Font.BOLD, 15)); RollLabel.setBounds(112, 20, 615, 20); Panel.add(RollLabel); SessionLabel = new JLabel("Session : " + this.Session, SwingConstants.CENTER); SessionLabel.setForeground(Color.WHITE); SessionLabel.setFont(new Font("SERRIF", Font.BOLD, 15)); SessionLabel.setBounds(112, 40, 615, 20); Panel.add(SessionLabel); ColumnName = new JLabel("", SwingConstants.LEFT); ColumnName.setText( " COURSE NO. TOTAL MARKS GRADE POINT LETTER GRADE COURSE CREDIT EXAM-TYPE"); ColumnName.setForeground(Color.WHITE); ColumnName.setFont(new Font("SERRIF", Font.BOLD, 10)); ColumnName.setBounds(112, 80, 635, 30); Panel.add(ColumnName); TakenLabel1 = new JLabel("Credit Hour Taken : ", SwingConstants.RIGHT); TakenLabel1.setForeground(Color.WHITE); TakenLabel1.setFont(new Font("SERRIF", Font.ITALIC, 12)); TakenLabel1.setBounds(112, 85 + NumberOfCourses * 40 + 60, 130, 20); Panel.add(TakenLabel1); TakenLabel2 = new JLabel("", SwingConstants.LEFT); TakenLabel2.setForeground(Color.WHITE); TakenLabel2.setFont(new Font("SERRIF", Font.ITALIC, 12)); TakenLabel2.setBounds(242, 85 + NumberOfCourses * 40 + 60, 50, 20); Panel.add(TakenLabel2); CompletedLabel1 = new JLabel("Credit Hour Completed : ", SwingConstants.RIGHT); CompletedLabel1.setForeground(Color.WHITE); CompletedLabel1.setFont( new Font("SERRIF", Font.ITALIC, 12)); // 50,85+NumberOfCourses*40+60+20,150,20 CompletedLabel1.setBounds(342, 85 + NumberOfCourses * 40 + 60, 150, 20); Panel.add(CompletedLabel1); CompletedLabel2 = new JLabel("opps", SwingConstants.LEFT); CompletedLabel2.setForeground(Color.WHITE); CompletedLabel2.setFont(new Font("SERRIF", Font.ITALIC, 12)); CompletedLabel2.setBounds(492, 85 + NumberOfCourses * 40 + 60, 50, 20); Panel.add(CompletedLabel2); GPALabel1 = new JLabel("GPA : ", SwingConstants.RIGHT); GPALabel1.setForeground(Color.WHITE); GPALabel1.setFont(new Font("SERRIF", Font.ITALIC, 12)); GPALabel1.setBounds(552, 85 + NumberOfCourses * 40 + 60, 80, 20); Panel.add(GPALabel1); GPALabel2 = new JLabel("36.25", SwingConstants.LEFT); GPALabel2.setForeground(Color.WHITE); GPALabel2.setFont(new Font("SERRIF", Font.ITALIC, 12)); GPALabel2.setBounds(632, 85 + NumberOfCourses * 40 + 60, 50, 20); Panel.add(GPALabel2); DocButton = new JButton("Create Document"); DocButton.setFont(new Font("SERRIF", Font.BOLD, 15)); DocButton.setBounds( 285, 85 + NumberOfCourses * 40 + 60 + 60, 250, 30); // 50+NumberOfCourses*30+(NumberOfCourses-1)*10+35 DocButton.addActionListener(this); Panel.add(DocButton); CheckAll = new JCheckBox("Uncheck all"); CheckAll.setForeground(Color.WHITE); CheckAll.setFont(new Font("SERRIF", Font.BOLD + Font.ITALIC, 12)); CheckAll.setOpaque(false); CheckAll.setSelected(true); CheckAll.addActionListener(this); setComponentsOnTheGrid(); Scroll = new JScrollPane( Panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); RPS.add(Scroll); RPS.setModal(true); RPS.setTitle(" Result : Particular Student "); RPS.setResizable(false); RPS.setSize(840, 565); RPS.setLocation( 250, 100 + (565 - RPS.getHeight()) / 2); // setiing RPS dialogbox in the middle of MenuFrame RPS.setVisible(true); }