public MainPanel() {
   super(new BorderLayout());
   BufferedImage bi = null;
   try {
     bi = ImageIO.read(getClass().getResource("test.jpg"));
   } catch (IOException ioe) {
     ioe.printStackTrace();
   }
   bufferedImage = bi;
   List<AbstractAction> list =
       Arrays.asList(
           new AbstractAction("NONE") {
             @Override
             public void actionPerformed(ActionEvent e) {
               mode = Flip.NONE;
               repaint();
             }
           },
           new AbstractAction("VERTICAL") {
             @Override
             public void actionPerformed(ActionEvent e) {
               mode = Flip.VERTICAL;
               repaint();
             }
           },
           new AbstractAction("HORIZONTAL") {
             @Override
             public void actionPerformed(ActionEvent e) {
               mode = Flip.HORIZONTAL;
               repaint();
             }
           });
   Box box = Box.createHorizontalBox();
   box.add(Box.createHorizontalGlue());
   box.add(new JLabel("Flip: "));
   for (AbstractAction a : list) {
     JRadioButton rb = new JRadioButton(a);
     if (bg.getButtonCount() == 0) {
       rb.setSelected(true);
     }
     box.add(rb);
     bg.add(rb);
     box.add(Box.createHorizontalStrut(5));
   }
   add(p);
   add(box, BorderLayout.SOUTH);
   setOpaque(false);
   setPreferredSize(new Dimension(320, 240));
 }
Beispiel #2
0
  /**
   * Creates an instance of <tt>ShowPreviewDialog</tt>
   *
   * @param chatPanel The <tt>ChatConversationPanel</tt> that is associated with this dialog.
   */
  ShowPreviewDialog(final ChatConversationPanel chatPanel) {
    this.chatPanel = chatPanel;

    this.setTitle(
        GuiActivator.getResources().getI18NString("service.gui.SHOW_PREVIEW_DIALOG_TITLE"));
    okButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.OK"));
    cancelButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.CANCEL"));

    JPanel mainPanel = new TransparentPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    // mainPanel.setPreferredSize(new Dimension(200, 150));
    this.getContentPane().add(mainPanel);

    JTextPane descriptionMsg = new JTextPane();
    descriptionMsg.setEditable(false);
    descriptionMsg.setOpaque(false);
    descriptionMsg.setText(
        GuiActivator.getResources().getI18NString("service.gui.SHOW_PREVIEW_WARNING_DESCRIPTION"));

    Icon warningIcon = null;
    try {
      warningIcon =
          new ImageIcon(
              ImageIO.read(
                  GuiActivator.getResources().getImageURL("service.gui.icons.WARNING_ICON")));
    } catch (IOException e) {
      logger.debug("failed to load the warning icon");
    }
    JLabel warningSign = new JLabel(warningIcon);

    JPanel warningPanel = new TransparentPanel();
    warningPanel.setLayout(new BoxLayout(warningPanel, BoxLayout.X_AXIS));
    warningPanel.add(warningSign);
    warningPanel.add(Box.createHorizontalStrut(10));
    warningPanel.add(descriptionMsg);

    enableReplacement =
        new JCheckBox(
            GuiActivator.getResources()
                .getI18NString("plugin.chatconfig.replacement.ENABLE_REPLACEMENT_STATUS"));
    enableReplacement.setOpaque(false);
    enableReplacement.setSelected(cfg.getBoolean(ReplacementProperty.REPLACEMENT_ENABLE, true));
    enableReplacementProposal =
        new JCheckBox(
            GuiActivator.getResources()
                .getI18NString("plugin.chatconfig.replacement.ENABLE_REPLACEMENT_PROPOSAL"));
    enableReplacementProposal.setOpaque(false);

    JPanel checkBoxPanel = new TransparentPanel();
    checkBoxPanel.setLayout(new BoxLayout(checkBoxPanel, BoxLayout.Y_AXIS));
    checkBoxPanel.add(enableReplacement);
    checkBoxPanel.add(enableReplacementProposal);

    JPanel buttonsPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER));
    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);

    mainPanel.add(warningPanel);
    mainPanel.add(Box.createVerticalStrut(10));
    mainPanel.add(checkBoxPanel);
    mainPanel.add(buttonsPanel);

    okButton.addActionListener(this);
    cancelButton.addActionListener(this);

    this.setPreferredSize(new Dimension(390, 230));
  }
Beispiel #3
0
  /**
   * 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);
  }