Java Code Examples for javax.swing.JLabel#setAlignmentX()

The following examples show how to use javax.swing.JLabel#setAlignmentX() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
public StateOfChargeDisplay(MainWindow mw) {
	super();
	this.mw = mw;
	setLayout(new BorderLayout());
	setBorder(BorderFactory.createTitledBorder("SOC"));
	img = new DisplayImage(mw);
	JPanel imgPanel = new JPanel();
	imgPanel.add(img);
	imgPanel.setAlignmentX(Component.CENTER_ALIGNMENT);

	label = new JLabel(LABELSTART + UNKNOWN);
	label.setBorder(BorderFactory.createLineBorder(getBackground(), 20));
	JPanel p = new JPanel();
	p.add(label);
	add(p, BorderLayout.SOUTH);
	label.setAlignmentX(Component.CENTER_ALIGNMENT);

	add(imgPanel, BorderLayout.CENTER);
}
 
Example 2
/**
	 * Constructor .
	 * 
	 * @param desktop
	 *            the main desktop pane.
	 */
	public AnnouncementWindow(MainDesktopPane desktop) {

		// Use JDialog constructor
		super("", false, false, false, false); //$NON-NLS-1$

		this.desktop = desktop;
		// Create the main panel
		JPanel mainPane = new JPanel();
		mainPane.setLayout(new BorderLayout());
//		mainPane.setBorder(new EmptyBorder(0, 0, 0, 0));
		setContentPane(mainPane);

		mainPane.setSize(new Dimension(200, 80));
		announcementLabel = new JLabel(" "); //$NON-NLS-1$
		announcementLabel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
		announcementLabel.setAlignmentX(Component.CENTER_ALIGNMENT);

		mainPane.add(announcementLabel, BorderLayout.CENTER);
		mainPane.setCursor(new Cursor(java.awt.Cursor.WAIT_CURSOR));

	}
 
Example 3
Source Project: javamelody   File: MBeansPanel.java    License: Apache License 2.0 5 votes vote down vote up
private JScrollPane createScrollPane() {
	final JScrollPane scrollPane = new JScrollPane();
	final JPanel panel = new JPanel();
	panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
	panel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
	scrollPane.setViewportView(panel);
	scrollPane.getVerticalScrollBar().setUnitIncrement(20);
	// cette récupération du focus dans le panel du scrollPane permet d'utiliser les flèches hauts et bas
	// pour scroller dès l'affichage du panel
	SwingUtilities.invokeLater(new Runnable() {
		@Override
		public void run() {
			panel.requestFocus();
		}
	});

	panel.setOpaque(false);
	for (final Map.Entry<String, List<MBeanNode>> entry : mbeansByTitle.entrySet()) {
		final String title;
		if (mbeansByTitle.size() == 1) {
			title = getString("MBeans");
		} else {
			title = entry.getKey();
		}
		final List<MBeanNode> mbeans = entry.getValue();
		final JLabel titleLabel = Utilities.createParagraphTitle(title, "mbeans.png");
		titleLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
		panel.add(titleLabel);

		final JPanel treePanel = createDomainTreePanel(mbeans);
		treePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
		treePanel.setBorder(MBeanNodePanel.LEFT_MARGIN_BORDER);
		panel.add(treePanel);
	}
	return scrollPane;
}
 
Example 4
public LabeledProgressBar() {

    setLayout(new OverlayLayout(this));

    label = new JLabel();
    label.setAlignmentX(0.5f);
    label.setFont(label.getFont().deriveFont(11f));
    add(label);

    progressBar = new JProgressBar(0, 100);
    progressBar.setBorderPainted(false);
    add(progressBar);

  }
 
Example 5
Source Project: PacketProxy   File: GUIOption.java    License: Apache License 2.0 5 votes vote down vote up
private JComponent createDescription(String description) throws Exception {
	JLabel label = new JLabel(description);
	label.setForeground(Color.BLACK);
	label.setBackground(Color.WHITE);
	label.setMaximumSize(new Dimension(Short.MAX_VALUE, label.getMinimumSize().height));
	label.setAlignmentX(Component.LEFT_ALIGNMENT);
	return label;
}
 
Example 6
private JPanel createWelcomePanel() {
    JPanel welcomePanel = new JPanel();
    welcomePanel.setLayout(new BoxLayout(welcomePanel, BoxLayout.Y_AXIS));
    JLabel welcomeToLabel = new JLabel(translate("startup.welcometo"));
    welcomeToLabel.setFont(welcomeToLabel.getFont().deriveFont(40));
    welcomeToLabel.setAlignmentX(0.5f);
    JPanel appNamePanel = new JPanel(new FlowLayout());
    JLabel jpLabel = new JLabel("JPEXS ");
    jpLabel.setAlignmentX(0.5f);
    jpLabel.setForeground(new Color(0, 0, 160));
    jpLabel.setFont(new Font("Tahoma", Font.BOLD, 50));
    jpLabel.setHorizontalAlignment(SwingConstants.CENTER);
    appNamePanel.add(jpLabel);

    JLabel ffLabel = new JLabel("Free Flash ");
    ffLabel.setAlignmentX(0.5f);
    ffLabel.setFont(new Font("Tahoma", Font.BOLD, 50));
    ffLabel.setHorizontalAlignment(SwingConstants.CENTER);
    appNamePanel.add(ffLabel);

    JLabel decLabel = new JLabel("Decompiler");
    decLabel.setAlignmentX(0.5f);
    decLabel.setForeground(Color.red);
    decLabel.setFont(new Font("Tahoma", Font.BOLD, 50));
    decLabel.setHorizontalAlignment(SwingConstants.CENTER);
    appNamePanel.add(decLabel);
    appNamePanel.setAlignmentX(0.5f);
    welcomePanel.add(Box.createGlue());
    welcomePanel.add(welcomeToLabel);
    welcomePanel.add(appNamePanel);
    JLabel startLabel = new JLabel(translate("startup.selectopen"));
    startLabel.setAlignmentX(0.5f);
    startLabel.setFont(startLabel.getFont().deriveFont(30));
    welcomePanel.add(startLabel);
    welcomePanel.add(Box.createGlue());
    return welcomePanel;
}
 
Example 7
Source Project: netbeans   File: ExpandableMessage.java    License: Apache License 2.0 5 votes vote down vote up
ExpandableMessage(String topMsgKey,
                  Collection<String> messages,
                  String bottomMsgKey,
                  JButton toggleButton) {
    super(null);
    this.messages = messages;
    this.toggleButton = toggleButton;
    lblTopMsg = new JLabel(getMessage(topMsgKey));
    lblBotMsg = (bottomMsgKey != null)
                ? new JLabel(getMessage(bottomMsgKey))
                : null;

    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

    add(lblTopMsg);
    lblTopMsg.setAlignmentX(LEFT_ALIGNMENT);

    if (lblBotMsg != null) {
        add(makeVerticalStrut(lblTopMsg, lblBotMsg));
        add(lblBotMsg);
        lblBotMsg.setAlignmentX(LEFT_ALIGNMENT);
    }

    Mnemonics.setLocalizedText(toggleButton,
                               getMessage("LBL_ShowMoreInformation")); //NOI18N
    toggleButton.addActionListener(this);
}
 
Example 8
Source Project: jdal   File: PaginatorView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected JComponent buildPanel() {
	pageSizeCombo = new JComboBox(pageSizes);
	pageSizeCombo.addItemListener(new PageSizeComboListener());
	nextPageButton = new JButton(new NextPageAction());
	previousPageButton = new JButton(new PreviousPageAction());
	lastPageButton = new JButton(new LastPageAction());
	firstPageButton = new JButton(new FirstPageAction());
	statusLabel = new JLabel();
	countLabel = new JLabel();
	JLabel numberPagesLabel =  new JLabel(getMessage("PaginatorView.pageSize") +  " ");
	pageSizeCombo.setMaximumSize(new Dimension(70, 30));
	numberPagesLabel.setAlignmentX(Container.RIGHT_ALIGNMENT);
	
	Box box = Box.createHorizontalBox();
	box.setBackground(Color.LIGHT_GRAY);
	box.setOpaque(true);
	box.add(countLabel);
	box.add(Box.createHorizontalStrut( 100 	/*180 + numberPagesLabel.getSize().width */));
	box.add(Box.createHorizontalGlue());
	box.add(firstPageButton);
	box.add(previousPageButton);
	box.add(Box.createHorizontalStrut(5));
	box.add(statusLabel);
	box.add(Box.createHorizontalStrut(5));
	box.add(nextPageButton);
	box.add(lastPageButton);
	box.add(Box.createHorizontalGlue());
	box.add(numberPagesLabel);
	box.add(pageSizeCombo);
	box.add(Box.createHorizontalStrut(30));
	
	// set page size from combo box
	String pageSize = (String) pageSizeCombo.getSelectedItem();
	paginator.setPageSize(parsePageSize(pageSize));
	
	return box;
}
 
Example 9
/**
 * Create the dialog.
 */
public ProgressDialog()
{
	setUndecorated(true);
	setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	setAlwaysOnTop(true);
	setResizable(false);
	Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
	setBounds(screen.width - 450, 0, 450, 200);
	getContentPane().setLayout(
		new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
	
	Component glue = Box.createGlue();
	getContentPane().add(glue);
	
	JLabel lblImage = new JLabel("HookManager");
	lblImage.setFont(new Font("Verdana", Font.BOLD, 40));
	lblImage.setAlignmentX(Component.CENTER_ALIGNMENT);
	lblImage.setHorizontalAlignment(SwingConstants.CENTER);
	getContentPane().add(lblImage);
	{
		lblProgress =
			new JLabel("<html>\r\n<center>\r\n<h1>Updating...</h1>");
		lblProgress.setAlignmentX(Component.CENTER_ALIGNMENT);
		lblProgress.setFont(new Font("Verdana", Font.PLAIN, 16));
		getContentPane().add(lblProgress);
		lblProgress.setHorizontalAlignment(SwingConstants.CENTER);
	}
	
	Component glue_1 = Box.createGlue();
	getContentPane().add(glue_1);
}
 
Example 10
Source Project: FCMFrame   File: MainFrame.java    License: Apache License 2.0 5 votes vote down vote up
public static void createHorizonalHintBox(JPanel parent, JComponent c, JLabel l1) {
	parent.setAlignmentX(Component.LEFT_ALIGNMENT);
	parent.setBounds(15, 10, 100, 30);
	c.setAlignmentX(Component.LEFT_ALIGNMENT);
	
	l1.setAlignmentX(Component.LEFT_ALIGNMENT);
	parent.add(l1);
}
 
Example 11
public OutDirWizardPage () {
   super( PAGE_OUT_DIR, getDescription(), CPSWizardPage.WIZ_TYPE_PRE_INIT );

   setLongDescription( getDescription() );

   setPreferredSize( panelDim );
   setMaximumSize( panelDim );

   JLabel lblOutDir = new JLabel( "<html><body style='width: 300px'>" +
                                  "<b>Select a folder or directory to store all of your crop planning data.</b>" +
                                  "<p><p>If you have already used this program to create crop plans and would like to load that information, " +
                                  "please select the folder or directory which contains your existing data. " +
                                  "(The data files have names that start with \"CPSdb\".)" +
                                  "" );
   lblOutDir.setAlignmentX( Component.CENTER_ALIGNMENT );

   String defaultDirectory = CPSGlobalSettings.getOutputDir();
   flchOutDir = new JFileChooser();
   flchOutDir.setSelectedFile( new File( defaultDirectory ) );
   flchOutDir.setName( SETTING_OUT_DIR );
   flchOutDir.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
   flchOutDir.setMultiSelectionEnabled( false );
   flchOutDir.setControlButtonsAreShown( false );
   flchOutDir.addPropertyChangeListener( new PropertyChangeListener() {

      public void propertyChange ( PropertyChangeEvent evt ) {
         if ( evt.getPropertyName().equals( JFileChooser.SELECTED_FILE_CHANGED_PROPERTY ) ) {
            outDirIsSelected = ( evt.getNewValue() != null ) ? true : false;
            userInputReceived( flchOutDir, evt );
         }
      }
   } ); // new PropChangeListener
   flchOutDir.setPreferredSize( fileDim );
   flchOutDir.setMaximumSize( fileDim );

   add( lblOutDir );
   add( flchOutDir );
}
 
Example 12
Source Project: djl   File: FashionMnistUtils.java    License: Apache License 2.0 4 votes vote down vote up
public Container(String label) {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    JLabel l = new JLabel(label, JLabel.CENTER);
    l.setAlignmentX(Component.CENTER_ALIGNMENT);
    add(l);
}
 
Example 13
/**
 * Make the dialog components
 * @return the GUI components for the dialog
 */
private Component makeDialogComponents()
{
	JPanel dialogPanel = new JPanel();
	dialogPanel.setLayout(new BorderLayout());

	// main panel with a box layout
	JPanel mainPanel = new JPanel();
	mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
	// Label at top
	JLabel introLabel = new JLabel(I18nManager.getText("dialog.learnestimationparams.intro") + ":");
	introLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
	introLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
	mainPanel.add(introLabel);

	// Panel for the calculated results
	_calculatedParamPanel = new ParametersPanel("dialog.estimatetime.results", true);
	_calculatedParamPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
	mainPanel.add(_calculatedParamPanel);
	mainPanel.add(Box.createVerticalStrut(14));

	mainPanel.add(new JLabel(I18nManager.getText("dialog.learnestimationparams.combine") + ":"));
	mainPanel.add(Box.createVerticalStrut(4));
	_weightSlider = new JScrollBar(JScrollBar.HORIZONTAL, 5, 1, 0, 11);
	_weightSlider.addAdjustmentListener(new AdjustmentListener() {
		public void adjustmentValueChanged(AdjustmentEvent inEvent)
		{
			if (!inEvent.getValueIsAdjusting()) {
				updateCombinedLabels(calculateCombinedParameters());
			}
		}
	});
	mainPanel.add(_weightSlider);
	_sliderDescLabel = new JLabel(" ");
	_sliderDescLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
	mainPanel.add(_sliderDescLabel);
	mainPanel.add(Box.createVerticalStrut(12));

	// Results panel
	_combinedParamPanel = new ParametersPanel("dialog.learnestimationparams.combinedresults");
	_combinedParamPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
	mainPanel.add(_combinedParamPanel);

	dialogPanel.add(mainPanel, BorderLayout.NORTH);

	// button panel at bottom
	JPanel buttonPanel = new JPanel();
	buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

	// Combine
	_combineButton = new JButton(I18nManager.getText("button.combine"));
	_combineButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent arg0) {
			combineAndFinish();
		}
	});
	buttonPanel.add(_combineButton);

	// Cancel
	JButton cancelButton = new JButton(I18nManager.getText("button.cancel"));
	cancelButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			_dialog.dispose();
		}
	});
	KeyAdapter escapeListener = new KeyAdapter() {
		public void keyPressed(KeyEvent inE) {
			if (inE.getKeyCode() == KeyEvent.VK_ESCAPE) {_dialog.dispose();}
		}
	};
	_combineButton.addKeyListener(escapeListener);
	cancelButton.addKeyListener(escapeListener);
	buttonPanel.add(cancelButton);
	dialogPanel.add(buttonPanel, BorderLayout.SOUTH);
	return dialogPanel;
}
 
Example 14
public void initializeGui() {

		setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		ButtonGroup group = new ButtonGroup();
		filterRadioButtons = new JRadioButton[MAX_FILTERS];

		for (int i=0; i< MAX_FILTERS; i++) {
			filterRadioButtons[i] = addRadioButton(filterName[i]);
			group.add(filterRadioButtons[i]);
		}
	
		JLabel filler0 = new JLabel("");
		filler0.setMinimumSize(new Dimension(14,14));
		filler0.setMaximumSize(new Dimension(14,14));
		add(filler0);
		lFreq = new JLabel(L_FREQ);
		lFreq.setAlignmentX(Component.LEFT_ALIGNMENT);
		add(lFreq);
		
		freqSlider = createSlider(FREQ_MIN, FREQ_MAX, (int)Config.filterFrequency);
		freqSlider.setMinorTickSpacing(FREQ_STEP);
		
		add(freqSlider);
		
		//JPanel panel1 = new JPanel();
		//add(panel1);
		JLabel filler1 = new JLabel("");
		filler1.setMinimumSize(new Dimension(14,14));
		filler1.setMaximumSize(new Dimension(14,14));
		add(filler1);
		lLength = new JLabel(L_LENGTH);
		lLength.setAlignmentX(Component.LEFT_ALIGNMENT);
		add(lLength);
		
		rcSlider = createSlider(RC_LEN_MIN, RC_LEN_MAX, RC_LEN_MIN);
		wsSlider = createSlider(WS_LEN_MIN, WS_LEN_MAX, WS_LEN_MIN*2);
		//updateSlider();
		add(rcSlider);
		add(wsSlider);
		
		JLabel filler2 = new JLabel("");
		filler2.setMinimumSize(new Dimension(14,44));
		filler2.setMaximumSize(new Dimension(14,44));
		add(filler2);
		/*
		JPanel panel1 = new JPanel();
		add(panel1);
//		panel1.setLayout(new BoxLayout(panel1, BoxLayout.X_AXIS));
		panel1.setLayout(new FlowLayout());
		JLabel lfreq = new JLabel("Cuttoff Freq");
		panel1.add(lfreq);
		JTextField txtFreq = new JTextField();
		panel1.add(txtFreq);
		JPanel panel2 = new JPanel();
		add(panel2);
		//panel2.setLayout(new BoxLayout(panel2, BoxLayout.X_AXIS));
		panel2.setLayout(new FlowLayout());
		JLabel lLength = new JLabel("Length (bits)");
		panel2.add(lLength);
		JTextField txtLength = new JTextField();
		panel2.add(txtLength);
		*/
		
		setFilter();
	}
 
Example 15
public static void buildCard2() {
	JPanel card = new JPanel();
	card.setLayout(new BoxLayout(card, BoxLayout.Y_AXIS));
	JLabel title = new JLabel("Where would you like to dump to?");
	title.setAlignmentX(Component.CENTER_ALIGNMENT);
	title.setBorder(new EmptyBorder(15, 20, 15, 20));
	card.add(title);
	final JFileChooser fc = new JFileChooser();
	fc.setSelectedFile(new File("test2.db"));

	final JButton open = new JButton("Select a SQLite3 File...");
	open.setAlignmentX(Component.CENTER_ALIGNMENT);
	card.add(open);

	final JLabel fnLabel = new JLabel();
	fnLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
	fnLabel.setBorder(new EmptyBorder(15, 20, 15, 20));
	card.add(fnLabel);

	final NextListener nexter = new NextListener() {
		@Override
		public void goNext() {
			cardStack.add(CARD_3);
			cl.show(cards, CARD_3);
		}
		@Override
		public void show() {
			next.setVisible(true);
			finish.setVisible(false);
			next.setEnabled(fc.getSelectedFile() != null);
            file = fc.getSelectedFile();
            if (file == null) {
	            fnLabel.setText("");
            } else {
	            fnLabel.setText(file.getName() + (file.exists() ? "" : " (new)"));
            }
		}
	};

	open.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			int returnVal = fc.showOpenDialog(open);
			if (returnVal == JFileChooser.APPROVE_OPTION) {
			}
			nexter.show();
		}
	});

	cards.add(card, CARD_2);
	nexters.put(CARD_2, nexter);
}
 
Example 16
Source Project: SikuliX1   File: SplashFrame.java    License: MIT License 4 votes vote down vote up
private void init(String[] args) {
  setResizable(false);
  setUndecorated(true);
  pane = getContentPane();

  if ("download".equals(args[0])) {
    pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
    pane.add(new JLabel(" "));
    lbl = new JLabel("");
    lbl.setAlignmentX(CENTER_ALIGNMENT);
    pane.add(lbl);
    pane.add(new JLabel(" "));
    txt = new JLabel("... waiting");
    txt.setAlignmentX(CENTER_ALIGNMENT);
    pane.add(txt);
    fw = 350;
    fh = 80;
  }

  if ("splash".equals(args[0])) {
    pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
    pane.setBackground(Color.yellow);
    int n = args.length;
    String e;
    int l = 0;
    int nlbl = 0;
    for (int i = 1; i < n; i++) {
      e = args[i];
      if (e.length() > l) {
        l = e.length();
      }
      if (e.length() > 1 && e.startsWith("#")) {
        nlbl++;
      }
    }
    JLabel[] lbls = new JLabel[nlbl];
    nlbl = 0;
    for (int i = 1; i < n; i++) {
      e = args[i];
      if (e.startsWith("#")) {
        if (e.length() > 1) {
          lbls[nlbl] = new JLabel(e.substring(1));
          lbls[nlbl].setAlignmentX(CENTER_ALIGNMENT);
          pane.add(lbls[nlbl]);
          nlbl++;
        }
        pane.add(new JSeparator());
      } else {
        pane.add(new JLabel(e));
      }
    }
    fw = 10 + 10*l;
    fh = 10 + n*15 + nlbl*15;
  }

  pack();
  setSize(fw, fh);
  setLocationRelativeTo(null);
  setAlwaysOnTop(true);
  setVisible(true);
}
 
Example 17
Source Project: swift-k   File: CredentialsDialog.java    License: Apache License 2.0 4 votes vote down vote up
public SwingCredentialsDialog(String title, Prompt[] prompts) {
    this.title = title;
    this.prompts = prompts;

    // the main panel
    JPanel main = new JPanel(new BorderLayout());
    titleLabel = new JLabel(title);
    titleLabel.setAlignmentX(0.5f);
    titleLabel.setFont(new Font("SansSerif", Font.BOLD, 16));
    main.add(titleLabel, BorderLayout.NORTH);
    // Labels
    GridBagLayout gbl = new GridBagLayout();
    JPanel lpane = new JPanel(gbl);
    GridBagConstraints gbc = new GridBagConstraints();

    lpane.setBorder(BorderFactory.createEmptyBorder(8, 0, 0, 0));

    labels = new JLabel[prompts.length];
    fields = new JTextComponent[prompts.length];
    browse = new JButton[prompts.length];

    for (int i = 0; i < prompts.length; i++) {
        labels[i] = new JLabel(prompts[i].label);
        labels[i].setFont(new Font("SansSerif", Font.BOLD, 14));
        lpane.add(labels[i]);
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.gridy = i;
        gbc.gridx = 0;
        gbc.weightx = 0.0;
        gbl.setConstraints(labels[i], gbc);

        switch (prompts[i].type) {
            case Prompt.TYPE_TEXT:
                fields[i] = new JTextField();
                break;
            case Prompt.TYPE_HIDDEN_TEXT:
                fields[i] = new JPasswordField();
                break;
            case Prompt.TYPE_FILE:
                fields[i] = new JTextField();
        }
        fields[i].addFocusListener(this);
        fields[i].setSize(fields[i].getPreferredSize().height + 8, 120);
        fields[i].addKeyListener(this);
        if (prompts[i].def != null) {
            fields[i].setText(prompts[i].def);
        }
        lpane.add(fields[i]);
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.gridx = 1;
        gbc.weightx = 1.0;
        gbl.setConstraints(fields[i], gbc);
        if (prompts[i].type == Prompt.TYPE_FILE) {
            browse[i] = new JButton("...");
            browse[i].addActionListener(this);
            lpane.add(browse[i]);
            gbc.gridx = 2;
            gbc.weightx = 0.0;
            gbl.setConstraints(browse[i], gbc);
        }
        if (prompts[i].def == null && focusIndex == -1) {
            focusIndex = i;
        }
    }

    main.add(lpane, BorderLayout.CENTER);
    main.setBorder(BorderFactory.createCompoundBorder(BorderFactory
        .createLineBorder(Color.BLACK, 1), BorderFactory
        .createEmptyBorder(8, 8, 8, 8)));

    dialog = new JFrame();
    dialog.setTitle("SSH " + title);
    dialog.getContentPane().add(main);
    dialog.setSize(Math.max(320, titleLabel.getPreferredSize().width),
        titleLabel.getPreferredSize().height + prompts.length
                * (labels[0].getPreferredSize().height + 8) + 24);
    dialog.setLocationRelativeTo(null);
    dialog.setUndecorated(true);
}
 
Example 18
Source Project: importer-exporter   File: SplashScreen.java    License: Apache License 2.0 4 votes vote down vote up
private void init(int numberOfSteps, int messageX, int messageY, Color messageColor) {
	JPanel content = new JPanel() {
		public boolean isOptimizedDrawingEnabled() {
			return false;
		}
	};
	
	content.setLayout(new OverlayLayout(content));
	content.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
	
	JPanel dynamicContent = new JPanel();
	dynamicContent.setOpaque(false);
	dynamicContent.setLayout(new GridBagLayout());
		
	message = new JLabel();
	message.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12));
	message.setForeground(messageColor);
	
	progressBar = new JProgressBar();
	progressBar.setPreferredSize(new Dimension(icon.getIconWidth(), 18));
	progressBar.setIndeterminate(false);
	progressBar.setMaximum(numberOfSteps);
	progressBar.setVisible(false);
	
	GridBagConstraints c = GuiUtil.setConstraints(0, 0, 1, 1, GridBagConstraints.HORIZONTAL, 5 + messageY, 5 + messageX, 0, 5);
	c.anchor = GridBagConstraints.NORTH;
	dynamicContent.add(message, c);
	
	c = GuiUtil.setConstraints(0, 1, 1, 1, GridBagConstraints.HORIZONTAL, 5, 5, 5, 5);
	c.anchor = GridBagConstraints.SOUTH;
	dynamicContent.add(progressBar, c);
	
	dynamicContent.setAlignmentX(0f);
	dynamicContent.setAlignmentY(0f);
	content.add(dynamicContent);
	
	JLabel image = new JLabel(icon);
	image.setAlignmentX(0f);
	image.setAlignmentY(0f);
	content.add(image);
	
	add(content, BorderLayout.CENTER);
	
	// center on screen
	Toolkit t = Toolkit.getDefaultToolkit();
	Insets frame_insets = t.getScreenInsets(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration());
	int frame_insets_x = frame_insets.left + frame_insets.right;
	int frame_insets_y = frame_insets.bottom + frame_insets.top;
	
	Dimension dim = t.getScreenSize();
	int x = (dim.width - icon.getIconWidth() - frame_insets_x) / 2;
	int y = (dim.height - icon.getIconHeight() - frame_insets_y) / 2;		
	setMinimumSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));
	setLocation(x, y);
	setAlwaysOnTop(true);
}
 
Example 19
@SuppressWarnings("unchecked")
public DeobfuscationDialog() {
    setDefaultCloseOperation(HIDE_ON_CLOSE);
    setSize(new Dimension(330, 270));
    setTitle(translate("dialog.title"));
    Container cp = getContentPane();
    cp.setLayout(new BoxLayout(cp, BoxLayout.Y_AXIS));
    codeProcessingLevel = new JSlider(JSlider.VERTICAL, 1, 3, 3);
    codeProcessingLevel.setMajorTickSpacing(1);
    codeProcessingLevel.setPaintTicks(true);
    codeProcessingLevel.setMinorTickSpacing(1);
    codeProcessingLevel.setSnapToTicks(true);
    JLabel lab1 = new JLabel(translate("deobfuscation.level"));
    //lab1.setBounds(30, 0, getWidth() - 60, 25);
    lab1.setAlignmentX(0.5f);
    cp.add(lab1);
    Hashtable<Integer, JLabel> labelTable = new Hashtable<>();
    //labelTable.put(LEVEL_NONE, new JLabel("None"));

    labelTable.put(DeobfuscationLevel.LEVEL_REMOVE_DEAD_CODE.getLevel(), new JLabel(translate("deobfuscation.removedeadcode")));
    labelTable.put(DeobfuscationLevel.LEVEL_REMOVE_TRAPS.getLevel(), new JLabel(translate("deobfuscation.removetraps")));
    labelTable.put(DeobfuscationLevel.LEVEL_RESTORE_CONTROL_FLOW.getLevel(), new JLabel(translate("deobfuscation.restorecontrolflow")));
    codeProcessingLevel.setLabelTable(labelTable);

    codeProcessingLevel.setPaintLabels(true);
    codeProcessingLevel.setAlignmentX(Component.CENTER_ALIGNMENT);
    //codeProcessingLevel.setSize(300, 200);

    //codeProcessingLevel.setBounds(30, 25, getWidth() - 60, 125);
    codeProcessingLevel.setAlignmentX(0.5f);
    add(codeProcessingLevel);
    //processAllCheckbox.setBounds(50, 150, getWidth() - 100, 25);
    processAllCheckbox.setAlignmentX(0.5f);
    add(processAllCheckbox);

    processAllCheckbox.setSelected(true);

    JButton cancelButton = new JButton(translate("button.cancel"));
    cancelButton.addActionListener(this::cancelButtonActionPerformed);
    JButton okButton = new JButton(translate("button.ok"));
    okButton.addActionListener(this::okButtonActionPerformed);

    JPanel buttonsPanel = new JPanel(new FlowLayout());
    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);
    buttonsPanel.setAlignmentX(0.5f);
    cp.add(buttonsPanel);

    setModal(true);
    View.centerScreen(this);
    setIconImage(View.loadImage("deobfuscate16"));
}
 
Example 20
/**
 * Init login screen
 */
private void initLoginUI() {
	// Main panel
	JPanel mpLoginOwner = new JPanel(new BorderLayout());
	this.getContentPane().add(mpLoginOwner, SCREENCARD_NAMES[SCREENCARD_LOGIN]);
	JPanel mpLogin = new JPanel();
	mpLogin.setLayout(new BoxLayout(mpLogin, BoxLayout.Y_AXIS));
	mpLoginOwner.add(mpLogin, BorderLayout.NORTH);

	// * Login Message label
	labelLoginMessage = new JLabel(getUIText("Login_Message_Default"));
	labelLoginMessage.setAlignmentX(0f);
	mpLogin.add(labelLoginMessage);

	// * Server panel
	JPanel spServer = new JPanel(new BorderLayout());
	spServer.setAlignmentX(0f);
	mpLogin.add(spServer);

	// ** Server label
	JLabel lServer = new JLabel(getUIText("Login_Server"));
	spServer.add(lServer, BorderLayout.WEST);

	// ** Server textbox
	txtfldServer = new JTextField(30);
	txtfldServer.setText(propConfig.getProperty("login.server", ""));
	txtfldServer.setComponentPopupMenu(new TextComponentPopupMenu(txtfldServer));
	spServer.add(txtfldServer, BorderLayout.EAST);

	// * Username panel
	JPanel spUsername = new JPanel(new BorderLayout());
	spUsername.setAlignmentX(0f);
	mpLogin.add(spUsername);

	// ** Username label
	JLabel lUsername = new JLabel(getUIText("Login_Username"));
	spUsername.add(lUsername, BorderLayout.WEST);

	// ** Username textbox
	txtfldUsername = new JTextField(30);
	txtfldUsername.setText(propConfig.getProperty("login.username", ""));
	txtfldUsername.setComponentPopupMenu(new TextComponentPopupMenu(txtfldUsername));
	spUsername.add(txtfldUsername, BorderLayout.EAST);

	// * Password panel
	JPanel spPassword = new JPanel(new BorderLayout());
	spPassword.setAlignmentX(0f);
	mpLogin.add(spPassword);

	// ** Password label
	JLabel lPassword = new JLabel(getUIText("Login_Password"));
	spPassword.add(lPassword, BorderLayout.WEST);

	// ** Password textbox
	passfldPassword = new JPasswordField(30);
	String strPassword = propConfig.getProperty("login.password", "");
	if(strPassword.length() > 0) {
		passfldPassword.setText(NetUtil.decompressString(strPassword));
	}
	passfldPassword.setComponentPopupMenu(new TextComponentPopupMenu(passfldPassword));
	spPassword.add(passfldPassword, BorderLayout.EAST);

	// * Remember Username checkbox
	chkboxRememberUsername = new JCheckBox(getUIText("Login_RememberUsername"));
	chkboxRememberUsername.setSelected(propConfig.getProperty("login.rememberUsername", false));
	chkboxRememberUsername.setAlignmentX(0f);
	mpLogin.add(chkboxRememberUsername);

	// * Remember Password checkbox
	chkboxRememberPassword = new JCheckBox(getUIText("Login_RememberPassword"));
	chkboxRememberPassword.setSelected(propConfig.getProperty("login.rememberPassword", false));
	chkboxRememberPassword.setAlignmentX(0f);
	mpLogin.add(chkboxRememberPassword);

	// * Buttons panel
	JPanel spButtons = new JPanel();
	spButtons.setLayout(new BoxLayout(spButtons, BoxLayout.X_AXIS));
	spButtons.setAlignmentX(0f);
	mpLogin.add(spButtons);

	// ** Login button
	btnLogin = new JButton(getUIText("Login_Login"));
	btnLogin.setMnemonic('L');
	btnLogin.setMaximumSize(new Dimension(Short.MAX_VALUE, btnLogin.getMaximumSize().height));
	btnLogin.setActionCommand("Login_Login");
	btnLogin.addActionListener(this);
	spButtons.add(btnLogin);

	// ** Quit button
	JButton btnQuit = new JButton(getUIText("Login_Quit"));
	btnQuit.setMnemonic('Q');
	btnQuit.setMaximumSize(new Dimension(Short.MAX_VALUE, btnQuit.getMaximumSize().height));
	btnQuit.setActionCommand("Login_Quit");
	btnQuit.addActionListener(this);
	spButtons.add(btnQuit);
}