Пример #1
1
 public int getTitleHeight(Component c) {
   int th = 21;
   int fh = getBorderInsets(c).top + getBorderInsets(c).bottom;
   if (c instanceof JDialog) {
     JDialog dialog = (JDialog) c;
     th = dialog.getSize().height - dialog.getContentPane().getSize().height - fh - 1;
     if (dialog.getJMenuBar() != null) {
       th -= dialog.getJMenuBar().getSize().height;
     }
   } else if (c instanceof JInternalFrame) {
     JInternalFrame frame = (JInternalFrame) c;
     th = frame.getSize().height - frame.getRootPane().getSize().height - fh - 1;
     if (frame.getJMenuBar() != null) {
       th -= frame.getJMenuBar().getSize().height;
     }
   } else if (c instanceof JRootPane) {
     JRootPane jp = (JRootPane) c;
     if (jp.getParent() instanceof JFrame) {
       JFrame frame = (JFrame) c.getParent();
       th = frame.getSize().height - frame.getContentPane().getSize().height - fh - 1;
       if (frame.getJMenuBar() != null) {
         th -= frame.getJMenuBar().getSize().height;
       }
     } else if (jp.getParent() instanceof JDialog) {
       JDialog dialog = (JDialog) c.getParent();
       th = dialog.getSize().height - dialog.getContentPane().getSize().height - fh - 1;
       if (dialog.getJMenuBar() != null) {
         th -= dialog.getJMenuBar().getSize().height;
       }
     }
   }
   return th;
 }
Пример #2
0
  public static void main(String[] args) {
    Toolkit theKit = aWindow.getToolkit(); // Get the window Toolkit
    Dimension wndSize = theKit.getScreenSize(); // Get the screen size

    // Set the position to screen center & size to half screen size
    aWindow.setBounds(
        wndSize.width / 4,
        wndSize.height / 4, // Position
        wndSize.width / 2,
        wndSize.height / 2); // Size
    aWindow.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    GridLayout grid = new GridLayout(5, 2, 30, 20); // Create a layout manager
    Container content = aWindow.getContentPane();
    content.setLayout(grid);

    EtchedBorder edge = new EtchedBorder(EtchedBorder.RAISED); // Button border

    // Now add ten Button compenents
    JButton button;
    for (int i = 1; i <= 10; i++) {
      content.add(button = new JButton("Press " + i));
      button.setBorder(edge);
    }

    aWindow.getContentPane().setBackground(new Color(238, 233, 233));
    aWindow.setVisible(true);
  }
Пример #3
0
  /**
   * Init JWhiteBoard interface
   *
   * @throws Exception
   */
  public void go() throws Exception {
    if (!noChannel && !useState) channel.connect(groupName);
    mainFrame = new JFrame();
    mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    drawPanel = new DrawPanel(useState);
    drawPanel.setBackground(backgroundColor);
    subPanel = new JPanel();
    mainFrame.getContentPane().add("Center", drawPanel);
    clearButton = new JButton("Clean");
    clearButton.setFont(defaultFont);
    clearButton.addActionListener(this);
    leaveButton = new JButton("Exit");
    leaveButton.setFont(defaultFont);
    leaveButton.addActionListener(this);
    subPanel.add("South", clearButton);
    subPanel.add("South", leaveButton);
    mainFrame.getContentPane().add("South", subPanel);
    mainFrame.setBackground(backgroundColor);
    clearButton.setForeground(Color.blue);
    leaveButton.setForeground(Color.blue);
    mainFrame.pack();
    mainFrame.setLocation(15, 25);
    mainFrame.setBounds(new Rectangle(250, 250));

    if (!noChannel && useState) {
      channel.connect(groupName, null, stateTimeout);
    }
    mainFrame.setVisible(true);
  }
Пример #4
0
  public TabSpawnable spawn() {
    JFrame f = new JFrame();
    f.getContentPane().setLayout(new BorderLayout());
    f.setTitle(_title);
    TabSpawnable newPanel = (TabSpawnable) clone();
    if (newPanel == null) return null; // failed to clone
    newPanel.setTitle(_title);
    if (newPanel instanceof TabToDoTarget) {
      TabToDoTarget me = (TabToDoTarget) this;
      TabToDoTarget it = (TabToDoTarget) newPanel;
      it.setTarget(me.getTarget());
    } else if (newPanel instanceof TabModelTarget) {
      TabModelTarget me = (TabModelTarget) this;
      TabModelTarget it = (TabModelTarget) newPanel;
      it.setTarget(me.getTarget());
    }
    f.getContentPane().add(newPanel, BorderLayout.CENTER);
    Rectangle bounds = getBounds();
    bounds.height += OVERLAPP * 2;
    f.setBounds(bounds);

    Point loc = new Point(0, 0);
    SwingUtilities.convertPointToScreen(loc, this);
    loc.y -= OVERLAPP;
    f.setLocation(loc);
    f.setVisible(true);

    if (_tear && (getParent() instanceof JTabbedPane)) ((JTabbedPane) getParent()).remove(this);

    return newPanel;
  }
Пример #5
0
  /** Initialize the contents of the frame. */
  private void initialize() {
    frame = new JFrame();
    frame.setBounds(100, 100, 450, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame
        .getContentPane()
        .setLayout(
            new FormLayout(
                new ColumnSpec[] {
                  FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
                  ColumnSpec.decode("default:grow"),
                  FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
                },
                new RowSpec[] {
                  FormFactory.RELATED_GAP_ROWSPEC,
                  RowSpec.decode("default:grow"),
                  FormFactory.LINE_GAP_ROWSPEC,
                  RowSpec.decode("default:grow"),
                  FormFactory.LINE_GAP_ROWSPEC,
                }));

    JPanel panel = new JPanel();
    frame.getContentPane().add(panel, "2, 2, fill, fill");

    openDialog = new FileDialog(this, "Open File", FileDialog.LOAD);

    JButton btnCharger = new JButton("Charger une partie");
    btnCharger.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            openDialog.setVisible(true);
            try {
              String dir = openDialog.getDirectory() + openDialog.getFile();
              Utilitaire.writeln(dir, textArea);
              jeu = new Kakuro(frame, dir);
              jeu.setVisible(true);
            } catch (NullPointerException point) {

            }
          }
        });
    panel.add(btnCharger);

    JButton btnNvlPartie = new JButton("Nouvelle Partie");
    panel.add(btnNvlPartie);
    btnNvlPartie.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            Random list = new Random();
            int seed = list.nextInt();
            new Utilitaire(Utilitaire.x, Utilitaire.y, seed);
            jeu = new Kakuro(frame);
            jeu.setVisible(true);
          }
        });

    textArea = new JTextArea();
    JScrollPane scrollPane = new JScrollPane(textArea);
    frame.getContentPane().add(scrollPane, "2, 4, fill, fill");
  }
  /**
   * Tests out the panel from the command line.
   *
   * @param args ignored.
   */
  public static void main(String[] args) {

    try {
      final JFrame jf = new JFrame("Generator Property Iterator");
      jf.getContentPane().setLayout(new BorderLayout());
      GeneratorPropertyIteratorPanel gp = new GeneratorPropertyIteratorPanel();
      jf.getContentPane().add(gp, BorderLayout.CENTER);
      jf.addWindowListener(
          new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              jf.dispose();
              System.exit(0);
            }
          });
      jf.pack();
      jf.setVisible(true);
      System.err.println("Short nap");
      Thread.currentThread().sleep(3000);
      System.err.println("Done");
      gp.setExperiment(new Experiment());
    } catch (Exception ex) {
      ex.printStackTrace();
      System.err.println(ex.getMessage());
    }
  }
 public static void main(String[] a) {
   JFrame f = new JFrame();
   f.getContentPane().setLayout(new GridLayout(0, 2));
   f.getContentPane().add(new JButtonLinkA("www.java2s.com"));
   f.getContentPane().add(new JButtonLinkA("www.java2s.com/ExampleCode/CatalogExampleCode.htm"));
   f.setSize(600, 200);
   f.setVisible(true);
 }
  public static void main(String[] args) {

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JBubblePanel bubblePanel = new JBubblePanel();
    JTextPane textPane = new JTextPane();
    bubblePanel.setLayout(new BorderLayout());
    bubblePanel.add(textPane, BorderLayout.CENTER);

    Font normalFont = new Font("Arial", Font.PLAIN, 12);
    Font boldFont = new Font("Arial", Font.BOLD, 12);

    SimpleAttributeSet normal = new SimpleAttributeSet();
    SimpleAttributeSet bold = new SimpleAttributeSet();
    StyleConstants.setBold(bold, true);

    try {
      textPane
          .getDocument()
          .insertString(textPane.getDocument().getLength(), "Your connection to ", normal);
      textPane
          .getDocument()
          .insertString(textPane.getDocument().getLength(), "cvs.dev.java.net ", bold);
      textPane
          .getDocument()
          .insertString(
              textPane.getDocument().getLength(),
              "failed. Here are a few possible reasons.\n\n",
              normal);
      textPane
          .getDocument()
          .insertString(
              textPane.getDocument().getLength(),
              " Your computer is may not be connected to the network.\n"
                  + "* The CVS server name may be entered incorrectly.\n\n",
              normal);
      textPane
          .getDocument()
          .insertString(
              textPane.getDocument().getLength(),
              "If you still can not connect, please contact support at ",
              normal);
      textPane
          .getDocument()
          .insertString(textPane.getDocument().getLength(), "*****@*****.**", bold);
      textPane.getDocument().insertString(textPane.getDocument().getLength(), ".", normal);
    } catch (BadLocationException ex) {
      ex.printStackTrace();
    }

    frame.getContentPane().setLayout(new BorderLayout());
    frame.getContentPane().add(bubblePanel, BorderLayout.CENTER);

    frame.setBounds(200, 300, 400, 360);
    frame.setVisible(true);
  }
Пример #9
0
  /** Initialize the contents of the frame. */
  private void initialize() {
    frame = new JFrame();
    frame.setBounds(100, 100, 450, 300);
    frame.setVisible(true);
    frame.setResizable(false);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(null);

    JButton btnCustomer = new JButton("Customer");
    btnCustomer.setFont(new Font("Tahoma", Font.BOLD, 16));
    btnCustomer.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            JOptionPane.showMessageDialog(null, "Welcome to Coffee Kiosk ");
            // Coffee1 nw = new Coffee1();
            // nw.NewScreen();
            cust = cust + 1;
            Customer cs = new Customer();
            cs.CustomerScreen();
          }
        });
    btnCustomer.setBounds(83, 94, 117, 86);
    frame.getContentPane().add(btnCustomer);

    JButton btnAdmin = new JButton("Admin");
    btnAdmin.setFont(new Font("Tahoma", Font.BOLD, 16));
    btnAdmin.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(null, "Welcome Admin ");
            Login ls = new Login();
            ls.LoginScreen();
          }
        });

    btnAdmin.setBounds(229, 94, 117, 86);
    frame.getContentPane().add(btnAdmin);

    JButton btnExit = new JButton("EXIT");
    btnExit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            JOptionPane.showMessageDialog(null, "Thank You for using Coffee Kiosk");
            System.exit(0);
          }
        });
    btnExit.setBounds(168, 207, 89, 23);
    frame.getContentPane().add(btnExit);

    JLabel lblLeedsCoffeeKiosk = new JLabel("LEEDS COFFEE KIOSK");
    lblLeedsCoffeeKiosk.setHorizontalAlignment(SwingConstants.CENTER);
    lblLeedsCoffeeKiosk.setFont(new Font("Times New Roman", Font.BOLD | Font.ITALIC, 30));
    lblLeedsCoffeeKiosk.setForeground(new Color(148, 0, 211));
    lblLeedsCoffeeKiosk.setBounds(36, 11, 366, 72);
    frame.getContentPane().add(lblLeedsCoffeeKiosk);
  }
 private void createProgressBarsInFrame(
     JFrame frame, JProgressBar progressBar1, JProgressBar progressBar2) {
   progressBar1.setValue(progressBar1.getMaximum());
   frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.PAGE_AXIS));
   frame.getContentPane().add(progressBar1);
   JPanel panel = new JPanel();
   frame.getContentPane().add(panel);
   panel.add(progressBar2);
   frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
   frame.pack();
   frame.setVisible(true);
 }
  /** Enters full screen mode and changes the display mode. */
  public void setFullScreen(DisplayMode displayMode, JFrame window) {

    window.setUndecorated(true);
    window.setResizable(false);
    cmdemo bgd = new cmdemo();
    JList mission = new JList(string);
    mission.setVisibleRowCount(4);
    JScrollPane pane = new JScrollPane(mission);
    pane.setBounds(400, 400, 225, 70);
    window.getContentPane().add(pane);

    muButton.setBounds(764 - 120, 625 - 10, 225, 49);
    textField1.setBounds(630 - 120, 328 - 10, 225, 25);
    window.getContentPane().add(muButton);
    window.getContentPane().add(textField1);
    // window.add(bgd);
    muButton.setDebugGraphicsOptions(javax.swing.DebugGraphics.NONE_OPTION);
    muButton.setToolTipText("start");
    muButton.setBorder(null);
    muButton.setRolloverIcon(new javax.swing.ImageIcon("imgs/start1.jpg"));
    muButton.addActionListener(
        new java.awt.event.ActionListener() {

          public void actionPerformed(java.awt.event.ActionEvent evt) {
            startActionPerformed(evt);
          }
        });

    aButton.setBounds(284 - 120, 625 - 10, 225, 49);
    window.getContentPane().add(aButton);
    window.add(bgd);
    aButton.setDebugGraphicsOptions(javax.swing.DebugGraphics.NONE_OPTION);
    aButton.setToolTipText("back");
    aButton.setBorder(null);
    aButton.setRolloverIcon(new javax.swing.ImageIcon("imgs/back1.jpg"));

    aButton.addActionListener(
        new java.awt.event.ActionListener() {

          public void actionPerformed(java.awt.event.ActionEvent evt) {
            backActionPerformed(evt);
          }
        });

    device.setFullScreenWindow(window);
    if (displayMode != null && device.isDisplayChangeSupported()) {
      try {
        device.setDisplayMode(displayMode);
      } catch (IllegalArgumentException ex) {
        // ignore - illegal mode for this device
      }
    }
  }
Пример #12
0
  public PrintDemoGfx(boolean q) {
    quiet = q;
    final JFrame f = new JFrame("Printing Test Dummy Frame");

    // Construct the object we want to print. Contrived:
    // this object would already exist in a real program.
    final GfxDemoCanvas thing = new GfxDemoCanvas(400, 300);

    f.getContentPane().add(thing, BorderLayout.CENTER);

    JButton printButton = new JButton("Print");
    f.getContentPane().add(printButton, BorderLayout.SOUTH);

    printButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              PrinterJob pjob = PrinterJob.getPrinterJob();
              pjob.setJobName("DemoGfx - Graphics Demo Printout");
              pjob.setCopies(1);
              // Tell the print system how to print our pages.
              pjob.setPrintable(
                  new Printable() {
                    /** called from the printer system to print each page */
                    public int print(Graphics pg, PageFormat pf, int pageNum) {
                      if (pageNum > 0) // we only print one page
                      return Printable.NO_SUCH_PAGE; // ie., end of job

                      // Now (drum roll please), ask "thing" to paint itself
                      // on the printer, by calling its paint() method with
                      // a Printjob Graphics instead of a Window Graphics.
                      thing.paint(pg);

                      // Tell print system that the page is ready to print
                      return Printable.PAGE_EXISTS;
                    }
                  });

              if (!quiet && pjob.printDialog() == false) // choose printer
              return; // user cancelled

              pjob.print(); // Finally, do the printing.
            } catch (PrinterException pe) {
              JOptionPane.showMessageDialog(
                  f, "Printer error" + pe, "Printing error", JOptionPane.ERROR_MESSAGE);
            }
          }
        });

    f.pack();
    f.setVisible(true);
  }
 private void setLayout() {
   GroupLayout layout = new GroupLayout(dialog.getContentPane());
   dialog.getContentPane().setLayout(layout);
   dialog.setResizable(true);
   layout.setAutoCreateContainerGaps(true);
   layout.setHorizontalGroup(layout.createParallelGroup().addComponent(tabbedPane));
   layout.setVerticalGroup(layout.createParallelGroup().addComponent(tabbedPane));
   layout.setHonorsVisibility(tabbedPane, true);
   // TODO set color here
   dialog.getContentPane().setBackground(new Color(0x132638));
   dialog.validate();
   dialog.repaint();
 }
Пример #14
0
  // Test routine.
  public static void main(String[] args) {
    // Create a button with the label "Jackpot".
    JButton button = new RoundButton("Jackpot");
    button.setBackground(Color.green);

    // Create a frame in which to show the button.
    JFrame frame = new JFrame();
    frame.getContentPane().setBackground(Color.yellow);
    frame.getContentPane().add(button);
    frame.getContentPane().setLayout(new FlowLayout());
    frame.setSize(150, 150);
    frame.setVisible(true);
  }
  public AuthorClient() {

    frame = new JFrame("Kumar's Publishing Hosue");
    frame2 = new JFrame("Result");
    panel = new JPanel();
    panel1 = new JPanel();

    panel.setLayout(new GridLayout(8, 2));
    panel1.setLayout(new GridLayout(1, 1));

    frame.setVisible(true);
    frame.setSize(300, 250);
    frame.getContentPane().setLayout(new BorderLayout());

    labelProductID = new JLabel("Product ID");
    labelDescription = new JLabel("Description");
    labelQuantity = new JLabel("Quantity");
    labelRate = new JLabel("Rate");
    labelUnitOfMsr = new JLabel("Unit of Measurement");

    textProductID = new JTextField(5);
    textDescription = new JTextField(15);
    textQuantity = new JTextField(15);
    textRate = new JTextField(10);
    textUnitOfMsr = new JTextField(50);

    submit = new JButton("Submit");

    panel.add(labelProductID);
    panel.add(textProductID);
    panel.add(labelDescription);
    panel.add(textDescription);
    panel.add(labelQuantity);
    panel.add(textQuantity);
    panel.add(labelRate);
    panel.add(textRate);
    panel.add(labelUnitOfMsr);
    panel.add(textUnitOfMsr);

    panel1.add(submit);

    ButtonListener blisten = new ButtonListener();
    submit.addActionListener(blisten);

    frame2.getContentPane().add(new JPanel(), BorderLayout.WEST);
    frame2.getContentPane().add(new JPanel(), BorderLayout.EAST);

    frame.getContentPane().add(panel, BorderLayout.CENTER);
    frame.getContentPane().add(panel1, BorderLayout.SOUTH);
  }
Пример #16
0
  /** Create the entire GUI from scratch */
  private void createGUI() {

    clientFrame = new JFrame("LeetFTP");

    // Allow program to exit gracefully

    clientFrame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    createTabs();
    createMenu();

    // Top Options Bar
    connectButton = new JButton("Connect");
    connectButton.addMouseListener(mouseHandler);

    optionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));

    optionPanel.add(connectButton);
    optionPanel.add(new JLabel("Name Server Hostname"));
    optionPanel.add(serverTextField);
    optionPanel.add(new JLabel("Port #"));
    optionPanel.add(portTextField);
    optionPanel.add(new JLabel("UserName"));
    optionPanel.add(nameTextField);

    // Bottom Transfer Table

    transferTable = new JTable();
    transferPanel = new JPanel(new BorderLayout());
    transferPanel.add(new JLabel("Current Transfers:"), BorderLayout.NORTH);
    transferPanel.add(transferTable);

    // Make the tab pane the GUI pane
    clientFrame.getContentPane().setLayout(new BorderLayout());
    clientFrame.getContentPane().add(mainPanel);
    clientFrame.getContentPane().add(optionPanel, BorderLayout.NORTH);
    clientFrame.getContentPane().add(transferPanel, BorderLayout.SOUTH);

    // Set Client Window Properties
    clientFrame.setSize(800, 600);
    // clientFrame.setResizable(false);
    clientFrame.setLocationRelativeTo(null);
    clientFrame.setVisible(true);
  }
Пример #17
0
  public static void main(String[] args) {
    JFrame frame = new JFrame("Demo of Additional Borders");
    frame.setIconImage(JideIconsFactory.getImageIcon(JideIconsFactory.JIDE32).getImage());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(new BorderLayout());

    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    panel.setLayout(new JideBoxLayout(panel, JideBoxLayout.Y_AXIS, 10));

    JTextArea textField = new JTextArea();
    JPanel border = new JPanel(new BorderLayout());
    border.setPreferredSize(new Dimension(100, 100));
    border.add(new JScrollPane(textField), BorderLayout.CENTER);
    border.setBorder(
        new JideTitledBorder(
            new PartialEtchedBorder(PartialEtchedBorder.LOWERED, PartialSide.NORTH),
            "PartialEtchedBorder"));

    JTextArea textField2 = new JTextArea();
    JPanel border2 = new JPanel(new BorderLayout());
    border2.setPreferredSize(new Dimension(100, 100));
    border2.add(new JScrollPane(textField2), BorderLayout.CENTER);
    border2.setBorder(
        new JideTitledBorder(
            new PartialLineBorder(Color.darkGray, 1, PartialSide.NORTH), "PartialLineBorder"));

    JTextArea textField3 = new JTextArea();
    JPanel border3 = new JPanel(new BorderLayout());
    border3.setPreferredSize(new Dimension(100, 100));
    border3.add(new JScrollPane(textField3), BorderLayout.CENTER);
    border3.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder(
                new PartialLineBorder(Color.gray, 1, true), "Rounded Corners Border"),
            BorderFactory.createEmptyBorder(0, 6, 4, 6)));

    panel.add(border, JideBoxLayout.FLEXIBLE);
    panel.add(Box.createVerticalStrut(12));
    panel.add(border2, JideBoxLayout.FLEXIBLE);
    panel.add(Box.createVerticalStrut(12));
    panel.add(border3, JideBoxLayout.FLEXIBLE);
    panel.add(Box.createGlue(), JideBoxLayout.VARY);

    panel.setPreferredSize(new Dimension(500, 400));
    frame.getContentPane().add(panel, BorderLayout.CENTER);
    frame.pack();
    frame.setVisible(true);
  }
  /** Simple test program. */
  public static void main(String[] args) {
    final JFrame frame = new JFrame("Testing AddPersonDialog");
    JButton button = new JButton("Click me");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            FamilyTree tree = new FamilyTree();
            AddPersonDialog dialog = new AddPersonDialog(frame, tree);
            dialog.pack();
            dialog.setLocationRelativeTo(frame);
            dialog.setVisible(true);

            Person newPerson = dialog.getPerson();
            if (newPerson != null) {
              tree.addPerson(newPerson);
              PrettyPrinter pretty = new PrettyPrinter(new PrintWriter(System.out, true));
              pretty.dump(tree);
            }
          }
        });
    frame.getContentPane().add(button);

    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(1);
          }
        });
    frame.pack();
    frame.setVisible(true);
  }
  public void launchTrajectoryRenderer() {

    Visualizer tv = this.getTrajectoryRenderLayerBase();
    List<EpisodeAnalysis> trajectories =
        EpisodeAnalysis.parseFilesIntoEAList(this.expertDir, this.domain, this.sp);
    TrajectoryRenderer tr =
        new TrajectoryRenderer(
            trajectories,
            GridWorldDomain.CLASSAGENT,
            GridWorldDomain.ATTX,
            GridWorldDomain.ATTY,
            new double[] {0, 30, .5},
            new double[] {0, 30, .5},
            3.f,
            10.f);
    tv.addRenderLayer(tr);

    tv.updateState(trajectories.get(0).getState(0));

    JFrame frame = new JFrame();
    frame.setPreferredSize(new Dimension(800, 800));
    frame.getContentPane().add(tv);
    frame.pack();
    frame.setVisible(true);
  }
Пример #20
0
  /** *********************************************************************** */
  private static void createAndShowGUI() {
    JFrame.setDefaultLookAndFeelDecorated(true); // give JFrame nice decorations
    JFrame frame = new JFrame("Java GUI"); // create the JFrame
    frame.setDefaultCloseOperation(
        JFrame.EXIT_ON_CLOSE); // set up the JFrame to end the program when it closes
    Container c = frame.getContentPane();
    c.setLayout(new BorderLayout());

    ColorBars drawingPanel = new ColorBars(); // set up the panel to draw in
    drawingPanel.setBackground(Color.BLACK); // the the background to black

    drawingPanel.btnDraw = new JButton("Click me"); // instantiate a swing button
    drawingPanel.btnDraw.addActionListener(drawingPanel); // register the panel with the button
    drawingPanel.btnClear = new JButton("Clear Screen");
    drawingPanel.btnClear.addActionListener(drawingPanel);

    Panel buttonPanel = new Panel(); // instantiate the panel for buttons
    buttonPanel.add(drawingPanel.btnDraw); // add the swing button the the button panel
    buttonPanel.add(drawingPanel.btnClear);

    c.add(
        drawingPanel,
        BorderLayout.CENTER); // add the drawing panel to the frame (take up the entire frame)
    c.add(buttonPanel, BorderLayout.SOUTH); // add the button panel to the bottom of the frame

    frame.setExtendedState(JFrame.MAXIMIZED_BOTH); // set the window to maximized
    frame.setSize(600, 400); // set the frame size (in case user un-maximizes
    frame.setVisible(true); // display the frame
  }
  private void registerDisposeListeners() {
    dialog.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            disposeFrame();
          }
        });
    // handle window closing commands for ctrl/cmd-W or hitting ESC.
    Toolkit.registerWindowCloseKeys(
        dialog.getRootPane(),
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            disposeFrame();
          }
        });

    dialog
        .getContentPane()
        .addKeyListener(
            new KeyAdapter() {
              public void keyPressed(KeyEvent e) {
                // System.out.println(e);
                KeyStroke wc = Toolkit.WINDOW_CLOSE_KEYSTROKE;
                if ((e.getKeyCode() == KeyEvent.VK_ESCAPE)
                    || (KeyStroke.getKeyStrokeForEvent(e).equals(wc))) {
                  disposeFrame();
                }
              }
            });
  }
  public void show() {
    FloorcJson floorcJson = null;
    try {
      floorcJson = Settings.get();
    } catch (Throwable ignored) {
    }

    HashMap<String, String> auth =
        floorcJson != null ? floorcJson.auth.get(Constants.defaultHost) : null;
    String username = "******";
    if (auth != null) {
      username = auth.get("username");
    }
    usernameInput.setText(username);
    frame = new JFrame();
    frame.getContentPane().add(contentContainer);
    frame.setMinimumSize(new Dimension(650, 500));
    frame.setResizable(false);
    frame.setLocationRelativeTo(null);
    frame.pack();
    contentContainer.setBorder(new EmptyBorder(5, 5, 5, 5));
    frame.setVisible(true);
    String contents =
        "<html><body><p>When you submit an "
            + "issue we will be notified right away. If we have contact information for you<br/> we will respond. You can also "
            + "contact us via [email protected], on IRC in #floobits<br/> "
            + "on Freenode, or via @floobits Twitter. If you run into "
            + "a bug it may help us if you send us your <br/>log. You can find it by going to Help -&gt; Find "
            + "log....     </p></body></html>";

    instructionsLabel.setText(contents);
    instructionsLabel.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
  }
Пример #23
0
  /**
   * This method starts the GUI.
   *
   * @throws CoapException Thrown, if the connection to obix via CoAP fails.
   */
  public void runGui() throws CoapException {
    this.lobby = obixChannel.getLobby(obixChannel.getLobbyUri());
    // Create and set up the window.
    mainFrame =
        new JFrame("ObixConnector at " + obixChannel.getBaseUri() + ": " + obixChannel.getPort());
    mainFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    mainFrame.setUndecorated(false);
    mainFrame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            close();
          }
        });

    Container contentPane = mainFrame.getContentPane();

    // Create and set up the content pane.
    this.addComponentToPane(contentPane);

    // Display the window.
    mainFrame.pack();
    executor.execute(updateThread);
    connector.addRunAndStopAble(updateThread);
    mainFrame.setVisible(true);
  }
  private void initComponents() {
    jfxPanel = new JFXPanel();

    createScene();

    ActionListener al =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            loadURL(txtURL.getText());
          }
        };

    btnGo.addActionListener(al);
    txtURL.addActionListener(al);

    progressBar.setPreferredSize(new Dimension(150, 18));
    progressBar.setStringPainted(true);

    JPanel topBar = new JPanel(new BorderLayout(5, 0));
    topBar.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
    topBar.add(txtURL, BorderLayout.CENTER);
    topBar.add(btnGo, BorderLayout.EAST);

    JPanel statusBar = new JPanel(new BorderLayout(5, 0));
    statusBar.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
    statusBar.add(lblStatus, BorderLayout.CENTER);
    statusBar.add(progressBar, BorderLayout.EAST);

    panel.add(topBar, BorderLayout.NORTH);
    panel.add(jfxPanel, BorderLayout.CENTER);
    panel.add(statusBar, BorderLayout.SOUTH);

    frame.getContentPane().add(panel);
  }
  public void testEmptyHeader() {
    fFrame = new JFrame("Test Window");

    // Create a panel to hold all other components
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BorderLayout());

    // Create a new table instance
    MyTableModel myModel = new MyTableModel();
    fTable = new JTable(myModel);

    // Add the table to a scrolling pane
    JScrollPane scrollPane = new JScrollPane(fTable);
    topPanel.add(scrollPane, BorderLayout.CENTER);

    fFrame.getContentPane().setLayout(new BorderLayout());
    fFrame.getContentPane().add(BorderLayout.CENTER, topPanel);

    fFrame.setSize(400, 450);
    fFrame.setLocation(20, 20);
    fFrame.setVisible(true);
    try {
      Thread.sleep(500);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    JTableHeader header = fTable.getTableHeader();
    assertTrue(
        "JTableHeader greater than 5 pixels tall with empty string first element.",
        header.getSize().height > 5);
    fFrame.setVisible(false);
    fFrame.dispose();
  }
Пример #26
0
  // ----------------Buttons
  // erstellen------------------------------------------------------------------------
  private void baueButton() {

    game = new JPanel(new GridLayout(YY, XX));
    buttons = new PuzzelHAButton[YY][XX];

    for (int y = 0; y < YY; y++)
      for (int x = 0; x < XX; x++) {
        buttons[y][x] =
            new PuzzelHAButton(
                new ImageIcon(
                    bilder
                        .get(bildNr)
                        .getSubimage(
                            x * (bilder.get(bildNr).getWidth() / XX),
                            y * (bilder.get(bildNr).getHeight() / YY),
                            bilder.get(bildNr).getWidth() / XX,
                            bilder.get(bildNr).getHeight() / YY)));
        buttons[y][x].setBorder(new LineBorder(Color.BLACK, 1));
        buttons[y][x].setActionCommand("" + y + x);
        buttons[y][x].setName("" + y + x);
        buttons[y][x].setPosY(y);
        buttons[y][x].setPosX(x);
        buttons[y][x].addActionListener(this);
        this.game.add(buttons[y][x]);
      }
    window.getContentPane().add(game);
  }
Пример #27
0
  public static void main(String[] args) {
    JFrame frame = new JFrame("Add");
    frame.setLocation(500, 400);
    //		frame.setPreferredSize(new Dimension(250, 100));
    Container contentPane = frame.getContentPane();

    FlowLayout layout = new FlowLayout();
    contentPane.setLayout(layout);
    JPanel panel = new JPanel();
    panel.add(new JTextField(6));
    panel.add(new JLabel("+"));
    panel.add(new JTextField(6));
    panel.add(new JLabel("="));
    panel.add(new JTextField(6));

    contentPane.add(panel, BorderLayout.CENTER);

    JPanel panel2 = new JPanel();
    panel2.add(new JButton("확인"));
    panel2.add(new JButton("취소"));
    contentPane.add(panel2, BorderLayout.SOUTH);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
  }
Пример #28
0
 public static void main(String[] args) {
   JFrame mainFrame = new JFrame("TestPopupWindow");
   mainFrame.getContentPane().add(new TestPopupWindow());
   mainFrame.pack();
   mainFrame.setLocationRelativeTo(null);
   mainFrame.setVisible(true);
 }
  public static void main(String[] args) {
    final JPopupMenu menu = new JPopupMenu();
    menu.setLayout(new GridLayout(0, 3, 5, 5));

    final MenuedButton button = new MenuedButton("Icons", menu);

    for (int i = 0; i < 9; i++) {
      // replace "print.gif" with your own image
      final JLabel label = new JLabel("" + i); // new ImageIcon("resources/images/print.gif") );
      label.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              button.getMainButton().setIcon(label.getIcon());
              menu.setVisible(false);
            }
          });
      menu.add(label);
    }

    JFrame frame = new JFrame("Button Test");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(new JLabel("Click Arrow Button To Show Popup"), BorderLayout.NORTH);
    frame.getContentPane().add(button, BorderLayout.CENTER);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
 public void testContextIsJFrameWhenJFrameIsShown() {
   JFrame frame = new JFrame();
   JButton comp = new JButton();
   frame.getContentPane().add(comp);
   windowContext.setActiveWindow(comp);
   assertSame(frame, windowContext.activeWindow());
 }