Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created with Simple GUI Extension for BlueJ
- * http://home.pf.jcu.cz/~gbluej/
- */
- import javax.swing.UIManager.LookAndFeelInfo;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.KeyAdapter;
- import java.awt.event.KeyEvent;
- import java.awt.event.MouseAdapter;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseWheelEvent;
- import java.awt.event.MouseWheelListener;
- import javax.swing.border.Border;
- import javax.swing.*;
- import java.util.Vector;
- import java.util.List;
- import java.util.ArrayList;
- import java.util.Arrays;
- public class DialogSkeleton extends JDialog
- {
- private JButton btnCancel;
- private JButton btnOK;
- private JCheckBox checkbox1;
- private JLabel lblTitle;
- private JList<String> listBox;
- private JPanel panel1;
- /** Create this dialog from a list of Strings */
- public DialogSkeleton(Vector<String> lines)
- {
- this.setModal(true);
- this.setTitle("DialogSkeleton");
- this.setSize(500,400);
- //pane with null layout
- JPanel contentPane = new JPanel(null);
- contentPane.setPreferredSize(new Dimension(500,400));
- contentPane.setBackground(new Color(192,192,192));
- btnCancel = new JButton();
- btnCancel.setBounds(391,350,90,35);
- btnCancel.setBackground(new Color(214,217,223));
- btnCancel.setForeground(new Color(0,0,0));
- btnCancel.setEnabled(true);
- btnCancel.setFont(new Font("DejaVu Sans",0,12));
- btnCancel.setText("Cancel");
- btnCancel.setVisible(true);
- btnOK = new JButton();
- btnOK.setBounds(288,350,90,35);
- btnOK.setBackground(new Color(214,217,223));
- btnOK.setForeground(new Color(0,0,0));
- btnOK.setEnabled(true);
- btnOK.setFont(new Font("DejaVu Sans",0,12));
- btnOK.setText("OK");
- btnOK.setVisible(true);
- checkbox1 = new JCheckBox();
- checkbox1.setBounds(16,350,130,35);
- checkbox1.setBackground(new Color(214,217,223));
- checkbox1.setForeground(new Color(0,0,0));
- checkbox1.setEnabled(true);
- checkbox1.setFont(new Font("DejaVu Sans",0,12));
- checkbox1.setText("Retain hyphens");
- checkbox1.setVisible(true);
- lblTitle = new JLabel();
- lblTitle.setBounds(7,5,279,16);
- lblTitle.setBackground(new Color(214,217,223));
- lblTitle.setForeground(new Color(0,0,0));
- lblTitle.setEnabled(true);
- lblTitle.setFont(new Font("DejaVu Sans",0,12));
- lblTitle.setText("Select lines that should NOT be joined.");
- lblTitle.setVisible(true);
- listBox = new JList<String>(lines);
- listBox.setBounds(5,29,477,311);
- listBox.setBackground(new Color(255,255,255));
- listBox.setForeground(new Color(0,0,0));
- listBox.setEnabled(true);
- listBox.setFont(new Font("Courier",0,12));
- listBox.setVisible(true);
- JScrollPane scrollPane = new JScrollPane(listBox);
- scrollPane.setBounds(5,29,477,311);
- panel1 = new JPanel(null);
- panel1.setBorder(BorderFactory.createEtchedBorder(1));
- panel1.setBounds(4,5,491,390);
- panel1.setBackground(new Color(214,217,223));
- panel1.setForeground(new Color(0,0,0));
- panel1.setEnabled(true);
- panel1.setFont(new Font("DejaVu Sans",0,12));
- panel1.setVisible(true);
- //adding components to contentPane panel
- panel1.add(btnCancel);
- panel1.add(btnOK);
- panel1.add(checkbox1);
- panel1.add(lblTitle);
- panel1.add(scrollPane, BorderLayout.CENTER);
- contentPane.add(panel1);
- //adding panel to JFrame and seting of window position and close operation
- this.add(contentPane);
- //this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- this.setLocationRelativeTo(null);
- this.pack();
- }
- /** Accessor to checkbox state */
- public boolean retainHyphens()
- {
- return checkbox1.isSelected();
- }
- /** A local main for testing */
- public static void main(String[] args)
- {
- javax.swing.SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- String[] numbers = { "zero", "one", "two", "three", "four"};
- // Create the dialog
- DialogSkeleton jdlg = new DialogSkeleton(new Vector<String>(Arrays.asList(numbers)));
- // Make it visible and wait
- jdlg.setVisible(true);
- // After the dialog closes, do the following, just as a demo.
- System.out.print("Retain hyphens is: ");
- if (jdlg.retainHyphens())
- {
- System.out.println("on.");
- }
- else
- {
- System.out.println("off.");
- }
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement