Java Code Examples for javax.swing.JLabel.setBorder()

The following are Jave code examples for showing how to use setBorder() of the javax.swing.JLabel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: jmt   File: JWatStartScreen.java   View Source Code Vote up 6 votes
private void initGUI() {
	this.setIconImage(JMTImageLoader.loadImage(IMG_JWATICON).getImage());
	this.setResizable(false);
	this.setTitle("JWAT");
	this.setSize(CommonConstants.MAX_GUI_WIDTH_JWAT_STARTSCREEN, CommonConstants.MAX_GUI_HEIGHT_JWAT_STARTSCREEN);
	//Image image = new ImageIcon(imageURL).getImage();
	//image = image.getScaledInstance(400, 315, Image.SCALE_SMOOTH);
	JPanel eastPanel = new JPanel(new BorderLayout());
	eastPanel.add(Box.createVerticalStrut(5), BorderLayout.NORTH);
	JPanel buttonPanel = new JPanel(new GridLayout(buttonAction.length, 1, 2, 2));
	eastPanel.add(buttonPanel, BorderLayout.CENTER);
	for (AbstractAction element : buttonAction) {
		buttonPanel.add(createButton(element));
	}
	JLabel imageLabel = new JLabel();
	imageLabel.setBorder(BorderFactory.createEmptyBorder(BUTTONSIZE - 5, 1, 0, 0));
	//imageLabel.setIcon(new ImageIcon(image));
	imageLabel.setIcon(new ImageIcon(new ImageIcon(imageURL).getImage().getScaledInstance(400, 315, Image.SCALE_SMOOTH)));
	imageLabel.setHorizontalAlignment(SwingConstants.RIGHT);
	imageLabel.setVerticalAlignment(SwingConstants.NORTH);
	this.getContentPane().add(imageLabel, BorderLayout.CENTER);
	this.getContentPane().add(eastPanel, BorderLayout.EAST);
}
 
Example 2
Project: incubator-netbeans   File: SummaryCellRenderer.java   View Source Code Vote up 6 votes
@Override
public Component getListCellRendererComponent (JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    Action[] actions = ((AbstractSummaryView.ActionsItem) value).getParent().getUserData().getActions();
    id = ((AbstractSummaryView.ActionsItem) value).getItemId();
    removeAll();
    labels = new HashMap<Component, Action>(actions.length);
    Component comp = dlcr.getListCellRendererComponent(list, "<html><a href=\"action\">ACTION_NAME</a>", index, isSelected, cellHasFocus); //NOI18N
    setBackground(comp.getBackground());
    for (Action a : actions) {
        JLabel label = getLabelFor((String) a.getValue(Action.NAME), isSelected ? comp.getForeground() : LINK_COLOR);
        label.setForeground(comp.getForeground());
        label.setBackground(comp.getBackground());
        label.setBorder(BorderFactory.createEmptyBorder());
        labels.put(label, a);
        add(label);
    }
    if (linkerSupport.getLinker(ActionHyperlink.class, id) == null) {
        linkerSupport.add(new ActionHyperlink(), id);
    }
    return this;
}
 
Example 3
Project: incubator-netbeans   File: RSSFeed.java   View Source Code Vote up 6 votes
private JComponent buildContentLoadingLabel() {
    JLabel label = new JLabel( BundleSupport.getLabel( "ContentLoading" ) ); // NOI18N
    label.setHorizontalAlignment( JLabel.CENTER );
    label.setVerticalAlignment( JLabel.CENTER );
    label.setOpaque( false );
    Component header = getContentHeader();
    if( null != header ) {
        JPanel panel = new JPanel( new GridBagLayout() );
        panel.setOpaque( false );
        panel.add( header, new GridBagConstraints(0,0,1,1,1.0,1.0,
            GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0 ) );
        panel.add( label, new GridBagConstraints(0,1,1,1,1.0,1.0,
            GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0 ) );
        panel.setBorder( BorderFactory.createEmptyBorder(40, 0, 40, 0));
        return panel;
    }
    label.setBorder( BorderFactory.createEmptyBorder(40, 0, 40, 0));
    return label;
}
 
Example 4
Project: openjdk-jdk10   File: TitledBorderLabelUITest.java   View Source Code Vote up 6 votes
private static void createAndShowGUI() {

        try {
            UIManager.setLookAndFeel(new TestLookAndFeel());

            JLabel label = new JLabel("Test Label");
            label.setSize(SIZE, SIZE);
            TitledBorder border = new TitledBorder("ABCDEF");
            label.setBorder(new TitledBorder(border));

            if (useLAF) {
                UIManager.setLookAndFeel(new NimbusLookAndFeel());
            } else {
                UIManager.getDefaults().put("LabelUI", MetalLabelUI.class.getName());
            }

            SwingUtilities.updateComponentTreeUI(label);

            paintToImage(label);

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
 
Example 5
Project: Tarski   File: BasicGraphEditor.java   View Source Code Vote up 5 votes
/**
 * 
 */
protected JLabel createStatusBar()
{
	JLabel statusBar = new JLabel(mxResources.get("ready"));
	statusBar.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4));

	return statusBar;
}
 
Example 6
Project: rapidminer   File: ConfigureDataView.java   View Source Code Vote up 5 votes
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
		int row, int column) {
	JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
	if (tableModel.hasError(row, column)) {
		if (errorHandlingCheckBox.isSelected()) {
			label.setBorder(WARNING_BORDER);
		} else {
			label.setBorder(ERROR_BORDER);
		}
	}
	return label;
}
 
Example 7
Project: GameOfSet   File: InfoPanel.java   View Source Code Vote up 5 votes
private JLabel createSetsCountLabel() {
    JLabel label = new JLabel("Sets found: 0.");
    label.setOpaque(true);
    label.setBackground(Color.gray);
    label.setBorder(new EmptyBorder(10, 10, 10, 10));
    return label;
}
 
Example 8
Project: xdman   File: ConfigDialog.java   View Source Code Vote up 5 votes
void createLeftPanel() {
	Box leftBox = Box.createVerticalBox();
	leftBox.setOpaque(true);
	leftBox.setBackground(StaticResource.titleColor);

	JLabel title = new JLabel(getString("CONFIG_TITLE"));
	title.setForeground(Color.white);
	title.setFont(title.getFont().deriveFont(Font.BOLD,
			title.getFont().getSize() * 1.2f));
	title.setBorder(new EmptyBorder(20, 20, 20, 40));

	leftBox.add(title);

	centerPanel.add(leftBox, BorderLayout.WEST);

	arrLbl = new JLabel[9];

	for (int i = 0; i < 9; i++) {
		String id = "CONFIG_LBL" + (i + 1);
		arrLbl[i] = new JLabel(getString(id));
		arrLbl[i].setName(id);
		arrLbl[i].addMouseListener(clickHandler);
		arrLbl[i].setForeground(Color.white);
		arrLbl[i].setFont(plainFont);
		arrLbl[i].setBorder(new EmptyBorder(5, 20, 5, 20));
		leftBox.add(arrLbl[i]);
	}
}
 
Example 9
Project: incubator-netbeans   File: ContentSection.java   View Source Code Vote up 5 votes
public ContentSection( String title, JComponent content, boolean maxSize ) {
    this( content, maxSize, 0 );
    JLabel lblTitle = new JLabel( title );
    lblTitle.setFont( SECTION_HEADER_FONT );

    lblTitle.setBorder( BorderFactory.createEmptyBorder(0, 0, 20, 0) );
    lblTitle.setForeground( Utils.getColor( COLOR_SECTION_HEADER ) );
    add( lblTitle, new GridBagConstraints(0,0,1,1,0.0,0.0,
            GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(6,0,0,0),0,0) );
}
 
Example 10
Project: geomapapp   File: ProcessingDialog.java   View Source Code Vote up 5 votes
public TaskPanel(String name, Thread task) {
	super( new BorderLayout() );

	this.name = name;
	this.task = task;

	JLabel nameL = new JLabel(name);
	nameL.setBorder(BorderFactory.createEmptyBorder(1, 2, 1, 1));
	add(nameL, BorderLayout.NORTH);

	if (task instanceof StartStopThread) {
		JButton stopB = new JButton("X");
		stopB.setMargin( new Insets(0,1,0,1));
		stopB.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				TaskPanel.this.task.interrupt();
				((StartStopThread) TaskPanel.this.task).stopTask();
			}
		});
		add(stopB, BorderLayout.EAST);
	}
	JProgressBar pb = new JProgressBar();
	pb.setIndeterminate(true);
	add(pb);

	setBorder( BorderFactory.createLineBorder(Color.black));

	int minWidth = getMinimumSize().width;
	int minHeight = getMinimumSize().height;
	int maxWidth = getMaximumSize().width;

	setPreferredSize(new Dimension(minWidth, minHeight));
	setMaximumSize(new Dimension(maxWidth, minHeight));
}
 
Example 11
Project: powertext   File: ParameterizedCompletionDescriptionToolTip.java   View Source Code Vote up 5 votes
/**
 * Constructor.
 *
 * @param owner The parent window.
 * @param ac The parent auto-completion.
 * @param pc The completion being described.
 */
public ParameterizedCompletionDescriptionToolTip(Window owner,
		ParameterizedCompletionContext context,
		AutoCompletion ac, ParameterizedCompletion pc) {

	tooltip = new JWindow(owner);

	this.pc = pc;

	descLabel = new JLabel();
	descLabel.setBorder(BorderFactory.createCompoundBorder(
				TipUtil.getToolTipBorder(),
				BorderFactory.createEmptyBorder(2, 5, 2, 5)));
	descLabel.setOpaque(true);
	descLabel.setBackground(TipUtil.getToolTipBackground());
	// It appears that if a JLabel is set as a content pane directly, when
	// using the JDK's opacity API's, it won't paint its background, even
	// if label.setOpaque(true) is called.  You have to have a container
	// underneath it for it to paint its background.  Thus, we embed our
	// label in a parent JPanel to handle this case.
	//tooltip.setContentPane(descLabel);
	JPanel panel = new JPanel(new BorderLayout());
	panel.add(descLabel);
	tooltip.setContentPane(panel);

	// Give apps a chance to decorate us with drop shadows, etc.
	PopupWindowDecorator decorator = PopupWindowDecorator.get();
	if (decorator!=null) {
		decorator.decorate(tooltip);
	}

	updateText(0);

	tooltip.setFocusableWindowState(false);

}
 
Example 12
Project: QN-ACTR-Release   File: WarningWindow.java   View Source Code Vote up 5 votes
/**
 * This is used to create components to be shown inside box
 * @param text text to be displayed inside box
 * @return created component
 */
private Component getEntry(String text) {
	JLabel label = new JLabel("<HTML>" + text + "</HTML>");
	label.setIcon(JMTImageLoader.loadImage("Warning"));
	label.setIconTextGap(BORDER);
	label.setHorizontalTextPosition(SwingConstants.RIGHT);
	label.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
	return label;
}
 
Example 13
Project: incubator-netbeans   File: ImportClassPanel.java   View Source Code Vote up 4 votes
/** Creates new form ImportClassPanel */
   public ImportClassPanel(List<TypeElement> priviledged, List<TypeElement> denied, Font font, JavaSource javaSource, int position, JTextComponent target ) {
       // System.err.println("priviledged=" + priviledged);
       // System.err.println("denied=" + denied);
       this.javaSource = javaSource;
       this.position = position;
       this.target = target;
       createModel(priviledged, denied);
       initComponents();
       setBackground(jList1.getBackground());
       
       if ( model.size() > 0) {
           jList1.setModel( model );
           setFocusable(false);        
           setNextFocusableComponent(jList1);
           jScrollPane1.setBackground( jList1.getBackground() );
           setBackground( jList1.getBackground() );
           if ( font != null ) {
               jList1.setFont(font);
           }
           int modelSize = jList1.getModel().getSize();
           if ( modelSize > 0 ) {
               jList1.setSelectedIndex(0);            
           }
           jList1.setVisibleRowCount( modelSize > 8 ? 8 : modelSize );
           jList1.setCellRenderer( new Renderer( jList1 ) );
           jList1.grabFocus();
       }
       else {            
           remove( jScrollPane1 );
           JLabel nothingFoundJL = new JLabel("<No Classes Found>");
           if ( font != null ) {
               nothingFoundJL.setFont(font);
           }
           nothingFoundJL.setBorder(javax.swing.BorderFactory.createEmptyBorder(2, 4, 4, 4));
           nothingFoundJL.setEnabled(false);
           nothingFoundJL.setBackground(jList1.getBackground());
           //nothingFoundJL.setOpaque(true);
           add( nothingFoundJL );
       }

setA11Y();
   }
 
Example 14
Project: SER316-Dresden   File: JNCalendarCellRenderer.java   View Source Code Vote up 4 votes
/**
   * Based on panel selected show markings and content related to its 
   * duration in the calendar.
   */
  public Component getTableCellRendererComponent(
      JTable table,
      Object value,
      boolean isSelected,
      boolean hasFocus,
      int row,
      int column) {
  	
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
String currentPanel = ((AppFrame)App.getFrame()).workPanel.dailyItemsPanel.getCurrentPanel();
if (d == null) {
          label.setEnabled(false);
	label.setIcon(null);
          label.setBackground(ColorMap.NULLDAY);
          return label;
      }
      
if (!isSelected) {
	CalendarDate cpsd = CurrentProject.get().getStartDate();
          CalendarDate cped = CurrentProject.get().getEndDate();
          if (!(((d.after(cpsd)) && (d.before(cped))) || (d.equals(cpsd)) || (d.equals(cped)))) {
		label.setBackground(ColorMap.NOPROJECT);
		return label;
	}
      }



label.setHorizontalTextPosition(2);
label.setEnabled(true);



      if (d.equals(CalendarDate.today())) {
          label.setBorder(BorderFactory.createLineBorder(ColorMap.TODAY));
      }
      
// set foreground color
if (d.getCalendar().get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
          label.setForeground(ColorMap.SUNDAYTEXT);
      }
else { 		
	label.setForeground(ColorMap.DAYTEXT);
}

// set background color
if (currentPanel == null)
	label.setBackground(ColorMap.FREEBG);

else if (currentPanel.equals("TASKS") && (t != null) && 
	(d.inPeriod(t.getStartDate(), t.getEndDate()))) 
		label.setBackground(ColorMap.TASKBG);

else if(currentPanel.equals("NOTES") && 
CurrentProject.getNoteList().getNoteForDate(d) != null) 
			label.setBackground(ColorMap.NOTEBG);

else if(currentPanel.equals("EVENTS") && 
(!(EventsManager.getEventsForDate(d).isEmpty()))) 
			label.setBackground(ColorMap.EVENTBG);

else if(!isSelected)
	label.setBackground(ColorMap.FREEBG);
else {
	label.setBackground(ColorMap.DAYSELECT);
}
// always display NREvents
if (EventsManager.isNonRepeatingEventsForDate(d))
	label.setIcon(IconFontSwing.buildIcon(GoogleMaterialDesignIcons.PRIORITY_HIGH, 24, ColorMap.PRIORITY));
else
	label.setIcon(null);

      return label;
  }
 
Example 15
Project: FreeCol   File: ReportTradePanel.java   View Source Code Vote up 4 votes
private JLabel createLeftLabel(String key) {
    JLabel result = Utility.localizedLabel(key);
    result.setBorder(Utility.LEFTCELLBORDER);
    return result;
}
 
Example 16
Project: FreeCol   File: AboutPanel.java   View Source Code Vote up 4 votes
/**
 * The constructor that will add the items to this panel.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 */
public AboutPanel(FreeColClient freeColClient) {
    super(freeColClient, new MigLayout("wrap"));

    // Header with image
    Image tempImage = ResourceManager.getImage("image.flavor.Title");
    JLabel apLogoLabel = new JLabel(new ImageIcon(tempImage));
    apLogoLabel.setBorder(
        new CompoundBorder(new EmptyBorder(2,2,2,2),
                           new BevelBorder(BevelBorder.LOWERED)));
    add(apLogoLabel, "center");

    // Create available Font choices
    Font fontBold = FontLibrary.createFont(FontLibrary.FontType.NORMAL,
        FontLibrary.FontSize.TINY, Font.BOLD,
        getImageLibrary().getScaleFactor());
    Font fontNormal = FontLibrary.createFont(FontLibrary.FontType.NORMAL,
        FontLibrary.FontSize.TINY, getImageLibrary().getScaleFactor());

    // Version
    JLabel apVersion = Utility.localizedLabel("aboutPanel.version");
    apVersion.setFont(fontBold);
    JLabel apRevision = new JLabel(FreeCol.getRevision());
    apRevision.setFont(fontNormal);
    add(apVersion, "newline 20");
    add(apRevision, "newline");

    // Official Site Link
    JLabel apOfficialSite = Utility.localizedLabel("aboutPanel.officialSite");
    apOfficialSite.setFont(fontBold);
    add(apOfficialSite, "newline 10");
    JButton apSiteURL = Utility.getLinkButton(SITE_URL, null, SITE_URL);
    apSiteURL.addActionListener(this);
    apSiteURL.setFont(fontNormal);
    add(apSiteURL, "newline");

    // SourceForge Project Site Link
    JLabel apSFProject = Utility.localizedLabel("aboutPanel.sfProject");
    apSFProject.setFont(fontBold);
    add(apSFProject, "newline 10");
    JButton apProjectURL = Utility.getLinkButton(PROJECT_URL, null, PROJECT_URL);
    apProjectURL.addActionListener(this);
    apProjectURL.setFont(fontNormal);
    add(apProjectURL, "newline");

    // Manual
    JLabel apManual = Utility.localizedLabel("aboutPanel.manual");
    apManual.setFont(fontBold);
    add(apManual, "newline 10");
    JButton apManualURL = Utility.getLinkButton(MANUAL_URL, null,
                                                MANUAL_URL);
    apManualURL.addActionListener(this);
    add(apManualURL, "newline");

    // License Disclaimer
    JTextArea apLegal = Utility.localizedTextArea("aboutPanel.legalDisclaimer");
    apLegal.setFont(fontNormal);
    add(apLegal, "newline 20, width 300px");

    // Copyright
    JLabel apCopyright = Utility.localizedLabel("aboutPanel.copyright");
    apCopyright.setFont(fontNormal);
    add(apCopyright, "newline 10");

    add(okButton, "newline 20, tag ok");
}
 
Example 17
Project: freecol   File: LoadingSavegameDialog.java   View Source Code Vote up 4 votes
/**
 * Creates a dialog to set the options for loading a saved game.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 * @param frame The owner frame.
 */
public LoadingSavegameDialog(FreeColClient freeColClient, JFrame frame) {
    super(freeColClient, frame);

    JPanel panel = new JPanel();
    panel.setBorder(Utility.blankBorder(10, 10, 10, 10));
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    panel.setOpaque(false);

    JLabel header = Utility.localizedHeaderLabel(
        Messages.nameKey("loadingSavegameDialog"), JLabel.CENTER,
        FontLibrary.FontSize.MEDIUM);
    header.setBorder(Utility.blankBorder(20, 0, 0, 0));

    JPanel p1 = new JPanel(new FlowLayout(FlowLayout.LEADING));
    p1.add(Utility.localizedLabel("loadingSavegameDialog.serverName"));

    serverNameField = new JTextField();

    JPanel p2 = new JPanel(new FlowLayout(FlowLayout.LEADING));
    p2.add(Utility.localizedLabel("loadingSavegameDialog.port"));

    portField = new JSpinner(new SpinnerNumberModel(FreeCol.getServerPort(),
                                                    1, 65536, 1));
    ButtonGroup bg = new ButtonGroup();
    String str = Messages.message("loadingSavegameDialog.singlePlayer");
    singlePlayer = new JRadioButton(str);
    bg.add(singlePlayer);
    str = Messages.message("loadingSavegameDialog.privateMultiplayer");
    privateMultiplayer = new JRadioButton(str);
    bg.add(privateMultiplayer);
    str = Messages.message("loadingSavegameDialog.publicMultiplayer");
    publicMultiplayer = new JRadioButton(str);
    bg.add(publicMultiplayer);

    panel.add(header);
    panel.add(p1);
    panel.add(serverNameField);
    panel.add(p2);
    panel.add(portField);
    panel.add(singlePlayer);
    panel.add(privateMultiplayer);
    panel.add(publicMultiplayer);
    panel.setSize(panel.getPreferredSize());

    initializeConfirmDialog(frame, true, panel, null, "ok", "cancel");
}
 
Example 18
Project: incubator-netbeans   File: BookmarkKeyChooser.java   View Source Code Vote up 4 votes
private void addCells(JPanel cellPanel, int cellCount, char... startToLastPairs) {
    Color foreColor = UIManager.getColor("Table.foreground");
    Color backColor = UIManager.getColor("Table.background");
    Color selForeColor = UIManager.getColor("Table.selectionForeground");
    Color selBackColor = UIManager.getColor("Table.selectionBackground");
    Border cellBorder = new LineBorder(Color.BLACK, 1, true);
    int cellId = 0;
    for (int i = 0; i < startToLastPairs.length;) {
        char start = startToLastPairs[i++];
        char last = startToLastPairs[i++];
        while (start <= last) {
            JLabel cell = new JLabel(" " + start + " ", SwingConstants.CENTER) {
                @Override
                public void paintComponent(Graphics g) {
                    Rectangle clip = g.getClipBounds();
                    Color origColor = g.getColor();
                    g.setColor(getBackground());
                    g.fillRect(clip.x, clip.y, clip.width, clip.height);
                    g.setColor(origColor);
                    super.paintComponent(g);
                }
            };
            final BookmarkInfo bookmark = key2bookmark.get(start);
            if (bookmark != null) {
                cell.setForeground(selForeColor);
                cell.setBackground(selBackColor);
                cell.setToolTipText(bookmark.getDescription(true, false, false));
                cell.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                        if (e.getClickCount() == 1) {
                            result = bookmark;
                            dispose();
                        }
                    }
                });
            } else {
                cell.setForeground(foreColor);
                cell.setBackground(backColor);
                cell.setToolTipText(NbBundle.getMessage(BookmarkKeyChooser.class,
                        "CTL_keyChooserUnoccupiedBookmarkKey")); // NOI18N
            }
            cell.setBorder(cellBorder);
            cellPanel.add(cell);
            cellId++;
            start++;
        }
    }
    // Fill in remaining cells (otherwise only would be 9x4)
    while (cellId < cellCount) {
        cellPanel.add(new JPanel());
        cellId++;
    }
}
 
Example 19
Project: zencash-swing-wallet-ui   File: TransactionTable.java   View Source Code Vote up 4 votes
public DetailsDialog(JFrame parent, Map<String, String> details)
	throws UnsupportedEncodingException
{
	this.setTitle("Transaction details...");
	this.setSize(600,  310);
    this.setLocation(100, 100);
	this.setLocationRelativeTo(parent);
	this.setModal(true);
	this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
	
	this.getContentPane().setLayout(new BorderLayout(0, 0));
	
	JPanel tempPanel = new JPanel(new BorderLayout(0, 0));
	tempPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
	JLabel infoLabel = new JLabel(
			"<html><span style=\"font-size:0.97em;\">" +
			"The table shows the information about the transaction with technical details as " +
			"they appear at ZENCash network level." +
		    "</span>");
	infoLabel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
	tempPanel.add(infoLabel, BorderLayout.CENTER);
	this.getContentPane().add(tempPanel, BorderLayout.NORTH);
	
	String[] columns = new String[] { "Name", "Value" };
	String[][] data = new String[details.size()][2];
	int i = 0;
	int maxPreferredWidht = 400;
	for (Entry<String, String> ent : details.entrySet())
	{
		if (maxPreferredWidht < (ent.getValue().length() * 6))
		{
			maxPreferredWidht = ent.getValue().length() * 6;
		}
		
		data[i][0] = ent.getKey();
		data[i][1] = ent.getValue();
		i++;
	}
	
	Arrays.sort(data, new Comparator<String[]>() 
	{
	    public int compare(String[] o1, String[] o2)
	    {
	    	return o1[0].compareTo(o2[0]);
	    }

	    public boolean equals(Object obj)
	    {
	    	return false;
	    }
	});
	
	DataTable table = new DataTable(data, columns);
	table.getColumnModel().getColumn(0).setPreferredWidth(200);
	table.getColumnModel().getColumn(1).setPreferredWidth(maxPreferredWidht);
	table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
	JScrollPane tablePane = new JScrollPane(
		table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	
	this.getContentPane().add(tablePane, BorderLayout.CENTER);

	// Lower close button
	JPanel closePanel = new JPanel();
	closePanel.setLayout(new FlowLayout(FlowLayout.CENTER, 3, 3));
	JButton closeButon = new JButton("Close");
	closePanel.add(closeButon);
	this.getContentPane().add(closePanel, BorderLayout.SOUTH);

	closeButon.addActionListener(new ActionListener()
	{
			@Override
			public void actionPerformed(ActionEvent e)
			{
				DetailsDialog.this.setVisible(false);
				DetailsDialog.this.dispose();
			}
	});

}
 
Example 20
Project: Yass   File: TestPanel1.java   View Source Code Vote up 4 votes
public TestPanel1() {
    
    iconLabel = new JLabel();
    contentPanel = getContentPanel();
    contentPanel.setBorder(new EmptyBorder(new Insets(10, 10, 10, 10)));

    icon = getImageIcon();

    setLayout(new java.awt.BorderLayout());

    if (icon != null)
        iconLabel.setIcon(icon);
    
    iconLabel.setBorder(new EtchedBorder(EtchedBorder.RAISED));
    
    add(iconLabel, BorderLayout.WEST);
    
    JPanel secondaryPanel = new JPanel();
    secondaryPanel.add(contentPanel, BorderLayout.NORTH);
    add(secondaryPanel, BorderLayout.CENTER);
}