private void initGUI() {

    JPanel pCommand = new JPanel();

    pResult = new JPanel();
    nsSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pCommand, pResult);

    pCommand.setLayout(new BorderLayout());
    pResult.setLayout(new BorderLayout());

    Font fFont = new Font("Dialog", Font.PLAIN, 12);

    txtCommand = new JTextArea(5, 40);

    txtCommand.setMargin(new Insets(5, 5, 5, 5));
    txtCommand.addKeyListener(this);

    txtCommandScroll = new JScrollPane(txtCommand);
    txtResult = new JTextArea(20, 40);

    txtResult.setMargin(new Insets(5, 5, 5, 5));

    txtResultScroll = new JScrollPane(txtResult);

    txtCommand.setFont(fFont);
    txtResult.setFont(new Font("Courier", Font.PLAIN, 12));
    /*
    // button replaced by toolbar
            butExecute = new JButton("Execute");

            butExecute.addActionListener(this);
            pCommand.add(butExecute, BorderLayout.EAST);
    */
    pCommand.add(txtCommandScroll, BorderLayout.CENTER);

    gResult = new GridSwing();
    gResultTable = new JTable(gResult);
    gScrollPane = new JScrollPane(gResultTable);

    // getContentPane().setLayout(new BorderLayout());
    pResult.add(gScrollPane, BorderLayout.CENTER);

    // Set up the tree
    rootNode = new DefaultMutableTreeNode("Connection");
    treeModel = new DefaultTreeModel(rootNode);
    tTree = new JTree(treeModel);
    tScrollPane = new JScrollPane(tTree);

    tScrollPane.setPreferredSize(new Dimension(120, 400));
    tScrollPane.setMinimumSize(new Dimension(70, 100));
    txtCommandScroll.setPreferredSize(new Dimension(360, 100));
    txtCommandScroll.setMinimumSize(new Dimension(180, 100));
    gScrollPane.setPreferredSize(new Dimension(460, 300));

    ewSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tScrollPane, nsSplitPane);

    fMain.getContentPane().add(ewSplitPane, BorderLayout.CENTER);
    doLayout();
    fMain.pack();
  }
Example #2
0
  /**
   * Set the value of content
   *
   * @param newVar the new value of content
   */
  private void setContent(final counts a, final connections cnc_a) {
    // Creates a new container
    content = frame.getContentPane();
    // sets the layout
    content.setLayout(new BorderLayout());

    this.setTaskbar(); // sets the taskbar
    // adding the taskbar to the bottom-part
    content.add(taskbar, BorderLayout.SOUTH);

    this.setDraw_pad(a, cnc_a, this.getTaskbar()); // sets the drawPad
    JScrollPane Padscroller = new JScrollPane();
    Padscroller.setWheelScrollingEnabled(true);
    Padscroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    Padscroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    Padscroller.setPreferredSize(new Dimension(200, 100));
    // Padscroller.setMinimumSize(new Dimension(200, 100));
    // Padscroller.setMaximumSize(new Dimension(200, 100));
    Padscroller.setViewportView(drawPad);
    content.add(Padscroller, BorderLayout.CENTER);

    this.setPanel(a, cnc_a); // sets the panel
    JScrollPane scroller = new JScrollPane(panel);
    scroller.setWheelScrollingEnabled(true);
    scroller.setPreferredSize(new Dimension(125, 80));
    scroller.setMinimumSize(new Dimension(125, 80));
    scroller.setMaximumSize(new Dimension(125, 80));
    // sets the scroller to the west portion
    content.add(scroller, BorderLayout.WEST);
    // content.add(panel, BorderLayout.WEST);
  }
Example #3
0
  public static Component CreateRouteTable(Object[][] data, Dimension totalSize) {
    String[] columnNames = {
      "Route #",
      "Carrier",
      "Dep. Airport",
      "Dep. Time",
      "Arr. Airport",
      "Arr. Time",
      "Price",
      "status"
    };

    // disable cell editing
    JTable routeTable =
        new JTable(data, columnNames) {
          public boolean isCellEditable(int rowIndex, int vColIndex) {
            return false;
          };
        };
    routeTable.getTableHeader().setReorderingAllowed(false);
    routeTable.getTableHeader().setResizingAllowed(false);
    JScrollPane routeTableScroll =
        new JScrollPane(routeTable); // create the routes table in a scrollPane

    routeTableScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    routePanelWidth = (totalSize.width * 3 / 4) * 48 / 100;
    routePanelHeight = totalSize.height * 45 / 100;
    routeTableScroll.setPreferredSize(new Dimension(routePanelWidth, routePanelHeight));
    return routeTableScroll;
  }
Example #4
0
  public static void updateResultsTable(Object[][] data) {
    // remove old route table
    resultsPanel.removeAll();

    // create new route table
    String[] columnNames = {
      "Route #", "Carrier", "Dep. Airport", "Dep. Time", "Arr. Airport", "Arr. Time", "Price"
    };
    JScrollPane routeTable =
        new JScrollPane(
            new JTable(data, columnNames) {
              public boolean isCellEditable(int rowIndex, int vColIndex) {
                return false;
              };
            });
    // create the routes table in a scrollPane
    routeTable.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    routeTable.setPreferredSize(new Dimension(resultsPanelWidth, resultsPanelHeight));
    resultsPanel.add(routeTable); // add the table to the JPanel
    resultsPanel.setBorder(BorderFactory.createTitledBorder("Search Results"));

    // display new route table
    resultsPanel.revalidate();
    resultsPanel.repaint();
  }
  public ErrorListDialog(
      Frame frame, String title, String caption, Vector messages, boolean showPluginMgrButton) {
    super(frame, title, true);

    JPanel content = new JPanel(new BorderLayout(12, 12));
    content.setBorder(new EmptyBorder(12, 12, 12, 12));
    setContentPane(content);

    Box iconBox = new Box(BoxLayout.Y_AXIS);
    iconBox.add(new JLabel(UIManager.getIcon("OptionPane.errorIcon")));
    iconBox.add(Box.createGlue());
    content.add(BorderLayout.WEST, iconBox);

    JPanel centerPanel = new JPanel(new BorderLayout());

    JLabel label = new JLabel(caption);
    label.setBorder(new EmptyBorder(0, 0, 6, 0));
    centerPanel.add(BorderLayout.NORTH, label);

    JList errors = new JList(messages);
    errors.setCellRenderer(new ErrorListCellRenderer());
    errors.setVisibleRowCount(Math.min(messages.size(), 4));

    JScrollPane scrollPane =
        new JScrollPane(
            errors, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    Dimension size = scrollPane.getPreferredSize();
    size.width = Math.min(size.width, 400);
    scrollPane.setPreferredSize(size);

    centerPanel.add(BorderLayout.CENTER, scrollPane);

    content.add(BorderLayout.CENTER, centerPanel);

    Box buttons = new Box(BoxLayout.X_AXIS);
    buttons.add(Box.createGlue());

    ok = new JButton(jEdit.getProperty("common.ok"));
    ok.addActionListener(new ActionHandler());

    if (showPluginMgrButton) {
      pluginMgr = new JButton(jEdit.getProperty("error-list.plugin-manager"));
      pluginMgr.addActionListener(new ActionHandler());
      buttons.add(pluginMgr);
      buttons.add(Box.createHorizontalStrut(6));
    }

    buttons.add(ok);

    buttons.add(Box.createGlue());
    content.add(BorderLayout.SOUTH, buttons);

    getRootPane().setDefaultButton(ok);

    pack();
    setLocationRelativeTo(frame);
    show();
  }
  private void initComponents() {

    final SimpleDateFormat dateFrmt = new SimpleDateFormat(DEFAULT_DATE_FORMAT);
    panel = new JPanel();
    panel.setLayout(new BorderLayout());
    JPanel north = new JPanel();
    north.setLayout(new BoxLayout(north, BoxLayout.X_AXIS));
    JLabel dateLbl = new JLabel("検査日:");
    north.add(dateLbl);
    dateFld = new JTextField(10);
    dateFld.setMaximumSize(dateFld.getPreferredSize());
    dateFld.setEditable(false);
    dateFld.setText(dateFrmt.format(new Date()));
    north.add(dateFld);
    north.add(Box.createHorizontalGlue());
    editCheck = new JCheckBox("項目編集");
    north.add(editCheck);
    panel.add(north, BorderLayout.NORTH);

    JPanel south = new JPanel();
    south.setLayout(new FlowLayout());
    deleteBtn = new JButton("削除", deleteIcon);
    deleteBtn.setEnabled(false);
    south.add(deleteBtn);
    closeBtn = new JButton("閉じる", closeIcon);
    south.add(closeBtn);
    saveBtn = new JButton("保存", saveIcon);
    south.add(saveBtn);
    panel.add(south, BorderLayout.SOUTH);

    setTable = new JTable();
    JScrollPane scroll = new JScrollPane(setTable);
    centerPanel = new JPanel();
    centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.X_AXIS));
    centerPanel.add(scroll);
    panel.add(centerPanel, BorderLayout.CENTER);

    templateTable = new JTable();
    templateTable.setToolTipText("DnDで左の施設内検査項目テーブルに追加してください。");
    rtScroll = new JScrollPane(templateTable);
    Dimension d = new Dimension(200, 200);
    rtScroll.setPreferredSize(d);
    d = new Dimension(200, Integer.MAX_VALUE);
    rtScroll.setMaximumSize(d);

    dialog = new JDialog();
    String title = ClientContext.getFrameTitle("院内検査項目追加");
    dialog.setTitle(title);
    dialog.setModal(true);
    dialog.setContentPane(panel);
    ClientContext.setDolphinIcon(dialog);

    dialog.pack();
    dialog.setLocationRelativeTo(chart.getFrame());
  }
Example #7
0
  public TestHTML() {
    int d = (Frame.getFrames().length == 0) ? JFrame.EXIT_ON_CLOSE : JFrame.DISPOSE_ON_CLOSE;

    JPanel pan = new JPanel();
    pan.setLayout(new BorderLayout(GAP, GAP - 4));
    pan.setBorder(new EmptyBorder(GAP, GAP, GAP, GAP));
    pan.setBackground(COL);
    pan.setFont(font);
    lab = new JLabel(MSG); // , SwingConstants.CENTER);
    lab.setName("title");
    lab.setFont(new Font("Serif", 3, 16));
    // lab.setForeground(Color.black);
    pan.add(lab, "North");

    text = new JTextArea("JTextArea\n");
    text.setName("area");
    text.setLineWrap(true);
    text.setFont(font);
    JScrollPane scr1 = new JScrollPane(text);
    scr1.setPreferredSize(new Dimension(300, 500));
    pan.add(scr1, "Center");

    html = new JEditorPane();
    html.setContentType("text/html");
    html.setEditable(false);
    html.addMouseListener(this);
    html.addMouseMotionListener(this);
    JScrollPane scr2 = new JScrollPane(html);
    scr2.setPreferredSize(new Dimension(350, 500));
    pan.add(scr2, "East");

    but = new JButton("Copy text from JTextArea to JEditorPane");
    but.addActionListener(this);
    pan.add(but, "South");

    frm = new JFrame(MSG);
    frm.setContentPane(pan);
    frm.setDefaultCloseOperation(d);
    frm.setLocation(100, 150);
    frm.pack();
    frm.setVisible(true);
  }
Example #8
0
 /**
  * Static Init
  *
  * @throws Exception
  */
 void jbInit() throws Exception {
   mainPanel.setLayout(mainLayout);
   mainLayout.setHgap(2);
   mainLayout.setVgap(2);
   infoPane.setBorder(BorderFactory.createLoweredBevelBorder());
   infoPane.setPreferredSize(new Dimension(500, 400));
   getContentPane().add(mainPanel);
   mainPanel.add(infoPane, BorderLayout.CENTER);
   mainPanel.add(confirmPanel, BorderLayout.SOUTH);
   infoPane.getViewport().add(info, null);
   confirmPanel.addActionListener(this);
 } //	jbInit
Example #9
0
  // Constructor.  Creates the GUI and sets up listeners for the buttons.
  public Interstate() {
    // Create the GUI components and lay them out.
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BorderLayout());
    JPanel selectionPanel = new JPanel();
    JButton sourceButton = new JButton("Source");
    destButton = new JButton("Destination");
    JButton distButton = new JButton("Use distance");
    JButton timeButton = new JButton("Use time");
    selectionPanel.add(sourceButton);
    selectionPanel.add(destButton);
    selectionPanel.add(distButton);
    selectionPanel.add(timeButton);
    selectionPanel.add(infoLabel);
    JPanel quitPanel = new JPanel();
    JButton quitButton = new JButton("Quit");
    quitPanel.add(quitButton);
    topPanel.add(selectionPanel, BorderLayout.WEST);
    topPanel.add(quitPanel, BorderLayout.EAST);
    setLayout(new BorderLayout());
    add(topPanel, BorderLayout.NORTH);

    // Make listeners for the buttons.
    sourceButton.addActionListener(new SourceButtonListener());
    destButton.addActionListener(new DestButtonListener());
    distButton.addActionListener(new DistButtonListener());
    timeButton.addActionListener(new TimeButtonListener());
    quitButton.addActionListener(new QuitButtonListener());

    // Get the image to use.
    ImageIcon interstatesMap = createImageIcon("us-interstates.jpg");

    // Make the representation of the roadmap.
    // We don't have to worry about null, because System.exit() will prevent it being an issue
    RoadMap roadmap = null;
    try {
      roadmap = new RoadMap("src/interstate-cities.csv", "src/interstate-links.csv");
    } catch (Exception e) {
      System.err.println(e.getMessage());
      System.exit(1);
    }

    // Set up the scroll pane.
    graphicalMap = new ScrollableMap(interstatesMap, 1, infoLabel, destButton, roadmap);
    JScrollPane pictureScrollPane = new JScrollPane(graphicalMap);
    pictureScrollPane.setPreferredSize(new Dimension(1700, 900));
    pictureScrollPane.setViewportBorder(BorderFactory.createLineBorder(Color.black));

    // Put it in this panel.
    add(pictureScrollPane);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
  }
Example #10
0
  public void addComponentsToPane() {

    testfield = new JTextField("", 33);
    testfield.addKeyListener(this);

    testtextarea = new TextArea(buffer, 15, 33, TextArea.SCROLLBARS_VERTICAL_ONLY);
    testtextarea.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(testtextarea);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setPreferredSize(new Dimension(600, 200));

    getContentPane().add(testfield, BorderLayout.PAGE_END);
    getContentPane().add(testtextarea, BorderLayout.CENTER);
  }
  boolean initControlCenter(String title) {

    this.setTitle(title);
    // set up content pane
    Container content = this.getContentPane();
    content.setLayout(new BorderLayout());
    panelAbout.setLayout(new BorderLayout());

    JTextArea textArea =
        new JTextArea(
            "PlayStation 2 Virtual File System release 1.0 \n\nSpecials thanks to our betatester\nPS2Linux Betatester: Mrbrown and Sarah\nPS2 betatester: Oobles, Caveman, Gamebytes, Ping^Spike, Josekenshin, Padawan, pakor, SandraThx and Rolando\n\nAdded little gui in java swing\nAdded feature to choose directory for media files\nAdded support for properties files\nCheck for updates at ps2dev.org\n\nRelease 1.2\n\nRewrite io with java NIO\nadded console mode support\n");
    textArea.setEditable(false);

    JScrollPane areaScrollPane = new JScrollPane(textArea);
    areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    areaScrollPane.setPreferredSize(new Dimension(250, 250));
    TitledBorder aboutBorder = BorderFactory.createTitledBorder("Change log and Greets");
    aboutBorder.setTitleColor(Color.blue);
    panelAbout.setBorder(aboutBorder);

    panelAbout.add(areaScrollPane);
    // set up tabbed pane
    content.add(jtpMain);

    jtpMain.addTab("Configure", panelChooser);
    jtpMain.addTab("About", panelAbout);
    //  set up display area
    // jtaDisplay.setEditable(false);
    // jtaDisplay.setLineWrap(true);
    // jtaDisplay.setMargin(new Insets(5, 5, 5, 5));
    // jtaDisplay.setFont(
    // new Font("Monospaced", Font.PLAIN, iDEFAULT_FontSize));
    // jspDisplay.setViewportView(jtaDisplay);
    // jspDisplay.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
    // panelConsole.add(jspDisplay, BorderLayout.CENTER);
    // panelConsole.add(jtfCommand, BorderLayout.SOUTH);
    // panelConsole.add(jtaDisplay, BorderLayout.CENTER);

    // listener: window closer
    this.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    this.vResize();
    return true;
  }
  protected JScrollPane createDirectoryList() {
    directoryList = new JList();
    align(directoryList);

    directoryList.setCellRenderer(new DirectoryCellRenderer());
    directoryList.setModel(new MotifDirectoryListModel());
    directoryList.addMouseListener(createDoubleClickListener(getFileChooser(), directoryList));
    directoryList.addListSelectionListener(createListSelectionListener(getFileChooser()));

    JScrollPane scrollpane = new JScrollPane(directoryList);
    scrollpane.setMaximumSize(MAX_SIZE);
    scrollpane.setPreferredSize(prefListSize);
    align(scrollpane);
    return scrollpane;
  }
Example #13
0
  View2(Model model) {
    this.model = model;

    temp = new JPanel();
    scroll = new JScrollPane();
    scroll.setPreferredSize(new Dimension(200, 405));
    list = new JList<String>();
    label1 = new JLabel("Entered:");
    // create UI
    // setBackground(Color.BLACK);

    temp.add(label1);
    temp.add(scroll);
    temp.setLayout(new BoxLayout(temp, BoxLayout.PAGE_AXIS));
    this.add(temp);
  }
  @Override
  protected JComponent createCenterPanel() {
    JPanel panel = new JPanel(new BorderLayout());

    // Toolbar

    DefaultActionGroup group = new DefaultActionGroup();

    fillToolbarActions(group);

    group.addSeparator();

    ExpandAllAction expandAllAction = new ExpandAllAction();
    expandAllAction.registerCustomShortcutSet(
        new CustomShortcutSet(
            KeymapManager.getInstance()
                .getActiveKeymap()
                .getShortcuts(IdeActions.ACTION_EXPAND_ALL)),
        myTree);
    group.add(expandAllAction);

    CollapseAllAction collapseAllAction = new CollapseAllAction();
    collapseAllAction.registerCustomShortcutSet(
        new CustomShortcutSet(
            KeymapManager.getInstance()
                .getActiveKeymap()
                .getShortcuts(IdeActions.ACTION_COLLAPSE_ALL)),
        myTree);
    group.add(collapseAllAction);

    panel.add(
        ActionManager.getInstance()
            .createActionToolbar(ActionPlaces.UNKNOWN, group, true)
            .getComponent(),
        BorderLayout.NORTH);

    // Tree
    expandFirst();
    defaultExpandTree();
    installSpeedSearch();

    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree);
    scrollPane.setPreferredSize(new Dimension(350, 450));
    panel.add(scrollPane, BorderLayout.CENTER);

    return panel;
  }
Example #15
0
 private void init() {
   setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
   addWindowListener(
       new WindowAdapter() {
         @Override
         public void windowClosing(final WindowEvent e) {
           cleanExit();
         }
       });
   addWindowStateListener(
       new WindowStateListener() {
         public void windowStateChanged(final WindowEvent arg0) {
           switch (arg0.getID()) {
             case WindowEvent.WINDOW_ICONIFIED:
               lessCpu(true);
               break;
             case WindowEvent.WINDOW_DEICONIFIED:
               lessCpu(false);
               break;
           }
         }
       });
   setIconImage(Configuration.getImage(Configuration.Paths.Resources.ICON));
   JPopupMenu.setDefaultLightWeightPopupEnabled(false);
   WindowUtil.setFrame(this);
   panel = new BotPanel();
   menuBar = new BotMenuBar(this);
   toolBar = new BotToolBar(this, menuBar);
   panel.setFocusTraversalKeys(0, new HashSet<AWTKeyStroke>());
   new BotKeyboardShortcuts(KeyboardFocusManager.getCurrentKeyboardFocusManager(), this, this);
   menuBar.setBot(null);
   setJMenuBar(menuBar);
   textScroll =
       new JScrollPane(
           TextAreaLogHandler.TEXT_AREA,
           ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
           ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
   textScroll.setBorder(null);
   textScroll.setPreferredSize(new Dimension(PANEL_WIDTH, 120));
   textScroll.setVisible(true);
   JScrollPane scrollableBotPanel = new JScrollPane(panel);
   add(toolBar, BorderLayout.NORTH);
   add(scrollableBotPanel, BorderLayout.CENTER);
   add(textScroll, BorderLayout.SOUTH);
 }
Example #16
0
  /**
   * File Manager Frame
   *
   * @param frame parent frame
   */
  public FileManager(JFrame frame, FileFilter filter) {
    super("File Manager");

    FileTree ftree = new FileTree(new File(System.getProperty("user.dir")), frame, filter);
    JScrollPane jsp = new JScrollPane(ftree);
    JPanel pane = (JPanel) getContentPane();
    pane.setLayout(new BorderLayout());
    pane.add(jsp, BorderLayout.CENTER);
    setJMenuBar(makeMenuBar(pane, ftree));
    pane.add(getFileFileterComboBox(ftree), BorderLayout.SOUTH);

    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    jsp.setPreferredSize(new Dimension(210, (int) (screen.getHeight() / 2)));
    pack();

    int yloc = (int) ((screen.getHeight() - getHeight()) / 2);
    setLocation(0, yloc);
    setVisible(true);
  }
  protected JScrollPane createFilesList() {
    fileList = new JList();

    if (getFileChooser().isMultiSelectionEnabled()) {
      fileList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    } else {
      fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }

    fileList.setModel(new MotifFileListModel());
    fileList.setCellRenderer(new FileCellRenderer());
    fileList.addListSelectionListener(createListSelectionListener(getFileChooser()));
    fileList.addMouseListener(createDoubleClickListener(getFileChooser(), fileList));
    align(fileList);
    JScrollPane scrollpane = new JScrollPane(fileList);
    scrollpane.setPreferredSize(prefListSize);
    scrollpane.setMaximumSize(MAX_SIZE);
    align(scrollpane);
    return scrollpane;
  }
Example #18
0
    TextPanel(String file) {
      super(new BorderLayout());

      JEditorPane text = new JEditorPane();

      try {
        text.setPage(TextPanel.this.getClass().getResource(file));
      } catch (Exception e) {
        text.setText("Error loading '" + file + "'");
        e.printStackTrace();
      }

      text.setEditable(false);

      JScrollPane scrollPane = new JScrollPane(text);
      Dimension dim = new Dimension();
      dim.width = 450;
      dim.height = 200;
      scrollPane.setPreferredSize(dim);
      TextPanel.this.add(BorderLayout.CENTER, scrollPane);
    }
  /** Construct a this GUI object's contents. */
  private void initComponents() {
    htmlWindow = new JEditorPane();
    htmlWindow.setPreferredSize(new Dimension(500, 500));
    htmlWindow.setEditable(false);
    htmlWindow.setContentType("text/html");
    scrollPane =
        new JScrollPane(
            htmlWindow,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setPreferredSize(new Dimension(500, 500));

    try {
      htmlWindow.setPage("file:./html-docs/index.html");
    } catch (IOException ioe) {
      System.err.println(ioe);
    }
    htmlWindow.addHyperlinkListener(
        new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              try {
                htmlWindow.setPage(e.getURL()); // ?????
              } catch (IOException ioe) {
                System.err.println(ioe);
              }
            }
          }
        });

    JButton exitButton = new JButton("Close Help Window");
    exitButton.addActionListener(this);
    mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(exitButton, "North");
    mainPanel.add(scrollPane, "Center");
    getContentPane().add(mainPanel);
  }
Example #20
0
  /** Stand alone testing. */
  public static void main(String[] args) {
    try {
      JFrame frame = new JFrame("JargonTree");
      JargonTree tree = new JargonTree(args, null);

      JScrollPane pane = new JScrollPane(tree);
      pane.setPreferredSize(new Dimension(800, 600));

      frame.addWindowListener(
          new WindowAdapter() {
            public void windowClosing(WindowEvent we) {
              System.exit(0);
            }
          });
      frame.getContentPane().add(pane, BorderLayout.NORTH);
      frame.pack();
      frame.show();
      frame.validate();

    } catch (Throwable e) {
      e.printStackTrace();
      System.out.println(((SRBException) e).getStandardMessage());
    }
  }
  public static void main() {
    // Main
    frame = new JFrame("Java Playground");
    frame.setSize(640, 480);
    // Make sure the divider is properly resized
    frame.addComponentListener(
        new ComponentAdapter() {
          public void componentResized(ComponentEvent c) {
            splitter.setDividerLocation(.8);
          }
        });
    // Make sure the JVM is reset on close
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosed(WindowEvent w) {
            new FrameAction().kill();
          }
        });

    // Setting up the keybinding
    // Ctrl+k or Cmd+k -> compile
    bind(KeyEvent.VK_K);

    // Ctrl+e or Cmd+e -> console
    bind(KeyEvent.VK_E);

    // Save, New file, Open file, Print.
    // Currently UNUSED until I figure out how normal java files and playground files will
    // interface.
    bind(KeyEvent.VK_S);
    bind(KeyEvent.VK_N);
    bind(KeyEvent.VK_O);
    bind(KeyEvent.VK_P);

    // Binds the keys to the action defined in the FrameAction class.
    frame.getRootPane().getActionMap().put("console", new FrameAction());

    // The main panel for typing code in.
    text = new JTextPane();
    textScroll = new JScrollPane(text);
    textScroll.setBorder(null);
    textScroll.setPreferredSize(new Dimension(640, 480));

    // Document with syntax highlighting. Currently unfinished.
    doc = text.getStyledDocument();
    doc.addDocumentListener(
        new DocumentListener() {
          public void changedUpdate(DocumentEvent d) {}

          public void insertUpdate(DocumentEvent d) {}

          public void removeUpdate(DocumentEvent d) {}
        });

    ((AbstractDocument) doc).setDocumentFilter(new NewLineFilter());

    // The output log; a combination compiler warning/error/runtime error/output log.
    outputText = new JTextPane();
    outputScroll = new JScrollPane(outputText);
    outputScroll.setBorder(null);

    // "Constant" for the error font
    error = new SimpleAttributeSet();
    error.addAttribute(StyleConstants.CharacterConstants.Italic, Boolean.TRUE);
    error.addAttribute(StyleConstants.Foreground, Color.RED);

    // "Constant" for the warning message font
    warning = new SimpleAttributeSet();
    warning.addAttribute(StyleConstants.CharacterConstants.Italic, Boolean.TRUE);
    warning.addAttribute(StyleConstants.Foreground, Color.PINK);

    // "Constant" for the debugger error font
    progErr = new SimpleAttributeSet();
    progErr.addAttribute(StyleConstants.Foreground, Color.BLUE);

    // Print streams to redirect System.out and System.err.
    out = new TextOutputStream(outputText, null);
    err = new TextOutputStream(outputText, error);
    System.setOut(new PrintStream(out));
    System.setErr(new PrintStream(err));

    // Sets up the output log
    outputText.setEditable(false);
    outputScroll.setVisible(true);

    // File input/output setup
    chooser = new JFileChooser();

    // Setting up miscellaneous stuff
    compiler = ToolProvider.getSystemJavaCompiler();
    JVMrunning = false;
    redirectErr = null;
    redirectOut = null;
    redirectIn = null;

    // Sets up the splitter pane and opens the program up
    splitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT, textScroll, outputScroll);
    consoleDisplayed = false;
    splitter.remove(outputScroll); // Initially hides terminal until it is needed
    splitter.setOneTouchExpandable(true);
    frame.add(splitter);
    frame.setVisible(true);

    // Sets the divider to the proper one, for debugging
    // splitter.setDividerLocation(.8);
  }
Example #22
0
  public SimpleTable() {
    JFrame frame = new JFrame("Table");
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    final String[] names = {"First Name", "Last Name", "Id"};
    final Object[][] data = {
      {"Mark", "Andrews", new Integer(1)},
      {"Tom", "Ball", new Integer(2)},
      {"Alan", "Chung", new Integer(3)},
    };

    TableModel dataModel =
        new AbstractTableModel() {
          public int getColumnCount() {
            return names.length;
          }

          public int getRowCount() {
            return data.length;
          }

          public Object getValueAt(int row, int col) {
            return data[row][col];
          }

          public String getColumnName(int column) {
            return names[column];
          }

          public Class getColumnClass(int col) {
            return getValueAt(0, col).getClass();
          }

          public void setValueAt(Object aValue, int row, int column) {
            data[row][column] = aValue;
          }
        };

    aTable = new JTable(dataModel);

    ListSelectionModel listMod = aTable.getSelectionModel();
    listMod.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listMod.addListSelectionListener(this);

    JScrollPane scrollpane = new JScrollPane(aTable);
    scrollpane.setPreferredSize(new Dimension(300, 300));
    frame.getContentPane().add(scrollpane);
    frame.pack();
    frame.setVisible(true);

    aTable.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
              System.out.println(" double click");
            }
          }
        });
  }
  /** Creates a ComponentTree, loading the Components from the file at <code>path</code>. */
  public ComponentTree(String path) {
    this.path = path;
    ttCount++;
    jTextArea = new JTextArea();
    textArea = new JTextArea();
    redirectSystemStreams();
    frame = createFrame();
    Container cPane = frame.getContentPane();
    JMenuBar mb = createMenuBar();
    TreeTableModel model = createModel(path);

    cPane.setLayout(new BorderLayout(5, 5));
    Dimension dim = new Dimension(600, 600);
    cPane.setPreferredSize(dim);

    try {
      textArea.read(new FileReader(path), null);
    } catch (IOException e) {
      e.printStackTrace(); // To change body of catch statement use File | Settings | File
      // Templates.
    }
    treeTable = createTreeTable(model);
    textArea.setEditable(false);

    JScrollPane tp =
        new JScrollPane(
            textArea,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    JScrollPane sp =
        new JScrollPane(
            treeTable,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    JScrollPane cp =
        new JScrollPane(
            jTextArea,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    sp.getViewport().setBackground(Color.white);

    Dimension scrDim = new Dimension(300, 600);
    Dimension dime = new Dimension(300, 400);
    Dimension dimc = new Dimension(300, 200);
    sp.setLocation(0, 0);
    sp.setPreferredSize(dime);
    tp.setLocation(300, 0);
    tp.setPreferredSize(scrDim);
    cp.setLocation(0, 400);
    cp.setPreferredSize(dimc);
    cPane.add(sp, BorderLayout.LINE_START);
    cPane.add(tp, BorderLayout.CENTER);
    cPane.add(cp, BorderLayout.PAGE_END);
    cPane.setPreferredSize(dim);

    // frame.add(cPane);
    frame.setJMenuBar(mb);
    // frame.pack();

    frame.setVisible(true);
  }
  /**
   * Constructor initialises the table and a popup tool, as well as initialising the required GUI
   * elements. It adds action listeners for the three main buttons, which include basic user input
   * validation checking.
   */
  public TableAttributeEditor(JFrame MyOwner) {
    // As usual, it is insanely hard to get the swing components to display
    // and work properly.  If JTable is not displayed in a scroll pane no headers are
    // displayed, and you have to do it manually.  (If you *do* display it
    // in a scrollbar, in this instance, it screws up sizing)
    // The broken header mis-feature is only mentioned in the tutorial,
    // not in the api doco - go figure.

    super();

    owner = MyOwner;

    // final JPanel mainPanel = (JPanel)this;

    tableData = new AttributeTableModel();

    attributeTable = new JTable(tableData);
    // attributeTable.setRowHeight(20);	// This may be needed, depends on how fussy people get about
    // the bottom of letters like 'y' getting cut off when the cell is selected - bug 3013.

    popupTableTool = new SmartPopupTableTool(attributeTable, tableData, (JXplorerBrowser) owner);

    // Set the renderer for the attribute type...
    final AttributeTypeCellRenderer typeRenderer = new AttributeTypeCellRenderer();

    attributeTable.setDefaultRenderer(AttributeNameAndType.class, typeRenderer);

    // Set the renderer for the attribute value...
    final AttributeValueCellRenderer valueRenderer = new AttributeValueCellRenderer();

    attributeTable.setDefaultRenderer(AttributeValue.class, valueRenderer);

    // Set the editor for the attribute value...
    myEditor = new AttributeValueCellEditor(owner);

    attributeTable.setDefaultEditor(AttributeValue.class, myEditor);

    attributeTable.getTableHeader().setReorderingAllowed(false);

    currentDN = null;

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    buttonPanel.add(
        submit =
            new CBButton(
                CBIntText.get("Submit"), CBIntText.get("Submit your changes to the Directory.")));
    buttonPanel.add(
        reset =
            new CBButton(
                CBIntText.get("Reset"),
                CBIntText.get("Reset this entry i.e. cancels any changes.")));
    buttonPanel.add(
        changeClass =
            new CBButton(
                CBIntText.get("Change Classes"),
                CBIntText.get("Change the Object Class of this entry.")));
    buttonPanel.add(
        opAttrs =
            new CBButton(
                CBIntText.get("Properties"),
                CBIntText.get("View the Operational Attributes of this entry.")));

    // I don't really understand why we have to do this...
    // but without it these buttons over ride the default
    // button (Search Bar's search button), if they have
    // been clicked and the user hits the enter key?
    opAttrs.setDefaultCapable(false);
    submit.setDefaultCapable(false);
    reset.setDefaultCapable(false);
    changeClass.setDefaultCapable(false);

    setLayout(new BorderLayout(10, 10));

    tableScroller = new JScrollPane();
    attributeTable.setBackground(Color.white);
    tableScroller.setPreferredSize(new Dimension(300, 285));
    tableScroller.setViewportView(attributeTable);
    add(tableScroller, BorderLayout.CENTER);
    add(buttonPanel, BorderLayout.SOUTH);

    if ("true".equals(JXConfig.getProperty("lock.read.only")))
      title = CBIntText.get("Table Viewer");
    else title = CBIntText.get("Table Editor");

    setVisible(true);

    // triggers adding operational attributes of the current entry.
    opAttrs.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            displayOperationalAttributes();
          }
        });

    reset.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            myEditor.stopCellEditing();
            // tableData.reset();
            displayEntry(originalEntry, dataSource, false);
          }
        });

    submit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            doSubmit();
          }
        });

    // This allows the user to change the objectclass attribute.
    // This is pretty tricky, because it changes what attributes are available.
    changeClass.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            changeClass();
          }
        });

    attributeTable.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            if (!doPopupStuff(e)) super.mousePressed(e);
          }

          public void mouseReleased(MouseEvent e) {
            if (!doPopupStuff(e)) super.mouseReleased(e);
          }

          // TODO need to have a way to call this from a keystroke...
          public boolean doPopupStuff(MouseEvent e) {
            if (e.isPopupTrigger() == false) return false;

            int row = attributeTable.rowAtPoint(new Point(e.getX(), e.getY()));

            attributeTable.clearSelection();
            attributeTable.addRowSelectionInterval(row, row);
            attributeTable.repaint();

            popupTableTool.registerCurrentRow(
                (AttributeNameAndType) attributeTable.getValueAt(row, 0),
                (AttributeValue) attributeTable.getValueAt(row, 1),
                row,
                tableData.getRDN()); // active path also set by valueChanged
            popupTableTool.show(attributeTable, e.getX(), e.getY());
            popupTableTool.registerCellEditor(myEditor); // TE: for bug fix 3107.
            return true;
          }
        });
  }
  public void initPanel() {
    // The panel uses an absolute layout.
    setLayout(null);

    // Name
    nameField = new JFormattedTextField(20);
    nameField.setEditable(false);
    addRow("Name", nameField);

    // Label
    labelField = new JTextField(20);
    labelField.addActionListener(this);
    labelField.addFocusListener(this);
    addRow("Label", labelField);

    // Help Text
    helpTextField = new JTextField(20);
    helpTextField.addActionListener(this);
    helpTextField.addFocusListener(this);
    addRow("Help Text", helpTextField);

    // Widget
    widgetBox = new JComboBox(humanizedWidgets);
    widgetBox.addActionListener(this);
    addRow("Type", widgetBox);

    // Value
    valueField = new JTextField(20);
    valueField.addActionListener(this);
    valueField.addFocusListener(this);
    addRow("Value", valueField);

    // Enable If
    enableIfField = new JTextField(20);
    enableIfField.addActionListener(this);
    enableIfField.addFocusListener(this);
    addRow("Enable If", enableIfField);

    // Bounding Method
    boundingMethodBox = new JComboBox(new String[] {"none", "soft", "hard"});
    boundingMethodBox.addActionListener(this);
    addRow("Bounding", boundingMethodBox);

    // Minimum Value
    minimumValueCheck = new JCheckBox();
    minimumValueCheck.addActionListener(this);
    minimumValueField = new JTextField(10);
    minimumValueField.addActionListener(this);
    minimumValueField.addFocusListener(this);
    JPanel minimumValuePanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 0));
    minimumValuePanel.add(minimumValueCheck);
    minimumValuePanel.add(minimumValueField);
    addRow("Minimum", minimumValuePanel);

    // Maximum Value
    maximumValueCheck = new JCheckBox();
    maximumValueCheck.addActionListener(this);
    maximumValueField = new JTextField(10);
    maximumValueField.addActionListener(this);
    maximumValueField.addFocusListener(this);
    JPanel maximumValuePanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 0));
    maximumValuePanel.add(maximumValueCheck);
    maximumValuePanel.add(maximumValueField);
    addRow("Maximum", maximumValuePanel);

    // Display Level
    displayLevelBox = new JComboBox(new String[] {"hud", "detail", "hidden"});
    displayLevelBox.addActionListener(this);
    addRow("Display Level", displayLevelBox);

    // Menu Items
    menuItemsTable = new JTable(new MenuItemsModel());
    menuItemsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JPanel tablePanel = new JPanel(new BorderLayout(5, 5));
    JScrollPane tableScroll =
        new JScrollPane(
            menuItemsTable,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    tableScroll.setSize(200, 170);
    tableScroll.setPreferredSize(new Dimension(200, 170));
    tableScroll.setMaximumSize(new Dimension(200, 170));
    tableScroll.setMinimumSize(new Dimension(200, 170));
    tablePanel.add(tableScroll, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 5));
    addButton = new JButton(new Icons.PlusIcon());
    addButton.addActionListener(this);
    removeButton = new JButton(new Icons.MinusIcon());
    removeButton.addActionListener(this);
    upButton = new JButton(new Icons.ArrowIcon(Icons.ArrowIcon.NORTH));
    upButton.addActionListener(this);
    downButton = new JButton(new Icons.ArrowIcon(Icons.ArrowIcon.SOUTH));
    downButton.addActionListener(this);
    buttonPanel.add(addButton);
    buttonPanel.add(removeButton);
    buttonPanel.add(upButton);
    buttonPanel.add(downButton);
    tablePanel.add(buttonPanel, BorderLayout.SOUTH);
    addRow("Menu Items", tablePanel);
  }
  // CONSTRUCTOR
  public FACFrame() {

    // SET PROPERTIES OF THE MAIN FRAME
    setTitle("Fully Associative Cache");
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setIconImage(Toolkit.getDefaultToolkit().createImage(FACFrame.class.getResource("cam.gif")));

    // CREATE COMPONENTS AND SET THEIR PROPERTIES

    // NAVIGATION BUTTONS
    restart = new JButton("Restart");
    next = new JButton("Next");
    back = new JButton("Back");
    quit = new JButton("Quit");

    // CACHE HITS AND MISSES INFO.
    lCacheHits = new JLabel("Cache Hits");
    lCacheMisses = new JLabel("Cache Misses");
    tCacheHits = new JTextField(5);
    tCacheMisses = new JTextField(5);
    tCacheHits.setEditable(false);
    tCacheHits.setFont(new Font("Monospaced", Font.BOLD, 14));
    tCacheHits.setText("  0");
    tCacheMisses.setEditable(false);
    tCacheMisses.setFont(new Font("Monospaced", Font.BOLD, 14));
    tCacheMisses.setText("  0");

    // PROGRESS UPDATE AREA
    tProgress = new JTextArea(3, 45);
    tProgress.setEditable(false);
    tProgress.setLineWrap(true);
    tProgress.setWrapStyleWord(true);
    tProgress.setCaretPosition(0);
    tProgress.setFont(new Font("Serif", Font.BOLD + Font.ITALIC, 16));
    tProgress.setText(
        "Welcome to Fully Associative Cache!\nThe system specs are as follows -"
            + "\n  16 Blocks in Cache\n  32 Blocks in Main Memory\n  8 Words per Block"
            + "\n  The replacement algorithm shown is the Least-Recently-Used algorithm"
            + "\n  as it is the most commonly used one."
            + "\nPlease generate the Address Reference String."
            + "\nThen click on \"Next\" to continue.");
    progressScroll = new JScrollPane();
    progressScroll.getViewport().add(tProgress);
    progressScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    lProgress = new JLabel("PROGRESS UPDATE");

    // ADDRESS REFERENCE STRING
    addRefStrList = new JList();
    addRefStrList.setEnabled(false);
    addRefStrScroll = new JScrollPane();
    addRefStrScroll.getViewport().setView(addRefStrList);
    addRefStrScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    addRefStrScroll.setPreferredSize(new Dimension(140, 300));

    // BUTTONS USED TO ADDRESS GENERATION
    autoGen = new JButton("Auto Generate Add. Ref. Str.");
    selfGen = new JButton("Self Generate Add. Ref. Str.");

    // BITS IN MAIN MEMORY ADDRESS
    lBits = new JLabel("                   TAG                        WORD");

    tTag = new JTextField(9);
    tTag.setEditable(false);
    tWord = new JTextField(7);
    tWord.setEditable(false);

    // SET THE FONT STYLES FOR THE BITS IN MAIN MEMORY ADDRESS
    tTag.setFont(new Font("Monospaced", Font.BOLD, 14));
    tWord.setFont(new Font("Monospaced", Font.BOLD, 14));

    // REGISTER LISTENERS
    restart.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            reStart();
          }
        });

    next.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            nextClicked = true;
            step();
          }
        });

    back.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            nextClicked = false;
            step();
          }
        });

    quit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            int confirmQuit =
                JOptionPane.showConfirmDialog(
                    null,
                    "Really Quit?",
                    "Quit Confirmation",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE);
            switch (confirmQuit) {
              case JOptionPane.YES_OPTION:
                removeInstance();
              case JOptionPane.NO_OPTION:
                break;
            }
          }
        });

    autoGen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            autoGenerateString();
          }
        });

    selfGen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            selfGenerateString();
          }
        });

    // DISABLE NAVIGATION BUTTONS FOR NOW
    next.setEnabled(false);
    back.setEnabled(false);

    // CREATE PANELS
    cachePanel = new FACachePanel();
    memoryPanel = new MemoryPanel();
    bottomPanel = new JPanel();
    cache = new JPanel();
    cacheHitsMisses = new JPanel();
    pAutoSelfGen = new JPanel();
    pAddRefStr = new JPanel();
    pEastPanel = new JPanel();
    pBitsInMM = new JPanel();

    // ADD COMPONENTS TO THE PANELS

    // PANEL WITH PROGRESS UPDATE TEXT AREA AND NAVIGATION BUTTONS
    bottomPanel.add(lProgress);
    bottomPanel.add(progressScroll);
    bottomPanel.add(restart);
    bottomPanel.add(next);
    bottomPanel.add(back);
    bottomPanel.add(quit);

    // PANEL WITH CACHE BLOCKS, HITS AND MISSES INFO.
    cacheHitsMisses.add(lCacheHits);
    cacheHitsMisses.add(tCacheHits);
    cacheHitsMisses.add(lCacheMisses);
    cacheHitsMisses.add(tCacheMisses);
    cacheHMBorder = BorderFactory.createEtchedBorder();
    cacheHitsMisses.setBorder(BorderFactory.createTitledBorder(cacheHMBorder, ""));

    cache.setLayout(new BorderLayout());
    cache.add(cachePanel, "Center");
    cache.add(cacheHitsMisses, "South");

    // PANEL WITH ADDRESS REFERENCE STRING AND STRING GENERATION BUTTONS
    pAutoSelfGen.setLayout(new GridLayout(2, 1));
    pAutoSelfGen.add(autoGen);
    pAutoSelfGen.add(selfGen);

    pAddRefStr.setLayout(new BorderLayout());
    pAddRefStr.setPreferredSize(new Dimension(160, 400));

    pAddRefStr.add(addRefStrScroll, "Center");
    pAddRefStr.add(pAutoSelfGen, "South");
    addRefStrBorder = BorderFactory.createEtchedBorder();
    pAddRefStr.setBorder(
        BorderFactory.createTitledBorder(addRefStrBorder, " Address Reference String "));

    // PANEL WITH THE MAIN MEMORY ADDRESS BITS INFO.
    pBitsInMM.setLayout(new BorderLayout());
    bitsInMMBorder = BorderFactory.createEtchedBorder();
    pBitsInMM.setBorder(BorderFactory.createTitledBorder(bitsInMMBorder, " Main Memory Address "));
    pBitsInMM.add(tTag, "Center");
    pBitsInMM.add(tWord, "East");
    pBitsInMM.add(lBits, "South");

    // PANEL CONTAINING THE ADDRESS REF. STRING PANEL AND BITS IN MM PANEL
    pEastPanel.setLayout(new BorderLayout());
    pEastPanel.setPreferredSize(new Dimension(310, 650));
    pEastPanel.add(pAddRefStr, "Center");
    pEastPanel.add(pBitsInMM, "South");

    // ADD COMPONENTS TO THE FRAME CONTAINER
    Container c = getContentPane();
    c.setLayout(new BorderLayout());
    c.add(cache, "West");
    c.add(memoryPanel, "Center");
    c.add(pEastPanel, "East");
    c.add(bottomPanel, "South");

    // INITIALIZE ARRAYS THAT HOLDS STATUS OF EMPTY AND LRU CACHE BLOCKS
    for (int i = 0; i < 16; i++) {
      statusCacheEmpty[i] = true;
      statusCacheLRU[i] = 0;
    }

    /*
     * CALL THE FUNCTION TO GENERATE THE ARRAY addresses, WHICH CONTAINS ALL THE POSSIBLE MEMORY ADDRESSES
     * THIS ARRAY WILL BE USEFUL IN THE AUTO GENERATION OF ADDRESSES AS WELL AS FOR VALIDATION OF
     * ADDRESS STRINGS INPUT BY THE USER IF HE/SHE CHOOSES SELF GENERATION.
     */
    createAddresses();

    pack();
  } // END CONSTRUCTOR
    protected void initComponents(
        AirspaceBuilderModel model, final AirspaceBuilderController controller) {
      final JCheckBox resizeNewShapesCheckBox;
      final JCheckBox enableEditCheckBox;

      JPanel newShapePanel = new JPanel();
      {
        JButton newShapeButton = new JButton("New shape");
        newShapeButton.setActionCommand(NEW_AIRSPACE);
        newShapeButton.addActionListener(controller);
        newShapeButton.setToolTipText("Create a new shape centered in the viewport");

        this.factoryComboBox = new JComboBox(defaultAirspaceFactories);
        this.factoryComboBox.setEditable(false);
        this.factoryComboBox.setToolTipText("Choose shape type to create");

        resizeNewShapesCheckBox = new JCheckBox("Fit new shapes to viewport");
        resizeNewShapesCheckBox.setActionCommand(SIZE_NEW_SHAPES_TO_VIEWPORT);
        resizeNewShapesCheckBox.addActionListener(controller);
        resizeNewShapesCheckBox.setSelected(controller.isResizeNewShapesToViewport());
        resizeNewShapesCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);
        resizeNewShapesCheckBox.setToolTipText(
            "New shapes are sized to fit the geographic viewport");

        enableEditCheckBox = new JCheckBox("Enable shape editing");
        enableEditCheckBox.setActionCommand(ENABLE_EDIT);
        enableEditCheckBox.addActionListener(controller);
        enableEditCheckBox.setSelected(controller.isEnableEdit());
        enableEditCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);
        enableEditCheckBox.setToolTipText("Allow modifications to shapes");

        Box newShapeBox = Box.createHorizontalBox();
        newShapeBox.add(newShapeButton);
        newShapeBox.add(Box.createHorizontalStrut(5));
        newShapeBox.add(this.factoryComboBox);
        newShapeBox.setAlignmentX(Component.LEFT_ALIGNMENT);

        JPanel gridPanel = new JPanel(new GridLayout(0, 1, 0, 5)); // rows, cols, hgap, vgap
        gridPanel.add(newShapeBox);
        gridPanel.add(resizeNewShapesCheckBox);
        gridPanel.add(enableEditCheckBox);

        newShapePanel.setLayout(new BorderLayout());
        newShapePanel.add(gridPanel, BorderLayout.NORTH);
      }

      JPanel entryPanel = new JPanel();
      {
        this.entryTable = new JTable(model);
        this.entryTable.setColumnSelectionAllowed(false);
        this.entryTable.setRowSelectionAllowed(true);
        this.entryTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        this.entryTable
            .getSelectionModel()
            .addListSelectionListener(
                new ListSelectionListener() {
                  public void valueChanged(ListSelectionEvent e) {
                    if (!ignoreSelectEvents) {
                      controller.actionPerformed(
                          new ActionEvent(e.getSource(), -1, SELECTION_CHANGED));
                    }
                  }
                });
        this.entryTable.setToolTipText("<html>Click to select<br>Double-Click to rename</html>");

        JScrollPane tablePane = new JScrollPane(this.entryTable);
        tablePane.setPreferredSize(new Dimension(200, 100));

        entryPanel.setLayout(new BorderLayout(0, 0)); // hgap, vgap
        entryPanel.add(tablePane, BorderLayout.CENTER);
      }

      JPanel selectionPanel = new JPanel();
      {
        JButton delselectButton = new JButton("Deselect");
        delselectButton.setActionCommand(CLEAR_SELECTION);
        delselectButton.addActionListener(controller);
        delselectButton.setToolTipText("Clear the selection");

        JButton deleteButton = new JButton("Delete Selected");
        deleteButton.setActionCommand(REMOVE_SELECTED);
        deleteButton.addActionListener(controller);
        deleteButton.setToolTipText("Delete selected shapes");

        JPanel gridPanel = new JPanel(new GridLayout(0, 1, 0, 5)); // rows, cols, hgap, vgap
        gridPanel.add(delselectButton);
        gridPanel.add(deleteButton);

        selectionPanel.setLayout(new BorderLayout());
        selectionPanel.add(gridPanel, BorderLayout.NORTH);
      }

      this.setLayout(new BorderLayout(30, 0)); // hgap, vgap
      this.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); // top, left, bottom, right
      this.add(newShapePanel, BorderLayout.WEST);
      this.add(entryPanel, BorderLayout.CENTER);
      this.add(selectionPanel, BorderLayout.EAST);

      controller.addPropertyChangeListener(
          new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent e) {
              if (SIZE_NEW_SHAPES_TO_VIEWPORT.equals(e.getPropertyName())) {
                resizeNewShapesCheckBox.setSelected(controller.isResizeNewShapesToViewport());
              } else if (ENABLE_EDIT.equals(e.getPropertyName())) {
                enableEditCheckBox.setSelected(controller.isEnableEdit());
              }
            }
          });
    }
Example #28
0
  private void setupPanels()
  {
    Border   border1, border2;
    int      row, col;
    MyButton btn;


    border2 = BorderFactory.createLoweredBevelBorder();
    
    JPanel mainPanel = new JPanel( new GridBagLayout() );
    
    GridBagConstraints con = new GridBagConstraints();
    con.fill = GridBagConstraints.HORIZONTAL; 
    con.weightx = 1; con.anchor = GridBagConstraints.NORTHWEST;
    
    // Setup States Panels
    JPanel statesP = new JPanel( new GridBagLayout() );
    border1 = BorderFactory.createEmptyBorder (4, 4, 2, 4);
    statesP.setBorder( BorderFactory.createCompoundBorder(border1, border2) );
    
    JPanel statesP_in = new JPanel(new GridBagLayout() );
    
    row = 0; col = 0;
    Enumeration enum = parent.stateDefs.elements();
    
    while ( enum.hasMoreElements() ) {
        RecDef def = ( RecDef ) enum.nextElement();
      
        if ( def.stateVector.size() > 0 ) {
            con.gridx = col; con.gridy = row;

            btn = new MyButton( def.description,
                                "Press for " + def.description
                              + " histogram", this );
            statesP_in.add( btn, con);
            btn.setIcon( new ColoredRect( def.color ) );
            btn.setHorizontalAlignment( btn.LEFT );
		   
            con.gridx = col + 1;
            def.checkbox = new JCheckBox( "", true );
            statesP_in.add( def.checkbox, con ); 
	    def.checkbox.addItemListener( this ); 
            def.checkbox.setToolTipText( "Enable or disable "
                                       + def.description );
	
            if ( (col / 2) == numCols ) {
                col = 0; row ++; 
            }
            else
                col += 2;
        }
    }
    
    con.gridx = 0; con.gridy = 0;
    con.fill = GridBagConstraints.NONE;
    con.weightx = 0;
    statesP.add( statesP_in, con );
    
    // State Buttons Controls
    JPanel states_cntl = new JPanel( new GridLayout(2, 1) );
    states_cntl.add( new MyButton( "All States On",
                                   "Enable all states", this) ); 
    states_cntl.add( new MyButton( "All States Off",
                                   "Disable all states", this) );
    
    con.gridx = 1;
    statesP.add( states_cntl, con );
    
    con.gridx = 0; con.gridy = 0;
    mainPanel.add( statesP, con );
    
    // Setup Arrows Panels
    if ( parent.arrowDefs.size() > 0 ) {
        row = 0; col = 0;
        JPanel arrowsP = new JPanel( new GridBagLayout() );
        border1 = BorderFactory.createEmptyBorder (2, 4, 4, 4);
        arrowsP.setBorder( BorderFactory.createCompoundBorder( border1,
                                                               border2 ) );

        JPanel arrowsP_in = new JPanel( new GridBagLayout() );

        enum = parent.arrowDefs.elements();
        while ( enum.hasMoreElements() ) {
            RecDef def = ( RecDef ) enum.nextElement();
            if ( def.stateVector.size() > 0 ) {
                con.gridx = col; con.gridy = row;
                btn = new MyButton( def.description,
                                    "Press for " + def.description
                                  + " histogram", this );
                arrowsP_in.add( btn, con );
                btn.setIcon( new ColoredRect( def.color ) );
                btn.setHorizontalAlignment( btn.LEFT );

                con.gridx = col + 1;
                def.checkbox = new JCheckBox( "", true );
                arrowsP_in.add( def.checkbox, con ); 
                def.checkbox.addItemListener( this ); 
                def.checkbox.setToolTipText( "Enable or disable "
                                           + def.description );
                if ( (col / 2) == numCols ) {
                    col = 0; row ++; 
                }
                else
                    col += 2;
            }   //  Endof if ( def.stateVector.size() > 0 )
        }

        con.gridx = 0; con.gridy = 0;
        con.fill = GridBagConstraints.NONE;
        con.weightx = 0;
        arrowsP.add( arrowsP_in, con );
    
        // Arrow Buttons Controls
        JPanel arrows_cntl = new JPanel( new GridLayout(2, 1) );
        arrows_cntl.add( new MyButton( "All Arrows On",
                                       "Enable all arrows", this) ); 
        arrows_cntl.add( new MyButton( "All Arrows Off",
                                       "Disable all arrows", this) );
    
        con.gridx = 1;
        arrowsP.add( arrows_cntl, con );

        con.gridy = 2; con.gridx = 0;
        mainPanel.add( arrowsP, con );
    }   //  Endof  if ( parent.arrowDefs.size() > 0 )
      
    //Add mainPanel to JScrollPane
    JScrollPane sP = new JScrollPane (mainPanel);
    sP.setPreferredSize (new Dimension (100, 100));
    sP.setMinimumSize (new Dimension (100, 100));
    add (sP);
  }
Example #29
0
  void jbInit() throws Exception {
    titledBorder1 =
        new TitledBorder(
            BorderFactory.createLineBorder(new Color(153, 153, 153), 2), "Assembler messages");
    this.getContentPane().setLayout(borderLayout1);

    this.setIconifiable(true);
    this.setMaximizable(true);
    this.setResizable(true);

    this.setTitle("EDIT");

    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    splitPane.setDividerLocation(470);
    sourceArea.setFont(new java.awt.Font("Monospaced", 0, 12));
    controlPanel.setLayout(gridBagLayout1);
    controlPanel.setBorder(BorderFactory.createLoweredBevelBorder());
    positionPanel.setLayout(gridBagLayout2);
    fileLabel.setText("Source file:");
    fileText.setEditable(false);
    browseButton.setSelected(false);
    browseButton.setText("Browse ...");
    assembleButton.setEnabled(false);
    assembleButton.setText("Assemble file");
    saveButton.setEnabled(false);
    saveButton.setText("Save file");
    lineLabel.setText("Line:");
    lineText.setMinimumSize(new Dimension(50, 20));
    lineText.setPreferredSize(new Dimension(50, 20));
    lineText.setEditable(false);
    columnLabel.setText("Column:");
    columnText.setMinimumSize(new Dimension(41, 20));
    columnText.setPreferredSize(new Dimension(41, 20));
    columnText.setEditable(false);
    columnText.setText("");
    messageScrollPane.setBorder(titledBorder1);
    messageScrollPane.setMinimumSize(new Dimension(33, 61));
    messageScrollPane.setPreferredSize(new Dimension(60, 90));
    optionsButton.setEnabled(false);
    optionsButton.setText("Assembler options ...");
    messageScrollPane.getViewport().add(messageList, null);
    messageList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    this.getContentPane().add(splitPane, BorderLayout.CENTER);
    splitPane.add(textScrollPane, JSplitPane.TOP);
    splitPane.add(controlPanel, JSplitPane.BOTTOM);
    textScrollPane.getViewport().add(sourceArea, null);

    controlPanel.add(
        fileLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        fileText,
        new GridBagConstraints(
            1,
            0,
            3,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        browseButton,
        new GridBagConstraints(
            4,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 5),
            0,
            0));
    controlPanel.add(
        optionsButton,
        new GridBagConstraints(
            2,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        assembleButton,
        new GridBagConstraints(
            3,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        saveButton,
        new GridBagConstraints(
            4,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 5),
            0,
            0));
    controlPanel.add(
        positionPanel,
        new GridBagConstraints(
            0,
            1,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    positionPanel.add(
        lineLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));
    positionPanel.add(
        lineText,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 0),
            0,
            0));
    positionPanel.add(
        columnLabel,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 10, 0, 0),
            0,
            0));
    positionPanel.add(
        columnText,
        new GridBagConstraints(
            3,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        messageScrollPane,
        new GridBagConstraints(
            0,
            2,
            5,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0));
  }
Example #30
0
    @Override
    public void actionPerformed(ActionEvent e) {

      licence_text =
          new String(
              "This program is free software: you can redistribute it and/or modify\n"
                  + "it under the terms of the GNU General Public License as published by\n"
                  + "the Free Software Foundation, either version 3 of the License, or\n"
                  + "(at your option) any later version.\n"
                  + "\n"
                  + "This program is distributed in the hope that it will be useful,\n"
                  + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
                  + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
                  + "GNU General Public License for more details.\n"
                  + "\n"
                  + "You should have received a copy of the GNU General Public License\n"
                  + "along with this program.  If not, see <http://www.gnu.org/licenses/>.\n"
                  + "\n\n\n");

      try {
        InputStream ips = new FileInputStream(getClass().getResource("COPYING").getPath());
        InputStreamReader ipsr = new InputStreamReader(ips);
        BufferedReader br = new BufferedReader(ipsr);

        String line;
        while ((line = br.readLine()) != null) {
          licence_text += line + '\n';
        }
        br.close();
      } catch (Exception e1) {
      }

      Dimension dimension = new Dimension(600, 400);

      JDialog licence = new JDialog(memento, "Licence");

      JTextPane text_pane = new JTextPane();
      text_pane.setEditable(false);
      text_pane.setPreferredSize(dimension);
      text_pane.setSize(dimension);

      StyledDocument doc = text_pane.getStyledDocument();

      Style justified =
          doc.addStyle(
              "justified",
              StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE));
      StyleConstants.setAlignment(justified, StyleConstants.ALIGN_JUSTIFIED);

      try {
        doc.insertString(0, licence_text, justified);
      } catch (BadLocationException ble) {
        System.err.println("Couldn't insert initial text into text pane.");
      }
      Style logicalStyle = doc.getLogicalStyle(0);
      doc.setParagraphAttributes(0, licence_text.length(), justified, false);
      doc.setLogicalStyle(0, logicalStyle);

      JScrollPane paneScrollPane = new JScrollPane(text_pane);
      paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
      paneScrollPane.setPreferredSize(dimension);
      paneScrollPane.setMinimumSize(dimension);

      JPanel pan = new JPanel();
      LayoutManager layout = new BorderLayout();
      pan.setLayout(layout);

      pan.add(new JScrollPane(paneScrollPane), BorderLayout.CENTER);
      JButton close = new JButton("Fermer");
      close.addActionListener(new ButtonCloseActionListener(licence));
      JPanel button_panel = new JPanel();
      FlowLayout button_panel_layout = new FlowLayout(FlowLayout.RIGHT, 20, 20);
      button_panel.setLayout(button_panel_layout);

      button_panel.add(close);
      pan.add(button_panel, BorderLayout.SOUTH);

      licence.add(pan);

      licence.pack();
      licence.setLocationRelativeTo(memento);
      licence.setVisible(true);
    }