Java Code Examples for javax.swing.JProgressBar#setVisible()

The following examples show how to use javax.swing.JProgressBar#setVisible() . 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 check out the related API usage on the sidebar.
Example 1
Source File: AutoUpgrade.java    From netbeans with Apache License 2.0 8 votes vote down vote up
private static boolean showUpgradeDialog (final File source, String note) {
       Util.setDefaultLookAndFeel();

JPanel panel = new JPanel(new BorderLayout());
panel.add(new AutoUpgradePanel (source.getAbsolutePath (), note), BorderLayout.CENTER);
JProgressBar progressBar = new JProgressBar(0, 100);
progressBar.setValue(0);
progressBar.setStringPainted(true);
progressBar.setIndeterminate(true);
panel.add(progressBar, BorderLayout.SOUTH);
progressBar.setVisible(false);

JButton bYES = new JButton("Yes");
bYES.setMnemonic(KeyEvent.VK_Y);
JButton bNO = new JButton("No");
bNO.setMnemonic(KeyEvent.VK_N);
JButton[] options = new JButton[] {bYES, bNO};
       JOptionPane p = new JOptionPane (panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, options, bYES);
       JDialog d = Util.createJOptionProgressDialog(p, NbBundle.getMessage (AutoUpgrade.class, "MSG_Confirmation_Title"), source, progressBar);
       d.setVisible (true);

       return new Integer (JOptionPane.YES_OPTION).equals (p.getValue ());
   }
 
Example 2
Source File: ProgressBarMemoryLeakTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void showUI(){
  sFrame = new JFrame();

  JProgressBar progressBar = new JProgressBar();
  progressBar.setVisible(false);
  progressBar.setIndeterminate(false);
  progressBar.setIndeterminate(true);
  progressBar.setIndeterminate(false);
  progressBar.setValue(10);
  progressBar.setString("Progress");

  sFrame.add(progressBar);

  sProgressBar = new WeakReference<>(progressBar);

  sFrame.setSize(200,200);
  sFrame.setVisible(true);
}
 
Example 3
Source File: DemoTheatreAppImproved.java    From arcgis-runtime-demo-java with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a progress bar.
 * 
 * @param parent progress bar's parent. The horizontal axis of the progress bar will be center-aligned to the parent.
 * @return a progress bar.
 */
private static JProgressBar createProgressBar(final JComponent parent) {
  final JProgressBar progressBar = new JProgressBar();
  progressBar.setSize(260, 20);
  parent.addComponentListener(new ComponentAdapter() {
    @Override
    public void componentResized(ComponentEvent e) {
      progressBar.setLocation(
        parent.getWidth() / 2 - progressBar.getWidth() / 2,
        parent.getHeight() - progressBar.getHeight() - 20);
    }
  });
  progressBar.setStringPainted(true);
  progressBar.setIndeterminate(true);
  progressBar.setVisible(false);
  return progressBar;
}
 
Example 4
Source File: DemoTheatreApp.java    From arcgis-runtime-demo-java with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a progress bar.
 * 
 * @param parent progress bar's parent. The horizontal axis of the progress bar will be center-aligned to the parent.
 * @return a progress bar.
 */
private static JProgressBar createProgressBar(final JComponent parent) {
  final JProgressBar progressBar = new JProgressBar();
  progressBar.setSize(260, 20);
  parent.addComponentListener(new ComponentAdapter() {
    @Override
    public void componentResized(ComponentEvent e) {
      progressBar.setLocation(
        parent.getWidth() / 2 - progressBar.getWidth() / 2,
        parent.getHeight() - progressBar.getHeight() - 20);
    }
  });
  progressBar.setStringPainted(true);
  progressBar.setIndeterminate(true);
  progressBar.setVisible(false);
  return progressBar;
}
 
Example 5
Source File: ProgressWindow.java    From pcap-burp with GNU Affero General Public License v3.0 6 votes vote down vote up
public ProgressWindow(JFrame parent, String title, String message) {
	super(parent, title, true);
	if (parent != null) {
		Dimension parentSize = parent.getSize();
		Point p = parent.getLocation();
		setLocation(p.x + parentSize.width / 4, p.y + parentSize.height / 4);
	}
	JPanel messagePane = new JPanel();
	label = new JLabel(message);
	messagePane.add(label);
	getContentPane().add(messagePane);

	JPanel progressPane = new JPanel();
	progressBar = new JProgressBar(0, 100);
	progressBar.setIndeterminate(true);
	progressBar.setPreferredSize(new Dimension(250, 20));
	progressBar.setVisible(true);
	progressPane.add(progressBar);

	getContentPane().add(progressPane, BorderLayout.SOUTH);
	setDefaultCloseOperation(DISPOSE_ON_CLOSE);
	pack();
}
 
Example 6
Source File: ProgressBarMemoryLeakTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void showUI(){
  sFrame = new JFrame();

  JProgressBar progressBar = new JProgressBar();
  progressBar.setVisible(false);
  progressBar.setIndeterminate(false);
  progressBar.setIndeterminate(true);
  progressBar.setIndeterminate(false);
  progressBar.setValue(10);
  progressBar.setString("Progress");

  sFrame.add(progressBar);

  sProgressBar = new WeakReference<>(progressBar);

  sFrame.setSize(200,200);
  sFrame.setVisible(true);
}
 
Example 7
Source File: ProgressBarMemoryLeakTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void showUI(){
  sFrame = new JFrame();

  JProgressBar progressBar = new JProgressBar();
  progressBar.setVisible(false);
  progressBar.setIndeterminate(false);
  progressBar.setIndeterminate(true);
  progressBar.setIndeterminate(false);
  progressBar.setValue(10);
  progressBar.setString("Progress");

  sFrame.add(progressBar);

  sProgressBar = new WeakReference<>(progressBar);

  sFrame.setSize(200,200);
  sFrame.setVisible(true);
}
 
Example 8
Source File: ProgressBarMemoryLeakTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void showUI(){
  sFrame = new JFrame();

  JProgressBar progressBar = new JProgressBar();
  progressBar.setVisible(false);
  progressBar.setIndeterminate(false);
  progressBar.setIndeterminate(true);
  progressBar.setIndeterminate(false);
  progressBar.setValue(10);
  progressBar.setString("Progress");

  sFrame.add(progressBar);

  sProgressBar = new WeakReference<>(progressBar);

  sFrame.setSize(200,200);
  sFrame.setVisible(true);
}
 
Example 9
Source File: ProgressBarMemoryLeakTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private static void showUI(){
  sFrame = new JFrame();

  JProgressBar progressBar = new JProgressBar();
  progressBar.setVisible(false);
  progressBar.setIndeterminate(false);
  progressBar.setIndeterminate(true);
  progressBar.setIndeterminate(false);
  progressBar.setValue(10);
  progressBar.setString("Progress");

  sFrame.add(progressBar);

  sProgressBar = new WeakReference<>(progressBar);

  sFrame.setSize(200,200);
  sFrame.setVisible(true);
}
 
Example 10
Source File: ProgressBarMemoryLeakTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void showUI(){
  sFrame = new JFrame();

  JProgressBar progressBar = new JProgressBar();
  progressBar.setVisible(false);
  progressBar.setIndeterminate(false);
  progressBar.setIndeterminate(true);
  progressBar.setIndeterminate(false);
  progressBar.setValue(10);
  progressBar.setString("Progress");

  sFrame.add(progressBar);

  sProgressBar = new WeakReference<>(progressBar);

  sFrame.setSize(200,200);
  sFrame.setVisible(true);
}
 
Example 11
Source File: ProgressBarMemoryLeakTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void showUI(){
  sFrame = new JFrame();

  JProgressBar progressBar = new JProgressBar();
  progressBar.setVisible(false);
  progressBar.setIndeterminate(false);
  progressBar.setIndeterminate(true);
  progressBar.setIndeterminate(false);
  progressBar.setValue(10);
  progressBar.setString("Progress");

  sFrame.add(progressBar);

  sProgressBar = new WeakReference<>(progressBar);

  sFrame.setSize(200,200);
  sFrame.setVisible(true);
}
 
Example 12
Source File: CheckinForm.java    From dummydroid with Apache License 2.0 5 votes vote down vote up
public CheckinForm(NavigateAction forward, NavigateAction backward) {
	super(forward, backward);

	result = new HypertextPane("");
	result.setPreferredSize(new Dimension(300, 200));
	result.setOpaque(false);
	progress = new JProgressBar();
	progress.setIndeterminate(true);
	progress.setVisible(false);

	setLayout(new BorderLayout());
	add(result, BorderLayout.CENTER);
	add(progress, BorderLayout.NORTH);
}
 
Example 13
Source File: StatusPanel.java    From jeveassets with GNU General Public License v2.0 5 votes vote down vote up
public Progress(UpdateType updateType, ProgressControl progressShow) {
	this.updateType = updateType;
	this.progressControl = progressShow;
	switch (updateType) {
		case STRUCTURE:
			text = DialoguesStructure.get().updateTitle();
			break;
		case PUBLIC_MARKET_ORDERS:
			text = TabsOrders.get().updateTitle();
			break;
		default:
			text = "";
	}
	jProgress = new JProgressBar(0, 100);
	Dimension size = new Dimension(Program.getButtonsWidth() * 2, Program.getButtonsHeight());
	jProgress.setMinimumSize(size);
	jProgress.setPreferredSize(size);
	jProgress.setMaximumSize(size);
	jProgress.setVisible(false);
	
	jProgress.setStringPainted(true);
	if (progressShow.isAuto()) {
		jProgress.setString(text);
	} else {
		jProgress.setString(GuiFrame.get().clickToShow(text));
		jProgress.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				progressShow.show();
			}
		});
	}
}
 
Example 14
Source File: BaselineCorrectorSetupDialog.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
private void addProgessBar() {
  // Add progress bar
  progressBar = new JProgressBar();
  progressBar.setValue(25);
  progressBar.setStringPainted(true);
  Border border =
      BorderFactory.createTitledBorder("Processing...     <Press \"ESC\" to cancel>    ");
  progressBar.setBorder(border);
  this.dialog.add(progressBar, BorderLayout.NORTH);
  // this.dialog.repaint();
  progressBar.setVisible(true);
  this.dialog.pack();
}
 
Example 15
Source File: RocPlot.java    From rtg-tools with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Creates a new swing plot.
 * @param precisionRecall true defaults to precision recall graph
 * @param interpolate if true, enable curve interpolation
 */
RocPlot(boolean precisionRecall, boolean interpolate) {
  mInterpolate = interpolate;
  mMainPanel = new JPanel();
  UIManager.put("FileChooser.readOnly", Boolean.TRUE);
  mFileChooser = new JFileChooser();
  final Action details = mFileChooser.getActionMap().get("viewTypeDetails");
  if (details != null) {
    details.actionPerformed(null);
  }
  mFileChooser.setMultiSelectionEnabled(true);
  mFileChooser.setFileFilter(new RocFileFilter());
  mZoomPP = new RocZoomPlotPanel();
  mZoomPP.setOriginIsMin(true);
  mZoomPP.setTextAntialiasing(true);
  mProgressBar = new JProgressBar(-1, -1);
  mProgressBar.setVisible(true);
  mProgressBar.setStringPainted(true);
  mProgressBar.setIndeterminate(true);
  mStatusLabel = new JLabel();
  mPopup = new JPopupMenu();
  mRocLinesPanel = new RocLinesPanel(this);
  mScrollPane = new JScrollPane(mRocLinesPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  mScrollPane.setWheelScrollingEnabled(true);
  mLineWidthSlider = new JSlider(JSlider.HORIZONTAL, LINE_WIDTH_MIN, LINE_WIDTH_MAX, 1);
  mScoreCB = new JCheckBox("Show Scores");
  mScoreCB.setSelected(true);
  mSelectAllCB = new JCheckBox("Select / Deselect all");
  mTitleEntry = new JTextField("ROC");
  mTitleEntry.setMaximumSize(new Dimension(Integer.MAX_VALUE, mTitleEntry.getPreferredSize().height));
  mOpenButton = new JButton("Open...");
  mOpenButton.setToolTipText("Add a new curve from a file");
  mCommandButton = new JButton("Cmd...");
  mCommandButton.setToolTipText("Send the equivalent rocplot command-line to the terminal");
  final ImageIcon icon = createImageIcon("com/rtg/graph/resources/realtimegenomics_logo.png", "RTG Logo");
  mIconLabel = new JLabel(icon);
  mIconLabel.setBackground(new Color(16, 159, 205));
  mIconLabel.setForeground(Color.WHITE);
  mIconLabel.setOpaque(true);
  mIconLabel.setFont(new Font("Arial", Font.BOLD, 24));
  mIconLabel.setHorizontalAlignment(JLabel.LEFT);
  mIconLabel.setIconTextGap(50);
  if (icon != null) {
    mIconLabel.setMinimumSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));
  }
  mGraphType = new JComboBox<>(new String[] {ROC_PLOT, PRECISION_SENSITIVITY});
  mGraphType.setSelectedItem(precisionRecall ? PRECISION_SENSITIVITY : ROC_PLOT);
  configureUI();
}
 
Example 16
Source File: Main.java    From blog with Apache License 2.0 4 votes vote down vote up
public void createAndShowUI() {
	BoundedRangeModel progressModel = new DefaultBoundedRangeModel();
	BoundedRangeProgress progressAdapter = new BoundedRangeProgress(progressModel);
	Document resultDocument = new PlainDocument();

	ComponentVisibility progressBarVisibility = new ComponentVisibility("enabled", false);
	progressBarVisibility.setInvisibleDelay(1, TimeUnit.SECONDS);

	ProgressCancelAction cancelAction = new ProgressCancelAction();
	cancelAction.putValue(Action.NAME, "Cancel");

	ProgressSimulationAction progressAction = new ProgressSimulationAction();
	progressAction.addProgressAware(progressAdapter);
	progressAction.addProgressAware(cancelAction);
	progressAction.addPropertyChangeListener(progressBarVisibility);
	progressAction.putValue(Action.NAME, "Start");
	progressAction.setResultDocument(resultDocument);

	JFrame mainFrame = new JFrame("Progress Object Pattern with Java Swing");
	mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
	mainFrame.setMinimumSize(new Dimension(600, 120));

	JProgressBar progressBar = new JProgressBar(progressModel);
	progressBar.setVisible(false);
	progressBar.setStringPainted(true);
	progressBarVisibility.setComponent(progressBar);

	JButton startProgressButton = new JButton(progressAction);
	JButton cancelButton = new JButton(cancelAction);
	JTextField resultTextField = new JTextField(40);
	resultTextField.setEditable(false);
	resultTextField.setDocument(resultDocument);

	JPanel mainPanel = new JPanel();
	mainPanel.add(startProgressButton);
	mainPanel.add(cancelButton);
	mainPanel.add(resultTextField);

	Container contentPane = mainFrame.getContentPane();
	contentPane.add(mainPanel);
	contentPane.add(progressBar, BorderLayout.SOUTH);

	mainFrame.pack();
	mainFrame.setLocationRelativeTo(null);
	mainFrame.setVisible(true);
}
 
Example 17
Source File: DiscoMixer.java    From aurous-app with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
	discoFrame = new JFrame();
	discoFrame.setTitle("Disco Mixer");
	discoFrame.setIconImage(Toolkit.getDefaultToolkit().getImage(
			DiscoMixer.class.getResource("/resources/aurouslogo.png")));
	discoFrame.setType(Type.UTILITY);
	discoFrame.setResizable(false);
	discoFrame.setBounds(100, 100, 606, 239);
	discoFrame
	.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
	discoFrame.getContentPane().setLayout(null);
	discoFrame.addWindowListener(new java.awt.event.WindowAdapter() {
		@Override
		public void windowClosing(
				final java.awt.event.WindowEvent windowEvent) {
			final int confirm = JOptionPane.showOptionDialog(discoFrame,
					"Are You Sure You Want to Close Disco Mixer?",
					"Exit Confirmation", JOptionPane.YES_NO_OPTION,
					JOptionPane.QUESTION_MESSAGE, null, null, null);
			if (confirm == 0) {
				Playlist.getPlaylist().discoOpen = false;
				discoFrame.dispose();
			}

		}
	});

	final JLabel logoLabel = new JLabel("");
	logoLabel.setHorizontalAlignment(SwingConstants.CENTER);
	logoLabel.setIcon(new ImageIcon(DiscoMixer.class
			.getResource("/resources/fmw.png")));
	logoLabel.setBounds(10, 0, 580, 70);
	discoFrame.getContentPane().add(logoLabel);

	discoProgressBar = new JProgressBar();
	discoProgressBar.setStringPainted(true);
	discoProgressBar.setBounds(113, 119, 380, 49);
	discoProgressBar.setVisible(false);
	discoFrame.getContentPane().add(discoProgressBar);

	queryField = new JTextField();
	queryField.setFont(new Font("Segoe UI", Font.PLAIN, 20));
	queryField.setHorizontalAlignment(SwingConstants.CENTER);
	queryField.setBounds(113, 119, 380, 44);
	discoFrame.getContentPane().add(queryField);
	queryField.setColumns(10);

	final JLabel instructionsLabel = new JLabel(
			"Enter an Artist, Song or Choose from the Top 100!");
	instructionsLabel.setFont(new Font("Segoe UI", Font.PLAIN, 20));
	instructionsLabel.setHorizontalAlignment(SwingConstants.CENTER);
	instructionsLabel.setBounds(23, 81, 541, 27);
	discoFrame.getContentPane().add(instructionsLabel);

	discoBuildButton = new JButton("Disco!");
	discoBuildButton.addActionListener(e -> {
		if (!queryField.getText().trim().isEmpty()) {
			discoProgressBar.setVisible(true);
			YouTubeDiscoUtils.buildDiscoPlayList(queryField.getText());
		} else {
			JOptionPane.showMessageDialog(discoFrame,
					"Please enter search query", "Error",
					JOptionPane.ERROR_MESSAGE);
			return;
		}
	});
	discoBuildButton.setForeground(Color.BLACK);
	discoBuildButton.setBounds(197, 174, 100, 26);
	discoFrame.getContentPane().add(discoBuildButton);

	top100Button = new JButton("Top Hits!");
	top100Button.addActionListener(e -> {
		discoProgressBar.setVisible(true);
		YouTubeDiscoUtils.buildTopPlayList();
	});
	top100Button.setForeground(Color.BLACK);
	top100Button.setBounds(307, 174, 100, 26);
	discoFrame.getContentPane().add(top100Button);
	Playlist.getPlaylist().discoOpen = true;
	final GhostText ghostText = new GhostText("Ghost B.C.", queryField);
	ghostText.setHorizontalAlignment(SwingConstants.CENTER);
	discoFrame.setLocationRelativeTo(UISession.getPresenter().jfxPanel);
}
 
Example 18
Source File: MainWindow.java    From Luyten with Apache License 2.0 4 votes vote down vote up
public MainWindow(File fileFromCommandLine) {
	configSaver = ConfigSaver.getLoadedInstance();
	windowPosition = configSaver.getMainWindowPosition();
	luytenPrefs = configSaver.getLuytenPreferences();
	
	mainMenuBar = new MainMenuBar(this);
	this.setJMenuBar(mainMenuBar);

	this.adjustWindowPositionBySavedState();
	this.setHideFindBoxOnMainWindowFocus();
	this.setShowFindAllBoxOnMainWindowFocus();
	this.setQuitOnWindowClosing();
	this.setTitle(TITLE);
	this.setIconImage(new ImageIcon(
			Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/resources/Luyten.png"))).getImage());

	JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
	label = new JLabel();
	label.setHorizontalAlignment(JLabel.LEFT);
	panel1.setBorder(new BevelBorder(BevelBorder.LOWERED));
	panel1.setPreferredSize(new Dimension(this.getWidth() / 2, 20));
	panel1.add(label);

	JPanel panel2 = new JPanel(new FlowLayout(FlowLayout.RIGHT));
	bar = new JProgressBar();

	bar.setStringPainted(true);
	bar.setOpaque(false);
	bar.setVisible(false);
	panel2.setPreferredSize(new Dimension(this.getWidth() / 3, 20));
	panel2.add(bar);

	model = new Model(this);
	this.getContentPane().add(model);

	JSplitPane spt = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panel1, panel2) {
		private static final long serialVersionUID = 2189946972124687305L;
		private final int location = 400;

		{
			setDividerLocation(location);
		}

		@Override
		public int getDividerLocation() {
			return location;
		}

		@Override
		public int getLastDividerLocation() {
			return location;
		}
	};
	spt.setBorder(new BevelBorder(BevelBorder.LOWERED));
	spt.setPreferredSize(new Dimension(this.getWidth(), 24));
	this.add(spt, BorderLayout.SOUTH);
	if (fileFromCommandLine != null) {
		model.loadFile(fileFromCommandLine);
	}

	try {
		DropTarget dt = new DropTarget();
		dt.addDropTargetListener(new DropListener(this));
		this.setDropTarget(dt);
	} catch (Exception e) {
		Luyten.showExceptionDialog("Exception!", e);
	}

	fileDialog = new FileDialog(this);
	fileSaver = new FileSaver(bar, label);

	this.setExitOnEscWhenEnabled(model);

	if (fileFromCommandLine == null || fileFromCommandLine.getName().toLowerCase().endsWith(".jar")
			|| fileFromCommandLine.getName().toLowerCase().endsWith(".zip")) {
		model.startWarmUpThread();
	}
	
	if(RecentFiles.load() > 0) mainMenuBar.updateRecentFiles();
}
 
Example 19
Source File: SplashScreen.java    From importer-exporter with 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 20
Source File: ReqView.java    From rest-client with Apache License 2.0 4 votes vote down vote up
/**
* 
* @Title: init 
* @Description: Component Initialization 
* @param
* @return void 
* @throws
 */
private void init()
{
    this.setLayout(new BorderLayout(RESTConst.BORDER_WIDTH, RESTConst.BORDER_WIDTH));
    this.setBorder(BorderFactory.createEmptyBorder(RESTConst.BORDER_WIDTH, RESTConst.BORDER_WIDTH, RESTConst.BORDER_WIDTH, RESTConst.BORDER_WIDTH));

    pnlUrl = new Panel();
    pnlUrl.setLayout(new BorderLayout(RESTConst.BORDER_WIDTH, 0));
    
    iconStart = UIUtil.getIcon(RESTConst.ICON_START);
    iconStop = UIUtil.getIcon(RESTConst.ICON_STOP);

    btnStart = new JButton(iconStart);
    btnStart.setName(RESTConst.START);
    btnStart.setToolTipText(RESTConst.START);
    btnStart.addActionListener(this);

    cbMtd = new JComboBox<HttpMethod>(HttpMethod.values());
    cbMtd.setToolTipText(RESTConst.METHOD);
    cbMtd.addActionListener(this);
    
    cbUrl = new JComboBox<String>();
    cbUrl.setEditable(true);
    cbUrl.setToolTipText(RESTConst.URL);
    cbUrl.requestFocus();
    
    pnlUrl.add(cbMtd, BorderLayout.WEST);
    pnlUrl.add(cbUrl, BorderLayout.CENTER);
    pnlUrl.add(btnStart, BorderLayout.EAST);

    this.add(pnlUrl, BorderLayout.NORTH);

    // pane contains body, header, cookie, parameter
    JTabbedPane tp = new JTabbedPane();

    pnlBody = new ReqBodyPanel();
    tp.add(RESTConst.BODY, pnlBody);

    pnlHdr = new ReqTabPanel(RESTConst.HEADER);
    tp.add(RESTConst.HEADER, pnlHdr);

    pnlCookie = new ReqTabPanel(RESTConst.COOKIE);
    tp.add(RESTConst.COOKIE, pnlCookie);

    this.add(tp, BorderLayout.CENTER);

    pb = new JProgressBar();
    pb.setVisible(false);
    this.add(pb, BorderLayout.SOUTH);
    this.setBorder(BorderFactory.createTitledBorder(null, RESTConst.HTTP_REQUEST, TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION));
}