Java Code Examples for java.awt.GridLayout

The following are top voted examples for showing how to use java.awt.GridLayout. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: jaer   File: JAERDataViewer.java   Source Code and License 6 votes vote down vote up
/** Creates new form JAERDataViewer */
public JAERDataViewer(String title) {
    initComponents();
    
    this.setTitle(title);
    
    pnlGraph = new GraphPanel();
    pnlGraph.setBackground(new java.awt.Color(255, 255, 255));
    pnlGraph.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    pnlGraphContainer.setLayout(new GridLayout(0,1));
    pnlGraph.setUpdateEvent(new GraphPanelUpdateEvent() {
        public void update() {
            updateAxeBoxes();
        }
    });
    pnlGraphContainer.add(pnlGraph);
    pnlGraphContainer.revalidate();
    pnlGraphContainer.repaint();
    
    pnlGraph.setResizeX(false);
    pnlGraph.setResizeY(true);
    updateAxeBoxes();
    periodicUpdate(true);
    tblData.setModel(tabledata);
}
 
Example 2
Project: human-mobility-modeling-utilities   File: FirstPassageTimeTest.java   Source Code and License 6 votes vote down vote up
public FirstPassageTimeTest(){
	super(new GridLayout(1,2));
	int dbscanMeter = 500;
	loadRealWorldData(new DistanceWithUnit(dbscanMeter, SpatialDistanceUnit.Meter));
	HashMap<Long, Double> values = null;
	values = firstPassageTimeCalculationTest();
	
	double[][] plotValues = new double [values.keySet().size()][2];
	
	int index=0;
	
	for(Entry<Long, Double> entry:values.entrySet()){
		plotValues[index][0] = entry.getKey();
		plotValues[index][1] = entry.getValue();
		
		index++;
	}
	
	
	PlotCanvas canvas = LinePlot.plot("First passage time", plotValues, Line.Style.SOLID, Color.RED);
       canvas.setTitle("First passage time (DBSCAN=" + dbscanMeter + "m)");
       canvas.setAxisLabels("t (hour)", "Fpt (t)");
       
	add(canvas);

}
 
Example 3
Project: sbc-qsystem   File: FInfoDialog.java   Source Code and License 6 votes vote down vote up
/**
 * Creates new form FStandAdvance
 */
public FInfoDialog(java.awt.Frame parent, boolean modal) {
    super(parent, modal);
    infoDialog = this;
    initComponents();
    if (WelcomeParams.getInstance().btnFont != null) {
        buttonBack.setFont(WelcomeParams.getInstance().btnFont);
        buttonInRoot.setFont(WelcomeParams.getInstance().btnFont);
        buttonPrint.setFont(WelcomeParams.getInstance().btnFont);
        jButton2.setFont(WelcomeParams.getInstance().btnFont);
    }

    //На верхней панели пункта регистрации, там где заголовок и картинка в углу, можно вывести вэб-контент по URL. Оставьте пустым если не требуется
    if (!WelcomeParams.getInstance().topURL.isEmpty()) {
        panelUp.removeAll();
        final BrowserFX bro = new BrowserFX();
        final GridLayout gl = new GridLayout(1, 1);
        panelUp.setLayout(gl);
        panelUp.add(bro);
        bro.load(Uses.prepareAbsolutPathForImg(WelcomeParams.getInstance().topURL));
    }
}
 
Example 4
Project: sbc-qsystem   File: BrowserFX.java   Source Code and License 6 votes vote down vote up
public BrowserFX() {
    javafxPanel = new JFXPanel();
    GridLayout gl = new GridLayout(1, 1);
    setLayout(gl);
    add(javafxPanel, BorderLayout.CENTER);
    try {
        Thread.sleep(3000);
    } catch (InterruptedException ex) {
    }

    Platform.runLater(() -> {
        bro = new Browser();
        bro.getWebEngine().setJavaScriptEnabled(true);
        Scene scene = new Scene(bro, 750, 500, Color.web("#666970"));
        javafxPanel.setScene(scene);
        ready = true;
    });
}
 
Example 5
Project: geomapapp   File: GMAProfile.java   Source Code and License 6 votes vote down vote up
void initSave() {
	savePanel = new JPanel(new GridLayout(0,1));
	savePanel.setBorder( BorderFactory.createTitledBorder("Save Options"));
	ButtonGroup gp = new ButtonGroup();
	saveToFile = new JToggleButton("Save ASCII table");
	savePanel.add( saveToFile );
	gp.add( saveToFile );
	saveToClipboard = new JToggleButton("Copy to clipboard");
	savePanel.add( saveToClipboard );
	gp.add( saveToClipboard );
	saveJPEG = new JToggleButton("Save JPEG image");
	savePanel.add( saveJPEG );
	gp.add( saveJPEG );
	savePNG = new JToggleButton("Save PNG image");
	savePanel.add( savePNG );
	gp.add( savePNG );
	print = new JToggleButton("Print");
	savePanel.add( print );
	gp.add( print );
}
 
Example 6
Project: ramus   File: SectorNameEditor.java   Source Code and License 6 votes vote down vote up
private Component getReplacemetPanel() {
    JPanel group = new JPanel(new GridLayout(0, 1));
    group.setBorder(BorderFactory.createTitledBorder(ResourceLoader
            .getString("ArrowReplacementType.name")));
    group.add(safe = new JRadioButton("ArrowReplacementType.safe"));
    group.add(children = new JRadioButton("ArrowReplacementType.branching"));
    group.add(all = new JRadioButton("ArrowReplacementType.everywhere"));
    safe.setSelected(true);

    ButtonGroup g = new ButtonGroup();
    g.add(children);
    g.add(all);
    g.add(safe);

    setReplaceEnable(false);

    return group;
}
 
Example 7
Project: incubator-netbeans   File: FilesModifiedConfirmation.java   Source Code and License 6 votes vote down vote up
public FilesModifiedConfirmation(SaveCookie[] saveCookies) {
    btnSaveAll = createSaveAllButton();
    btnSave    = createSaveButton();

    Mnemonics.setLocalizedText(btnSaveAll, getInitialSaveAllButtonText());
    Mnemonics.setLocalizedText(btnSave,    getInitialSaveButtonText());

    JScrollPane scrollPane
            = new JScrollPane(list = createFilesList(saveCookies));

    if (!listModel.isEmpty()) {
        list.setSelectedIndex(0);
    } else {
        updateSaveButtonState();
    }

    JComponent panel = new JPanel(new GridLayout(1, 1));
    panel.add(scrollPane);
    panel.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
    mainComponent = panel;
}
 
Example 8
Project: ramus   File: StatusPanel.java   Source Code and License 6 votes vote down vote up
/**
 * This method initializes this
 *
 * @return void
 */
private void initialize() {
    double[][] size = {{5, TableLayout.FILL, 5},
            {5, TableLayout.FILL, 5}};
    this.setLayout(new TableLayout(size));
    final GridLayout gridLayout3 = new GridLayout();
    JPanel child = new JPanel(gridLayout3);
    this.setSize(351, 105);
    gridLayout3.setRows(3);
    gridLayout3.setColumns(2);
    gridLayout3.setHgap(5);
    gridLayout3.setVgap(5);
    child.add(getJRadioButton(), null);
    child.add(getJRadioButton1(), null);
    child.add(getJRadioButton2(), null);
    child.add(getJRadioButton3(), null);
    child.add(getJRadioButton4(), null);
    child.add(getJTextField(), null);
    this.add(child, "1,1");
}
 
Example 9
Project: ramus   File: VisualPanelCopyOptions.java   Source Code and License 6 votes vote down vote up
/**
 * Create the panel.
 */
public VisualPanelCopyOptions() {
    setLayout(new GridLayout(0, 1, 0, 0));

    copyFont = new JCheckBox("Visual.copyFont");
    copyFont.setSelected(true);
    add(copyFont);

    copyBackground = new JCheckBox("Visual.copyBackground");
    copyBackground.setSelected(true);
    add(copyBackground);

    copyForeground = new JCheckBox("Visual.copyForeground");
    copyForeground.setSelected(true);
    add(copyForeground);

    copySize = new JCheckBox("Visual.copySize");
    copySize.setSelected(true);
    add(copySize);

}
 
Example 10
Project: rapidminer   File: ProcessExecutionResultOverview.java   Source Code and License 6 votes vote down vote up
/**
 * Removes and adds the single result blocks according to the current width.
 */
private void redoLayout() {
	resultPanel.removeAll();
	if (expanded) {
		int curWidth = parent.getSize().width;
		int relevantWidth = SingleResultOverview.MIN_WIDTH + 25;
		int xCount = curWidth / relevantWidth;
		int yCount = (int) Math.ceil((double) results.size() / xCount);
		resultPanel.setLayout(new GridLayout(yCount, xCount));
		for (SingleResultOverview overview : results) {
			resultPanel.add(overview);
		}
	}
	revalidate();

}
 
Example 11
Project: bhattiprolu-pad   File: BhattiproluPad.java   Source Code and License 6 votes vote down vote up
public BhattiproluPad() {
	mainFrame = new JFrame("Bhattiprolu Pad - Now, type in Telugu easily");
	mainFrame.setSize(800, 800);
	mainFrame.setLayout(new GridLayout(3, 1));

	headLabel = new JLabel("Bhattiprolu Pad 0.1", JLabel.CENTER);
	contentLabel = new JLabel("Empty", JLabel.CENTER);
	mainPanel = new JPanel();
	mainPanel.setLayout(new FlowLayout());

	headLabel.setFont(englishFont);
	contentLabel.setFont(teluguFont);

	mainFrame.add(headLabel);
	mainFrame.add(mainPanel);
	mainFrame.add(contentLabel);
	mainFrame.setVisible(true);
	mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}
 
Example 12
Project: jmt   File: SynopsisPanel.java   Source Code and License 6 votes vote down vote up
private void initComponents() {
	Box vBox = Box.createVerticalBox();
	Box hBox = Box.createHorizontalBox();
	synView = new JTextPane();
	synView.setContentType("text/html");
	synView.setEditable(false);
	synScroll = new JScrollPane(synView);
	synScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	synScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
	vBox.add(Box.createVerticalStrut(30));
	vBox.add(hBox);
	vBox.add(Box.createVerticalStrut(30));
	hBox.add(Box.createHorizontalStrut(20));
	hBox.add(synScroll);
	hBox.add(Box.createHorizontalStrut(20));
	this.setLayout(new GridLayout(1, 1));
	this.add(vBox);
}
 
Example 13
Project: geomapapp   File: XYSave.java   Source Code and License 6 votes vote down vote up
void initSave() {
	savePanel = new JPanel(new GridLayout(0,1));
	savePanel.setBorder( BorderFactory.createTitledBorder("Save Options"));
	ButtonGroup gp = new ButtonGroup();
	saveToFile = new JToggleButton("Save ASCII table");
	savePanel.add( saveToFile );
	gp.add( saveToFile );
	saveToClipboard = new JToggleButton("Copy to clipboard");
	savePanel.add( saveToClipboard );
	gp.add( saveToClipboard );
	saveJPEG = new JToggleButton("Save JPEG image");
	savePanel.add( saveJPEG );
	gp.add( saveJPEG );
	savePNG = new JToggleButton("Save PNG image");
	savePanel.add( savePNG );
	gp.add( savePNG );
	saveToExcel = new JToggleButton("Save Excel table");
	savePanel.add( saveToExcel );
	gp.add( saveToExcel );
	print = new JToggleButton("Print");
	savePanel.add( print );
	gp.add( print );
}
 
Example 14
Project: Equella   File: AbstractTreeEditor.java   Source Code and License 6 votes vote down vote up
public AbstractTreeEditor()
{
	tree = createTree();
	tree.addTreeSelectionListener(this);
	tree.setPreferredSize(new Dimension(325, 0));
	tree.setMinimumSize(new Dimension(325, 0));

	// Ensure the root nodes start loading
	tree.loadChildren(tree.getRootNode());

	editArea = new JPanel(new GridLayout(1, 1));

	AppletGuiUtils.removeBordersFromSplitPane(this);
	setOrientation(JSplitPane.HORIZONTAL_SPLIT);
	setContinuousLayout(true);
	setResizeWeight(0.05);

	add(tree, JSplitPane.LEFT);
	add(editArea, JSplitPane.RIGHT);

	noSelectionEditor = new BasicMessageEditor(
		CurrentLocale.get("com.tle.admin.gui.common.tree.nodeeditor.nonodeselected"));

	showTreeNodeEditor(noSelectionEditor);
}
 
Example 15
Project: jmt   File: SectorsTextualPanel.java   Source Code and License 6 votes vote down vote up
private void initComponents() {
	Box vBox = Box.createVerticalBox();
	Box hBox = Box.createHorizontalBox();
	synView = new JTextPane();
	synView.setContentType("text/html");
	synView.setEditable(false);
	synScroll = new JScrollPane(synView);
	synScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	synScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
	vBox.add(Box.createVerticalStrut(30));
	vBox.add(hBox);
	vBox.add(Box.createVerticalStrut(30));
	hBox.add(Box.createHorizontalStrut(20));
	hBox.add(synScroll);
	hBox.add(Box.createHorizontalStrut(20));
	this.setLayout(new GridLayout(1, 1));
	this.add(vBox);
	synView
			.setText("<html><body><center><font face=\"bold\" size=\"3\">Saturation Sectors will be here displayed once you solve the model.</font></center></body></html>");
}
 
Example 16
Project: Equella   File: AdminToolList.java   Source Code and License 6 votes vote down vote up
protected JPanel createButtonsPanel()
{
	List<JButton> buttons = createButtons();

	int count = buttons.size();
	int maxPerRow = 3;

	int cols = count < maxPerRow ? count : maxPerRow;
	int rows = (int) Math.ceil((double) count / (double) maxPerRow);

	JPanel content = new JPanel(new GridLayout(rows, cols));
	for( JButton button : buttons )
	{
		content.add(button);
	}

	return content;
}
 
Example 17
Project: Sunrin2017   File: Swing03.java   Source Code and License 6 votes vote down vote up
public Swing03() {
	setTitle("GridLayout");
	setSize(200, 200);
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	
	Container c = getContentPane();
	c.setLayout(new GridLayout(3, 2));
	c.add(new JButton("Btn1"));
	c.add(new JButton("Btn2"));
	c.add(new JButton("Btn3"));
	c.add(new JButton("Btn4"));
	c.add(new JButton("Btn5"));
	c.add(new JButton("Btn6"));
	
	setVisible(true);
}
 
Example 18
Project: NovelJ   File: SettingsWindow_Windows.java   Source Code and License 6 votes vote down vote up
/**
 * 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 GridLayout(1, 0, 0, 0));

	JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
	frame.getContentPane().add(tabbedPane);

	JScrollPane scrollPane = new JScrollPane();
	tabbedPane.addTab("New tab", null, scrollPane, null);

	JScrollPane scrollPane_1 = new JScrollPane();
	tabbedPane.addTab("New tab", null, scrollPane_1, null);
}
 
Example 19
Project: QN-ACTR-Release   File: KMeanScatterPanelChoose.java   Source Code and License 6 votes vote down vote up
public KMeanScatterPanelChoose(WorkloadAnalysisSession m) {
	super(new BorderLayout());
	setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Scatter Clustering"));

	model = (ModelWorkloadAnalysis) m.getDataModel();
	this.session = m;

	varXCombo = new JComboBox(model.getMatrix().getVariableNames());
	varYCombo = new JComboBox(model.getMatrix().getVariableNames());
	varXCombo.setSelectedIndex(0);
	varYCombo.setSelectedIndex(1);

	JButton vis = new JButton(VIS_SCATTER);

	JPanel combos = new JPanel(new GridLayout(1, 2, 5, 0));
	combos.add(varXCombo);
	combos.add(varYCombo);

	add(combos, BorderLayout.NORTH);
	add(vis, BorderLayout.SOUTH);
}
 
Example 20
Project: trashjam2017   File: AppletGameContainer.java   Source Code and License 5 votes vote down vote up
/**
 * Create a new panel to display the console output
 * 
 * @param e The exception causing the console to be displayed
 */
public ConsolePanel(Exception e) {
   setLayout(new BorderLayout());
   setBackground(Color.black);
   setForeground(Color.white);
   
   Font consoleFont = new Font("Arial", Font.BOLD, 14);
   
   Label slickLabel = new Label("SLICK CONSOLE", Label.CENTER);
   slickLabel.setFont(consoleFont);
   add(slickLabel, BorderLayout.PAGE_START);
   
   StringWriter sw = new StringWriter();
   e.printStackTrace(new PrintWriter(sw));
   
   textArea.setText(sw.toString());
   textArea.setEditable(false);
   add(textArea, BorderLayout.CENTER);
   
   // add a border on both sides of the console
   add(new Panel(), BorderLayout.LINE_START);
   add(new Panel(), BorderLayout.LINE_END);
   
   Panel bottomPanel = new Panel();
   bottomPanel.setLayout(new GridLayout(0, 1));
   Label infoLabel1 = new Label("An error occured while running the applet.", Label.CENTER);
   Label infoLabel2 = new Label("Plese contact support to resolve this issue.", Label.CENTER);
   infoLabel1.setFont(consoleFont);
   infoLabel2.setFont(consoleFont);
   bottomPanel.add(infoLabel1);
   bottomPanel.add(infoLabel2);
   add(bottomPanel, BorderLayout.PAGE_END);
}
 
Example 21
Project: JAddOn   File: JLogin.java   Source Code and License 5 votes vote down vote up
public JLogin(Component c) {
    StaticStandard.setLogin(this);
    dialog.setModal(true);
    dialog.setPreferredSize(new Dimension(400, 150));
    setStandardNames();
    setStandardActionListeners();
    //input_panel.setLayout(new BoxLayout(input_panel, BoxLayout.Y_AXIS));
    input_panel.setLayout(new GridLayout(2, 2));
    pw_panel.setLayout(new BoxLayout(pw_panel, BoxLayout.X_AXIS));
    user_panel.setLayout(new BoxLayout(user_panel, BoxLayout.X_AXIS));
    
    /*
    pw_panel.add(pw_label);
    pw_panel.add(pw);
    user_panel.add(user_label);
    user_panel.add(user);
    */
    
    input_panel.add(user_label);
    input_panel.add(user);
    input_panel.add(pw_label);
    input_panel.add(pw);
    
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setLayout(new BorderLayout());
    
    button_panel.add(login);
    button_panel.add(cancel);
    
    //input_panel.add(user_panel);
    //input_panel.add(pw_panel);
    dialog.add(input_panel, BorderLayout.CENTER);
    dialog.add(button_panel, BorderLayout.SOUTH);
    dialog.pack();
    setRelativeTo(c);
}
 
Example 22
Project: litiengine   File: AssetPanel.java   Source Code and License 5 votes vote down vote up
public AssetPanel() {
  this.gridLayout = new GridLayout(3, COLUMNS);
  this.gridLayout.setVgap(5);
  this.gridLayout.setHgap(5);
  this.setLayout(this.gridLayout);

  this.setBorder(new EmptyBorder(5, 5, 5, 5));
  this.setBackground(Color.DARK_GRAY);
}
 
Example 23
Project: geomapapp   File: ShapeSuite.java   Source Code and License 5 votes vote down vote up
public String getURLString() {
	JTextField txt = new JTextField(60);
	JPanel panel = new JPanel(new GridLayout(2,0));
	panel.add(new JLabel("Enter URL (example: \"http://www.ldeo.columbia.edu/~akm/shape_files/WF2004_T741.shp\")"));
	panel.add(txt);
	int ok = JOptionPane.showConfirmDialog((JFrame)map.getTopLevelAncestor(),
				panel,
				"enter URL",
				JOptionPane.OK_CANCEL_OPTION);
	if( ok==JOptionPane.CANCEL_OPTION) return null;
	return txt.getText();
}
 
Example 24
Project: smile_1.5.0_java7   File: IsoMapDemo.java   Source Code and License 5 votes vote down vote up
@Override
public JComponent learn() {
    JPanel pane = new JPanel(new GridLayout(1, 2));
    double[][] data = dataset[datasetIndex].toArray(new double[dataset[datasetIndex].size()][]);        
    if (data.length > 1000) {
        double[][] x = new double[1000][];
        for (int i = 0; i < 1000; i++)
            x[i] = data[i];
        data = x;
    }

    long clock = System.currentTimeMillis();
    IsoMap isomap = new IsoMap(data, 2, k);
    System.out.format("Learn IsoMap from %d samples in %dms\n", data.length, System.currentTimeMillis() - clock);

    double[][] y = isomap.getCoordinates();

    PlotCanvas plot = new PlotCanvas(Math.colMin(y), Math.colMax(y));
    plot.points(y, 'o', Color.RED);

    int n = y.length;
    Graph graph = isomap.getNearestNeighborGraph();
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            if (graph.hasEdge(i, j)) {
                plot.line(y[i], y[j]);
            }
        }
    }

    plot.setTitle("IsoMap");
    pane.add(plot);

    return pane;
}
 
Example 25
Project: GIFKR   File: SaveFrame.java   Source Code and License 5 votes vote down vote up
public SaveFrame(Animation animation, ProgressDisplay d) {
	super("Save");
	this.animation = animation;
	this.d = d;

	initializeComponents();
	addActionListeners();

	setLayout(new GridBagLayout());
	GridBagConstraints gbc = ViewUtils.createGBC();

	JPanel spinPanel = new JPanel(new GridLayout(3,2));
	spinPanel.add(new JLabel("Width:"));
	spinPanel.add(widthSpinner);
	spinPanel.add(new JLabel("Height:"));
	spinPanel.add(heightSpinner);
	spinPanel.add(frameDelayLabel);
	spinPanel.add(frameDelaySpinner);

	add(spinPanel, gbc);
	gbc.gridy++;


	JLabel noteLabel = new JLabel("Filename conflicts will be resolved automatically");
	noteLabel.setFont(noteLabel.getFont().deriveFont(noteLabel.getFont().getSize() - 2f));
	add(noteLabel, gbc);
	gbc.gridy++;

	add(chooser, gbc);
	pack();
}
 
Example 26
Project: 2D-Elliptic-Mesh-Generator   File: DataSelectPanel.java   Source Code and License 5 votes vote down vote up
public DataSelectPanel(Object[][] data, int dimension, String... parametersNames) {
    _data = data;
    _dimension = dimension;

    _parametersNames = parametersNames;

    if (_dimension > parametersNames.length) {
        throw new IllegalArgumentException("Number of parameters must be > to dimension=" + _dimension);
    }

    setLayout(new GridLayout(_parametersNames.length /*+ 1*/, 1));
    //JPanel title = new JPanel();
    //title.setLayout(new GridLayout(1, 2));
    //title.add(new JLabel("Variable"));
    //title.add(new JLabel("Axis / Parameter"));
    //add(title);

    if (_dimension == 0) {
        buildRows();
    } else if (_dimension == 1) {
        buildRows(0);
    } else if (_dimension == 2) {
        buildRows(0, 1);
    } else if (_dimension == 3) {
        buildRows(0, 1, 2);
    }

    fireSelectedDataChanged("init");
}
 
Example 27
Project: Pixie   File: UserConfigs.java   Source Code and License 5 votes vote down vote up
/**
 * Add a list of radio buttons, representing default, generally used, values
 * for the DPI.
 */
private void addDPIDefaultVals() {
    // set the layout of the panel, based on the amount of elements to be displayed on it
    jPDefaultValues.setLayout(new GridLayout(DPI_VALUES.length, 1));

    for (int index = 0; index < DPI_VALUES.length; index++) {
        String text = DPI_VALUES[index] + " DPI";

        // create a radio button with the given text
        JRadioButton jrbDPIValues = new JRadioButton(text);

        // set its action command to a number for easier usage later (to retrieve the value of the DPI)
        jrbDPIValues.setActionCommand(Integer.toString(DPI_VALUES[index]));

        // add action listener to synchronize the text field with the radio buttons
        jrbDPIValues.addActionListener(e -> jFTFDPIValue.setValue(Integer.parseInt(bgScreenDPIs.getSelection().getActionCommand())));

        // add mouse listener to display the help message when the mouse is on top of the radio buttons
        jrbDPIValues.addMouseListener(new java.awt.event.MouseAdapter() {
            @Override
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jPDefaultValuesMouseEntered(evt);
            }
        });

        jrbDPIValues.setBackground(Color.white);

        // add the radio button to the button group
        bgScreenDPIs.add(jrbDPIValues);

        // add the radio button to the panel displaying it
        jPDefaultValues.add(jrbDPIValues);

        // select the radio button which has the same value as the user preffered one (if any)
        if (DPI_VALUES[index] == userPreferences.getPreferredDPI()) {
            jrbDPIValues.setSelected(true);
            jFTFDPIValue.setValue(DPI_VALUES[index]);
        }
    }
}
 
Example 28
Project: smile_1.5.0_java7   File: IsotonicMDSDemo.java   Source Code and License 5 votes vote down vote up
/**
 * Execute the MDS algorithm and return a swing JComponent representing
 * the clusters.
 */
public JComponent learn() {
    JPanel pane = new JPanel(new GridLayout(1, 2));
    double[][] data = dataset[datasetIndex].toArray(new double[dataset[datasetIndex].size()][]);
    String[] labels = dataset[datasetIndex].toArray(new String[dataset[datasetIndex].size()]);
    if (labels[0] == null) {
        Attribute[] attr = dataset[datasetIndex].attributes();
        labels = new String[attr.length];
        for (int i = 0; i < labels.length; i++) {
            labels[i] = attr[i].getName();
        }
    }

    long clock = System.currentTimeMillis();
    IsotonicMDS isomds = new IsotonicMDS(data, 2);
    System.out.format("Learn Kruskal's Nonmetric MDS (k=2) from %d samples in %dms\n", data.length, System.currentTimeMillis()-clock);

    PlotCanvas plot = ScatterPlot.plot(isomds.getCoordinates(), labels);
    plot.setTitle("Kruskal's Nonmetric MDS (k = 2)");
    pane.add(plot);

    clock = System.currentTimeMillis();
    isomds = new IsotonicMDS(data, 3);
    System.out.format("Learn Kruskal's Nonmetric MDS (k=3) from %d samples in %dms\n", data.length, System.currentTimeMillis()-clock);

    plot = ScatterPlot.plot(isomds.getCoordinates(), labels);
    plot.setTitle("Kruskal's Nonmetric MDS (k = 3)");
    pane.add(plot);

    return pane;
}
 
Example 29
Project: LivroJavaComoProgramar10Edicao   File: TicTacToeClient.java   Source Code and License 5 votes vote down vote up
public TicTacToeClient(String host)
{ 
   ticTacToeHost = host; // set name of server
   displayArea = new JTextArea(4, 30); // set up JTextArea
   displayArea.setEditable(false);
   add(new JScrollPane(displayArea), BorderLayout.SOUTH);

   boardPanel = new JPanel(); // set up panel for squares in board
   boardPanel.setLayout(new GridLayout(3, 3, 0, 0));

   board = new Square[3][3]; // create board

   // loop over the rows in the board
   for (int row = 0; row < board.length; row++) 
   {
      // loop over the columns in the board
      for (int column = 0; column < board[row].length; column++) 
      {
         // create square
         board[row][column] = new Square(" ", row * 3 + column);
         boardPanel.add(board[row][column]); // add square       
      }
   } 

   idField = new JTextField(); // set up textfield
   idField.setEditable(false);
   add(idField, BorderLayout.NORTH);
   
   panel2 = new JPanel(); // set up panel to contain boardPanel
   panel2.add(boardPanel, BorderLayout.CENTER); // add board panel
   add(panel2, BorderLayout.CENTER); // add container panel

   setSize(300, 225); // set size of window
   setVisible(true); // show window

   startClient();
}
 
Example 30
Project: knime-activelearning   File: ButtonList.java   Source Code and License 5 votes vote down vote up
/**
 * Contructor with ClassModel Initializes ClassModel directly via the
 * constructor.
 *
 * @param classModel
 *            the ClassModel
 * @param maxRows
 *            maximum number of buttons per column
 */
public ButtonList(final ClassModel classModel, final int maxRows) {
    super();

    m_maxRows = maxRows;
    m_panels = new ArrayList<>();
    m_buttons = new ArrayList<>();

    m_classModel = classModel;

    setLayout(new GridLayout(1, 3));

    recreateButtonList();
}
 
Example 31
Project: incubator-netbeans   File: PopupPane.java   Source Code and License 5 votes vote down vote up
public PopupPane() {
    listComponents = new HashSet<ListComponent>();
    view = new JPanel();
    GridLayout grid = new GridLayout(0, 1);
    grid.setHgap(0);
    grid.setVgap(0);
    view.setLayout(grid);
    view.setBorder(BorderFactory.createEmptyBorder());
    setName("progresspopup"); //NOI18N
    setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    setViewportView(view);
    setFocusable(true);
    setRequestFocusEnabled(true);

    Action down = new MoveDownAction();
    getActionMap().put("Move-Down", down);
    getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "Move-Down");
    getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "Move-Down");
    
    Action up = new MoveUpAction();
    getActionMap().put("Move-Up", up);
    getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "Move-Up");
    getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "Move-Up");
    Action cancel = new CancelAction();
    getActionMap().put("Cancel-Task", cancel);
    getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "Cancel-Task");
    getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "Cancel-Task");
    
    Action select = new SelectAction();
    getActionMap().put("select-task", select);
    getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "select-task");
    getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "select-task");
    
    
    setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
}
 
Example 32
Project: openjdk-jdk10   File: JSplitPaneOverlapping.java   Source Code and License 5 votes vote down vote up
protected void prepareControls() {
    JFrame frame = new JFrame("SplitPane Mixing");
    JPanel p = new JPanel(new GridLayout());
    p.setPreferredSize(new Dimension(500, 500));
    propagateAWTControls(p);
    sp1 = new JScrollPane(p);

    JButton button = new JButton("JButton");
    button.setBackground(Color.RED);
    button.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            clicked = true;
        }
    });
    sp2 = new JScrollPane(button);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sp1, sp2);
    splitPane.setOneTouchExpandable(false);
    splitPane.setDividerLocation(150);

    splitPane.setPreferredSize(new Dimension(400, 200));

    frame.getContentPane().add(splitPane);
    frame.pack();
    frame.setVisible(true);
}
 
Example 33
Project: ABM-adaptive-tolerance   File: MigFrame.java   Source Code and License 5 votes vote down vote up
public MigFrame(World world, EventManager event, int[] rules)
{
	super("MigScape 3.0");	// creates frame, the constructor uses a string argument for the frame title
	JPanel mainPanel = new JPanel(new GridLayout(5, 5));
	grid = new Grid(world, false);
	gridF = new Grid(world, true);
	ui = new UserControls(grid, event, rules);
	para = new Parameters(event, rules);

	mainPanel.add(grid, BorderLayout.CENTER);
	mainPanel.add(ui, BorderLayout.NORTH);
	mainPanel.add(para, BorderLayout.SOUTH);
	mainPanel.setSize(world.getSizeX()*10, world.getSizeY()*10);
	grid.setSize(new Dimension(world.getSizeX()*10, world.getSizeY()*10));
	gridF.setSize(new Dimension(world.getSizeX()*10, world.getSizeY()*10));
	ui.setSize(new Dimension(world.getSizeY()*10, 50));
	para.setSize(new Dimension(world.getSizeY()*10, 50));
	this.add(grid, BorderLayout.CENTER);
	this.add(gridF, BorderLayout.EAST);
	this.add(ui, BorderLayout.NORTH);
	this.add(para, BorderLayout.SOUTH);
	this.validate();
	setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);  // specifies what happens when user closes the frame. exit_on_close means the program will stop
	grid.setBackground(Color.WHITE);
	gridF.setBackground(Color.WHITE);
	ui.setBackground(Color.WHITE);
	para.setBackground(Color.WHITE);
}
 
Example 34
Project: incubator-netbeans   File: OpenFileAction.java   Source Code and License 5 votes vote down vote up
@Override
public boolean approve(File[] selectedFiles) {
    /* check the files: */
    List<String> errorMsgs = null;
    for (int i = 0; i < selectedFiles.length; i++) {
        String msgPatternRef = null;
        File file = selectedFiles[i];

        if (!file.exists()) {
            msgPatternRef = "MSG_FileDoesNotExist";             //NOI18N
        } else if (file.isDirectory()) {
            msgPatternRef = "MSG_FileIsADirectory";             //NOI18N
        } else if (!file.isFile()) {
            msgPatternRef = "MSG_FileIsNotPlainFile";           //NOI18N
        }
        if (msgPatternRef == null) {
            continue;
        }
        if (errorMsgs == null) {
            errorMsgs = new ArrayList<String>(selectedFiles.length - i);
        }
        errorMsgs.add(NbBundle.getMessage(OpenFileAction.class,
                msgPatternRef, file.getName()));
    }
    if (errorMsgs == null) {
        return true;
    } else {
        JPanel panel = new JPanel(
                new GridLayout(errorMsgs.size(), 0, 0, 2));   //gaps
        for (String errMsg : errorMsgs) {
            panel.add(new JLabel(errMsg));
        }
        DialogDisplayer.getDefault().notify(
                new NotifyDescriptor.Message(
                panel, NotifyDescriptor.WARNING_MESSAGE));
        return false;
    }
}
 
Example 35
Project: Equella   File: NoTopicEditor.java   Source Code and License 5 votes vote down vote up
public NoTopicEditor(String message)
{
	JLabel messageLabel = new JLabel(CurrentLocale.get(getKey("notopic.") + message));
	messageLabel.setHorizontalAlignment(SwingConstants.CENTER);

	setLayout(new GridLayout(1, 1));
	add(messageLabel);
}
 
Example 36
Project: ants   File: FoodView.java   Source Code and License 5 votes vote down vote up
public FoodView() {
	setLayout(new GridLayout(3, 1, 5, 5));
	
	add(textID);
	add(textPositionX);
	add(textPositionY);
}
 
Example 37
Project: rapidminer   File: AverageVectorViewer.java   Source Code and License 5 votes vote down vote up
public AverageVectorViewer(AverageVector vector, IOContainer container) {
	setLayout(new GridLayout(1, 1));
	this.vector = vector;

	JPanel mainPanel = new JPanel();
	GridBagLayout layout = new GridBagLayout();
	mainPanel.setLayout(layout);
	GridBagConstraints c = new GridBagConstraints();
	c.fill = GridBagConstraints.BOTH;
	c.insets = new Insets(11, 11, 11, 11);
	c.gridwidth = GridBagConstraints.REMAINDER;
	c.weightx = 1.0d;
	c.weighty = 0.0d;

	JLabel mainLabel = new JLabel("<html><h2>" + getName() + " (" + vector.size() + ")</h2></html>");
	layout.setConstraints(mainLabel, c);
	mainPanel.add(mainLabel);

	for (int i = 0; i < vector.size(); i++) {
		Averagable avg = vector.getAveragable(i);
		Component visualizationComponent = ResultDisplayTools.createVisualizationComponent(avg, container, "Averagable");
		layout.setConstraints(visualizationComponent, c);
		mainPanel.add(visualizationComponent);

	}
	ExtendedJScrollPane scrollPane = new ExtendedJScrollPane(mainPanel);
	scrollPane.setBorder(null);
	add(scrollPane);
}
 
Example 38
Project: FreeCol   File: NationTypeDetailPanel.java   Source Code and License 5 votes vote down vote up
/**
 * Builds the details panel for the given nation type.
 *
 * @param nationType - the IndianNationType
 * @param panel the panel to use
 */
private void buildIndianNationTypeDetail(IndianNationType nationType,
                                         JPanel panel) {
    List<RandomChoice<UnitType>> skills = nationType.getSkills();

    panel.setLayout(new MigLayout("wrap 2, gapx 20", "", ""));

    JLabel name = Utility.localizedHeaderLabel(nationType, FontLibrary.FontSize.SMALL);
    panel.add(name, "span, align center, wrap 40");

    panel.add(Utility.localizedLabel("colopedia.nationType.aggression"));
    panel.add(Utility.localizedLabel("colopedia.nationType."
            + nationType.getAggression().getKey()));

    panel.add(Utility.localizedLabel("colopedia.nationType.settlementNumber"));
    panel.add(Utility.localizedLabel("colopedia.nationType."
            + nationType.getNumberOfSettlements().getKey()));

    panel.add(Utility.localizedLabel("colopedia.nationType.typeOfSettlements"));
    panel.add(new JLabel(Messages.getName(nationType.getCapitalType()),
        new ImageIcon(getImageLibrary().getSettlementImage(nationType.getCapitalType())),
        SwingConstants.CENTER));

    List<String> regionNames = new ArrayList<>();
    for (String regionName : nationType.getRegions()) {
        regionNames.add(Messages.getName(regionName));
    }
    panel.add(Utility.localizedLabel("colopedia.nationType.regions"));
    panel.add(new JLabel(join(", ", regionNames)));

    panel.add(Utility.localizedLabel("colopedia.nationType.skills"), "top, newline 20");
    GridLayout gridLayout = new GridLayout(0, 2);
    gridLayout.setHgap(10);
    JPanel unitPanel = new JPanel(gridLayout);
    unitPanel.setOpaque(false);
    for (RandomChoice<UnitType> choice : skills) {
        unitPanel.add(getUnitButton(choice.getObject()));
    }
    panel.add(unitPanel);
}
 
Example 39
Project: smile_1.5.0_java7   File: FontChooser.java   Source Code and License 5 votes vote down vote up
private JDialog createDialog(Component parent) {
    Frame frame = parent instanceof Frame ? (Frame) parent
            : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);
    JDialog dialog = new JDialog(frame, getMessage("SelectFont"), true);

    Action okAction = new DialogOKAction(dialog);
    Action cancelAction = new DialogCancelAction(dialog);

    JButton okButton = new JButton(okAction);
    okButton.setFont(DEFAULT_FONT);
    JButton cancelButton = new JButton(cancelAction);
    cancelButton.setFont(DEFAULT_FONT);

    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new GridLayout(2, 1));
    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);
    buttonsPanel.setBorder(BorderFactory.createEmptyBorder(25, 0, 10, 10));

    ActionMap actionMap = buttonsPanel.getActionMap();
    actionMap.put(cancelAction.getValue(Action.DEFAULT), cancelAction);
    actionMap.put(okAction.getValue(Action.DEFAULT), okAction);
    InputMap inputMap = buttonsPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), cancelAction.getValue(Action.DEFAULT));
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), okAction.getValue(Action.DEFAULT));

    JPanel dialogEastPanel = new JPanel();
    dialogEastPanel.setLayout(new BorderLayout());
    dialogEastPanel.add(buttonsPanel, BorderLayout.NORTH);

    dialog.getContentPane().add(this, BorderLayout.CENTER);
    dialog.getContentPane().add(dialogEastPanel, BorderLayout.EAST);
    dialog.pack();
    dialog.setLocationRelativeTo(frame);
    return dialog;
}
 
Example 40
Project: QN-ACTR-Release   File: IterationSelector.java   Source Code and License 5 votes vote down vote up
/**
 * Initialize all gui objects
 */
private void initComponents() {
	setLayout(new BorderLayout());
	JPanel topPanel = new JPanel(new GridLayout(2, 1));
	topPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
	JLabel label = new JLabel("Execution number: ");
	final JSpinner spinner = new JSpinner();
	spinner.setPreferredSize(DIM_SPINNER);
	spinner.setValue(new Integer(1));
	label.setLabelFor(spinner);
	// Pack spinner and its label on top, while description is on the second line
	JPanel tmp = new JPanel();
	tmp.add(label);
	tmp.add(spinner);
	topPanel.add(tmp);
	description.setHorizontalAlignment(SwingConstants.CENTER);
	topPanel.add(description);
	// Adds state change to spinner.
	spinner.addChangeListener(new ChangeListener() {
		public void stateChanged(ChangeEvent e) {
			int i = ((Integer) spinner.getValue()).intValue();
			if (i <= 0) {
				i = 1;
			}
			if (i > model.getWhatIfValues().length) {
				i = model.getWhatIfValues().length;
			}
			select(i - 1);
			spinner.setValue(new Integer(i));
		}
	});

	add(topPanel, BorderLayout.NORTH);
	add(tabber, BorderLayout.CENTER);
	select(0);
}